NASM 어셈블러를 사용하여 스스로 부트 로더를 작성하려고합니다. 두 줄의 텍스트를 인쇄하고 키 누르기를 기다렸다가 키를 눌렀을 때 재부팅하려면 'r'키를 누르고 b 키를 누르면 계속 부팅하려고합니다. 그러나 그것은 내 질문의 대상이 아닙니다. (나중에이 기능을 구현할 것이므로 코드의 nop
지침을 즉시 작성합니다.) 오히려 왜 내 개행 문자 0xA
이 그런 이상한 방식으로 인쇄되는지 묻고 싶습니다. 한 번에 3 가지 항목을 모두 TODO에서 수행했지만 로더가 잘못 보지 않아야하므로 중요하다고 생각합니다. 개행 문자를 인쇄 -BIOS 레벨 어셈블리에서 개행 문자를 어떻게 인쇄합니까?
BITS 16 ; tell nasm we're working in 16 bit real mode
start: ; entry symbol for the os
mov ax, 0x07C0 ; 4 kilobyte stack space set up
add ax, 288 ; (4096+512)/16 bytes per paragraph
mov ss, ax
mov sp, 4096
mov ax, 0x07C0 ; set data segment to where we've loaded
mov ds, ax
mov si, text_string ; put our string position into SI
call write_string ; call our string-printing function
mov si, text_string_tutorial
cli ; jump here for an infinite loop
hlt
text_string db 'Mao Mao Loader 0.01 written by Safal Aryal', 0xA
text_string_tutorial db 'Press r to reboot or b to continue booting', 0x9
write_string: ; output string located in si
mov ah, 0xE ; the 'print char' function of int 0x10
.repeat:
lodsb ; get character from the string
cmp al, 0 ; check if it is zero
je .done ; if it is, jump to .done and finish the function
int 10h ; call interrupt 10h
jmp .repeat ; repeat for every char in the string
.done:
ret
read_input:
mov ah, 0x00
int 16h
cmp al, 'r'
nop
cmp al, 'b'
nop
times 510-($-$$) db 0 ; pad boot sector with zeroes
dw 0xAA55 ; standard bootsig
;TODO: read key pressed, change background colour and start writing kernel