I'm trying to get into assembler and I'm reading through a document that gives a short introduction. There is a task to convert the following code to pure assembler code:
mov bx, 30
if (bx <= 4) {
mov al , ’A’
} else if (bx < 40) {
mov al, ’B’
} else {
mov al, ’C’
}
mov ah, 0x0e
int 0x10 ; print the character in al
jmp $
; Padding and magic number.
times 510-($-$$) db 0
dw 0xaa55
I created this assembler code:
mov bx, 30
cmp bx, 4
jle if_branch
cmp bx, 40
jl elif_branch
mov al, 'C'
if_branch:
mov al, 'A'
elif_branch:
mov al, 'B'
mov ah, 0x0e
int 0x10
jmp $
times 510-($-$$) db 0
dw 0xaa55
However no matter what I put into bx in line 1 the output will always be 'B'. What am I missing there?
My setup: I'm writing the assembler code in codeblocks and use nasm to create a bin file. Then I execute that bin file using qemu.
Aucun commentaire:
Enregistrer un commentaire