a simple os
;nasm os.asm -o os.com ;用winhex复制粘贴到c.img,使用bochs调试 org 07c00h ; 告诉编译器程序被加载到07c00h处 mov ax, cs mov ds, ax mov es, ax call DispStr ; display a string on screen jmp $ ; 无限循环 DispStr: mov ax, BootMessage mov bp, ax ; es:bp =串地址 mov cx, 16 ; 串长度 mov ax, 01301h ; ah=13, al=01 mov bx, 000ch ; bh=0, bl=0ch(黑底红字) mov dl, 0 int 10h ret BootMessage: db "hello, OS world!" times 510-($-$$) db 0 ; 填充剩余的空间为0,共512byte Sign dw 0xaa55 ; mbr sign
PS:
$ = 当前行被汇编后的地址
$$ = 当前节的地址
$-$$ = 当前行相对于节的偏移