How to debug custom OS with VirtualBox?

2019-08-29 09:50发布

问题:

I am developing my own operating system. So far, I have this code:

ORG 0x7C00
BITS 16

mov si, msg
call Print

cli
hlt

Print:
  lodsb
  cmp al, 0
  je Done
  mov ah, 0Eh
  mov bh, 0
  int 10h
  jmp Print

Done:
  ret

msg db 'Hello World!', 0
times 510-($-$$) db 0
dw 0xAA55

I have used nasm -f bin bootloader.asm -o myos.hdd to create the hard drive file.

I am successfully able to run this code in VirturalBox.

Now, I am trying to figure out how to use the debug feature on VirturalBox. So far, I have been able to open the debug session by running

VirtualBox --debug-command-line --start-dbg --startvm MYOS

This starts my OS with a debug console. This is the point where I am stuck.

1) How am I able to actually start my operating system from this console?
2) How can I view registers such as ax and al?
3) How can I set breakpoints, such as at the print function?