Write a possible assembly language instruction or set
of instructions to accomplish the following:
Compare the byte stored at the memory location pointed to by
register R4 to the upper (higher) byte stored in register
R5
b) Branch to instruction at label ‘ZERO’ if the lower byte of
register R6 is zero
c) Jump to the instruction at label ‘EVEN’ if the
value in register R7 is an even number
Writtten for ARM 32 bit
a) LDRB R4,[R4] ; loads byte pointed by memoy address in R4 to R4
MOV R5,R5 LSR #0x18 ; R5 is shifted 24 times(hexa number 18) right so that R5(32 bit reg) contains upper byte
; if reisters are 16 bits as in Keil ARM , then shift only 8 times
CMP R4,R5 ;compare R4 and R5
b)AND R6,R6,#0x00FF ; And with 00ff ,all bits except lower byte, set to 0. lower byte retained.
CBZ $R6,ZERO ;if R6 is zero, jump to label ZERO or use (CMP $R6,#0 BEQ ZERO )
c)AND R7,R7,#0x0001 ; if even number, AND results 1 else 0
CBZ $R7,EVEN ; if R7 is 0, then even number or use (CMP $R7,#0 BEQ EVEN )
Get Answers For Free
Most questions answered within 1 hours.