Write a program that uses addition and subtraction to set and clear ZERO flag?
ZERO Flag is a type of control flags which tells the CPU whether the answer is completer zero or not. Following program shows how to set and clear zero flag in assembly language by adding and subtracting two register values.
.model small ; sets the memory model to small
.stack 100h ; sets the size of the stack to 100h bytes (256 bytes)
.data ; start of the data segment
; there is no data defined in this code
.code ; start of the code segment
main proc ; start of the main procedure
mov bl, 5 ; move the value 5 into the BL register
mov dl, 5 ; move the value 5 into the DL register
SUB dl, bl ; subtract the value in BL from the value in DL and store the result in DL
; the result is 0, so the zero flag is set
ADD dl, bl ; add the value in BL to the value in DL and store the result in DL
; the result is 5, so the zero flag is cleared
mov ah, 4ch ; move the value 4ch (which represents the "exit" function) into the AH register
INT 21h ; call the interrupt 21h, which executes the function stored in the AH register
main endp ; end of the main procedure
end main ; end of the program


1 Comment
Thanks.