Write an assembly code to examine the content of register R2
Write an assembly code to examine the content of register R2, if it contains an even number then set each of the first 5 bits of register R1 into one.
Solution
MSG1 DB 0DH, 0AH, \"The number in R2 is even. $\"
MSG2 DB 0DH, 0AH, \"The umber in R2 is odd. $\"
;intialize r2 register here
START:
MOV AX, r2 ; moving regsiter r2 value into accumulator
MOV DS, AX
MOV BL, 02 ; moving 02 in BL register
MOV AX, 59 ; moving 59 into AX
DIV BL ; prforming division operation
CMP AH, 00H ; comparing if reminder is 0 or not
JZ EVEN ; jump if reminder is 0
JNZ ODD ; if not 0
EVEN:
MOV DX, OFFSET MSG1 ;READ CHARACTER ONE BY ONE
SBR r1,1; ;set r1 bit
JMP FINAL
ODD:
MOV DX, OFFSET MSG2 ; READ CHARACTER ONE BY ONE
JMP FINAL
FINAL:
MOV AH, 09H ;
INT 21H ; INTTERUPT WHEN CPU BUSY
END
