H
H
HelpMePlease22020-12-23 10:49:13
assembler
HelpMePlease2, 2020-12-23 10:49:13

Why is this asm code running?

I have code that compiles with NASM and runs in QEMU. It should just output Hello, world in the BIOS. But along with it, reboot_req is launched. What is the problem?

[org 0x8000]

mov si, helloworld
call print
mov si, newline
call print

reboot_req:
    mov si, reboot_request
    call print
    mov ah, 0x0
    int 0x16
    int 0x19

%include "print.asm"
helloworld: db "Hello, world!!!", 0
newline: db 0x0d, 0xa, 0
reboot_request: db 0x0d,0xa, "Press any key to reboot...", 0x0d,0xa,0
cmd: db "$ ", 0
wrongcmd: db "Wrong command!!!", 0
times 2048-($-$$) db 0

And this is the print.asm file
print:
    push ax
    push si

    mov ah, 0x0e
    .Loop:
    mov al, [si]
    cmp al, 0
    je .Exit
    int 0x10
    inc si
    jmp .Loop
    .Exit:
    pop ax
    pop si
    ret

Answer the question

In order to leave comments, you need to log in

1 answer(s)
E
Evgeny Matveev, 2021-02-28
@ematveev

print.asm

print:
    push ax
    push si
......
    pop ax
    pop si

first you need to fix the error - the pop commands must be called in the reverse order, compared to the push commands, and for you they are NOT in the reverse order

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question