8086 assembler tutorial for beginners (part 7)

program flow control

controlling the program flow is a very important thing, this is where your program can make decisions according to certain conditions.



Note: the latest version of the integrated 8086 assembler automatically creates a workaround by replacing the conditional jump with the opposite, and adding big unconditional jump. To check if you have the latest version of emu8086 click help-> check for an update from the menu.



Another, yet rarely used method is providing an immediate value instead of label. When immediate value starts with $ relative jump is performed, otherwise compiler calculates instruction that jumps directly to given offset. For example:


org    100h

; unconditional jump forward: 
; skip over next 3 bytes + itself  
; the machine code of short jmp instruction takes 2 bytes.  
jmp $3+2
a db 3    ; 1 byte. 
b db 4    ; 1 byte. 
c db 4    ; 1 byte. 

; conditional jump back 5 bytes: 
mov bl,9
dec bl      ; 2 bytes. 
cmp bl, 0   ; 3 bytes. 
jne $-5     ; jump 5 bytes back 

ret






<<< previous part <<<      >>> Next Part >>>