if else in assembly language 8086 code example
Example: if statement in assembly x86
INCLUDE asmlib.inc
.data
prompt BYTE "Enter a number",0
evenMsg BYTE "That number is even ", 0
oddMsg BYTE "That number is odd", 0
divisor DWORD 2
.code
main PROC
mov edx, OFFSET prompt ;output the prompt
call writeLine
call readInt ; read in a number
mov edx, 0 ; clear the edx for division
div divisor ; can't divide by an immediate
; use a variable
.IF edx == 0 ; if the remainder is 0
mov edx, OFFSET evenMsg ; it is an even number
.ELSE
mov edx, OFFSET oddMsg
.ENDIF
call writeLine ; write the message to the screen.
exit
main ENDP
END main