Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

assembally code register addressing

Options
  • 21-01-2005 5: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 Posts: 7,276 ✭✭✭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 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 Posts: 23,212 ✭✭✭✭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