DEV Community

Jaipal001
Jaipal001

Posted on

64-bit bootloader from scratch in AT&T assembly, Part-4

.code64    # 64-bit mode
entry64:
    mov $KERNEL_OFFSET, %rax     # load and run kernel
    call *%rax

print_cli:         # print data into video memory
    mov $0xb8000, %ecx # VIDEO_MEMORY
print_loop_cli:
    # edx = str
    mov $0, %eax
    movb (%edx), %al   # str[i]
    mov $0x0f, %ah    # white fg, black bg
    cmp $0, %al
    je print_end_cli
    mov %ax, (%ecx)
    add $2, %ebx
    add $2, %ecx
    add $1, %edx
    jmp print_loop_cli
print_end_cli:
    ret

println_cli:
    mov $0xb8000, %ecx # VIDEO_MEMORY

    mov $0x0f0a, %eax  # 0f\n
    add %ebx, %ecx
    mov %eax, (%ecx)
    mov $1, %ebx
    ret
Enter fullscreen mode Exit fullscreen mode

Top comments (0)