0

I am trying to make a very simple bootloader in GAS assembly, and i am making a print function for it.

It doesn't print anything

printing a single char by movb $0x41, %al and int 0x10. compiled as file.s and ld -o file.bin --oformat binary -e main a.out

boot_print.s:

print:
        movb    (%rbp), %al
        cmpb    $0, %al
        je      print_end
        int     $0x10
        inc     %rbp
        jmp     print
print_end:
        ret

boot_main.s

.global main

main:
        movb    $0x0e, %ah
        movl    $msg, %ebx
        call    print
        jmp .

.include "boot_print.s"

msg:
        .ascii  "Hello, World!\n"

.fill   510-(.-main), 1, 0
.word   0xaa55

Thanks for reading guys!

Peter Cordes
  • 328,167
  • 45
  • 605
  • 847
  • Legacy BIOS MBR bootloaders run in 16-bit mode, but you're making 64-bit code (apparently intentionally by using `%rbp`!). Use `as --16` if that works, and `ld -melf_i386`. Disassembling your flat binary with `ndisasm -b16` will show you how it will execute, or use a debugger. – Peter Cordes Jul 20 '21 at 16:53
  • [Calculating padding length with GAS AT&T directives for a boot sector?](https://stackoverflow.com/q/47859273) shows a working GCC `-m32` command that will work if you put `.code16` at the top of your file. – Peter Cordes Jul 20 '21 at 16:55
  • alright thanks guys! – wannastacksmash Jul 20 '21 at 18:23

0 Answers0