Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

assembally code register addressing

  • 21-01-2005 05:44PM
    #1
    Closed Accounts Posts: 35


    dunno if anyone here does embedded programming, if ya do Ive a little knot I need some help with
    Im working with a 87C552, an 8051 derivative, and am reading a number from a keypad to use as an Id to select a servo motor to run PWM to.
    1) I have the keypad scan function saving the kay value to the accumulator.
    2) I have the current PWM value for each of the 5 motors stored in registers 1 to 5

    How do I use the number in the accumulator to select the information in the relevant register?
    IE
    if A = 3
    then
    move data from R3 to PWM0.


Comments

  • Registered Users, Registered Users 2 Posts: 7,289 ✭✭✭kenmc


    unfortunately this is all chip specific - depends on the instruction set of the processor.
    dunno the assml lang of that chip i'm afraid...
    one way would be to write it in C and step through a debugger though possibly....


  • Registered Users, Registered Users 2 Posts: 1,391 ✭✭✭fatherdougalmag


    Here's the programming guide/instruction set for the 80C51.

    There's a couple of 'compare and branch' instructions. Or you could back up the value in A, subtract 3 and then do a JNZ (which implies that A wasn't 0) over the 'move' instruction.

    Sorry, just reading off the specs. Never worked with this chip.


  • Registered Users, Registered Users 2 Posts: 23,202 ✭✭✭✭Tom Dunne


    toblerone wrote:
    How do I use the number in the accumulator to select the information in the relevant register?
    IE
    if A = 3
    then
    move data from R3 to PWM0.
    Oooooh, it's been a long time since I looked at an 8051.

    I think the best approach would be to take the data out of the Accumulator and move it to an address. You could then use the CJNE - compare and jump if not equal command - for each of the registers.


Advertisement