Я написал свой первый загрузчик с помощью GNU Assembler с AT & T синтаксисом. Предположим, чтобы напечатать hello world
на экране, затем сообщите пользователю, что нажатие любой клавиши приведет к перезагрузке. Только после нажатия клавиши происходит перезагрузка, которая должна быть инициирована. Мой код загрузчика не ждет ключа и автоматически перезагружается после печати информации. Почему этот код не ждет нажатия клавиши, и как я могу его исправить?INT 16h/AH = 0h не ждет нажатия клавиши в моем загрузчике
Мой код загрузочного сектора:
#generate 16-bit code
.code16
#hint the assembler that here is the executable code located
.text
.globl _start;
#boot code entry
_start:
jmp _boot #jump to boot code
welcome: .asciz "Hello, World\n\r" #here we define the string
AnyKey: .asciz "Press any key to reboot...\n\r"
.macro mWriteString str #macro which calls a function to print a string
leaw \str, %si
call .writeStringIn
.endm
#function to print the string
.writeStringIn:
lodsb
orb %al, %al
jz .writeStringOut
movb $0x0e, %ah
int $0x10
jmp .writeStringIn
.writeStringOut:
ret
#Gets the pressed key
.GetPressedKey:
mov 0, %ah
int $0x16 #BIOS Keyboard Service
ret
.Reboot:
mWriteString AnyKey
call .GetPressedKey
#Sends us to the end of the memory
#causing reboot
.byte 0x0ea
.word 0x0000
.word 0xffff
_boot:
mWriteString welcome
call .Reboot
#move to 510th byte from the start and append boot signature
. = _start + 510
.byte 0x55
.byte 0xaa
спасибо :) он работает сейчас –