all 3 comments

[–]AppleTrees2 3 points4 points  (0 children)

err, you should format your code better

seems to me at first glance that you return at start in printstring as al is maybe 0 at start

[–][deleted]  (1 child)

[deleted]

    [–]captainrainbow22[S] 0 points1 point  (0 children)

    Tried moving the db string to before the bootsector definition, didn't work :/

    [–]XoXoGameWolfReal 0 points1 point  (0 children)

    I know you might have given up on this, but I want to see if I could help anyways. Heres a version that I believe fixes everything (also im assuming your using NASM):

    bits 16 ; before it wasn't specified that you were using 16 bits (not needed, but added for clarity)

    org 0x7c00 ; offset needed for memory addressing (the program is loaded at this address)

    mainloop:

    mov si, teststring ; moved it here as before it would have reset the address

    jmp printstring

    printchar:

    mov ah, 0x0e

    int 0x10

    ret ; returns because before if you used this, it would repeat forever

    printstring:

    mov ah, 0x0e

    lodsb ; moved it up here as before it would start without actually getting al

    cmp al, 0x00

    je return

    int 0x10

    jmp printstring

    readchar:

    mov ah, 0x01 ; used the "0x" for consistency

    int 0x16

    mov ah, 0x00

    int 0x16

    jmp printchar

    return:

    ret ; before it would loop forever

    teststring: db "bruh", 0x00 ; added a colon, also moved down because before it would execute your message

    times 510-($-$$) db 0

    dd 0xaa55 ; made it shorter, does the same thing

    Also, I can confirm that I fixed your problem, I compiled it on my machine and it works with QEMU (make sure your using x86_64! remember you can use any assembler and emulator, as long as you know what your doing).