Question

Complete this AVR assembly language fragment so that it adds the unsigned 16-bit value in register...

Complete this AVR assembly language fragment so that it adds the unsigned 16-bit value in register pair r9:r6 to the unsigned 16-bit value in r7:r8. (Registers 9 and 7 are the most signficant bytes in these 16-bit quantities. The result ends up in r7:r8.)

addadcadiwr6r7r8r9  addadcadiwr6r7r8r9 ,  addadcadiwr6r7r8r9
addadcadiwr6r7r8r9  addadcadiwr6r7r8r9 ,  addadcadiwr6r7r8r9

Homework Answers

Answer #1

/* Add the unsigned 16-bit value in register pair r9:r6 to the unsigned 16-bit value in r7:r8. The result ends up in r7:r8. */

.include "m328-pdef.inc" ; Includes AVR related functions

.eq    rstart = 0x00
.def    r1 = r9:r6 ;defining registers
.def    r2 = r7:r8 ;defining registers
.ds ; data segment
.org rstart
r3: .byte 2 ;holds 16 bit registers r9:r6
r4: .byte 2 ;holds 16 bit registers r7:r8
.cseg
.org 0x00
jmp begin ; jump to loop begin

begin:
    movw r3,r1 ; move the content of r1 to r3
    movw r4,r2 ; move the content of r2 to r4
    add r3,r4  ; add the content and store in r3
    ret        ; return the computed result
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT