Code is for a msp430 microcontroller. 1 Write an assembly program with the follo
ID: 3905612 • Letter: C
Question
Code is for a msp430 microcontroller.
1 Write an assembly program with the following specifications a. In the main block, you should have two registers R4 and R5. They should be checked in an infinite loop. If R4 is greater than R5, then the greater subroutine will be called If R4 is less than R5, then the less subroutine will be called. If R4 equals R5, then no operations will be done. In the greater subroutine, your code will fill the decimal numbers 1,2, 3, 4, 5 in hex- adecimal form to five successive memory locations. After this operation, the value in R4 will be decreased by one. c. In the less subroutine, your code will fill the decimal numbers 10,9,8,7,6 in hexadecimal form to five successive memory locations. After this operation, the value in R4 will be decreased by one.Explanation / Answer
.text
.global _main
arr1 DB 1,2,3,4,5
arr2 DB 10,9,8,7,6
_main mov.w #0280h,SP ; initialize stack pointer
mov.w #WDTPW+WDTHOLD,&WDTCTL ; stop watchdog timer
Init mov.w #arr1, R11
mov.w #arr2, R12
Mainloop cmp R4,R5
jl less
jg greater
less mov.w R11,#0x0A0000
inc.w R11
dec.w R4
jz Conc
jmp Mainloop
greater mov.w R12,#0x0B0000
inc R12
dec.w R5
jz Conc
jmp Mainloop
Conc jmp $
.sect ".reset" ; MSP430 RESET Vector
.short _main
.end