Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Assembly code need explanation

Status
Not open for further replies.
Oct 21, 2003
3
US
Hello,

I have a hw assignment below and I don't know what the three lines doing, can someone kindly explain to me?

Thanks,
Tracy

Assume the following lines of HC11 code run on your HC11 system (MC68HC11E1 chip, program loaded into RAM during bootstrap)

PORTA= 0x1000

ldaa #3
staa PORTA
ldaa PORTA

What will be the value in the A accumulator after these lines of code have executed?

 
Hey Tracy,

Well... I have not worked with Motorola assembler since my Commodore Vic 20 back in the 80s. However, this is what I can tell you:

[tt]LDAA[/tt] means load immediate value to accumulator
[tt]STAA[/tt] means store immediate value to accumulator
The [tt]#3[/tt] means the immediate value 3 -not the value of another register...

[tt]PORTA = 0x1000[/tt] refers to a hardware hexadecimal address. 0x1000 equals to the binary value 0001.0000.0000.0000

[tt]LDAA #3[/tt] loads the dicimal value 3 into the accumulator
[tt]STAA PORTA[/tt] sends the accumulator value (3) to PORTA (0x1000)
[tt]LDAA PORTA[/tt] reads from value from PORTA (0x1000) to the accumulator.

What does the accumulator hold then? Well, that depends what is at address 0x1000. If a buffer or latch is placed on that address, you should read back the same value, hence 3!

Hope this can guide you in the right direction!!

Good luck with your assignment §;O)


Jakob

PS. You should have a Motorola Instruction set reference manual at hand.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top