0

I'm teaching myself assembly (NASM) through 16-bit boot loader programming, and I've come across a problem. I wrote a program that uses a function print to display "Hello,World!" to the screen, but I only get 'U' as my output.

Here is the assembly:

print:
    pusha
    mov ah, 0x0e
    int 0x10
    popa
    ret

mov al, 'H'
call print
mov al, 'e'
call print
mov al, 'l'
call print
mov al, 'l'
call print
mov al, 'o'
call print
mov al, ','
call print
mov al, 'W'
call print
mov al, 'o'
call print
mov al, 'r'
call print
mov al, 'l'
call print
mov al, 'd'
call print
mov al, '!'
call print

jmp $

times 510-($-$$) db 0
dw 0xaa55

I'm sure it's something really obvious or stupid, as I'm just getting started. Thanks in advance.

yossarian
  • 1,537
  • 14
  • 21
  • 1
    You appear to be executing your `print` function first. When it gets to `ret`, there's no return address to return to, so you crash. Jump over it, or put the subroutine last. – Frank Kotler Apr 14 '14 at 02:20
  • Wow, that was incredibly dumb of me. Thanks. – yossarian Apr 14 '14 at 02:26

0 Answers0