我刚刚在汇编中编写了这段代码,但是当我用nasm编译它并用QEMU执行图像时,我得到的是从软盘启动... 这些是我使用的指令
nasm -f bin ENSIASiX.asm -o ENSIASiX.bin
dd if=/dev/null of=ENSIASiX.img count=1 bs=512
dd if=ENSIASiX.bin of=ENSIASiX.img conv=notrunc
qemu -fda ENSIASiX.img -boot a
这是我写的汇编代码我不知道问题是代码还是我汇编的方式
bits 16 ; system 16-BITS
org 0x7C00 ; BIOS Boot Original
jmp Main
memoryerror:
MOV SI, errorr
CALL PrintString
RET
PrintCharacter: ; a function to print characters in the screen
MOV AH, 0x0E ;telling the BIOS that we want to print one character on screen
MOV BH, 0x00 ;the number of the page where to print the character
MOV BL, 0x07 ;the color is light-grey font on black background
INT 0x10 ;call video interruption
RET ;returning from calling procedure
PrintString: ;the procedure to print string on screen
NextCharacter: ;label to fetch the next character from string
MOV AL,[SI] ;take a byte from the string and store it in AL register
INC SI ;increment SI to get the next_character
OR AL, AL ;Check if it's the end of the string
JZ ExitFunction ;Jump to ExitFunction label if the result is zero (END OF STRING)
CALL PrintCharacter ;Else call the function PrintCharacter
JMP NextCharacter ;take the next character
ExitFunction: ;the end of function label
RET ;returning from calling procedure
Main:
MOV SI, Welcome ;Store String in pointer to SI " Welcome User to the RATM V 0.5 BootLoader for ENSIASiX operating System "
CALL PrintString ; call the function to print the string stored in SI
MOV SI, Wait_MSG ;store string in pointer to SI
CALL PrintString ;call the function to print the string stored in SI
MOV AH, 0
INT 0x16 ;AH = 0 and Interruption 0x16 for get keystroke from keyboard
XOR AX, AX ;make AX register null
INT 0x12 ;Interruption for Detecting low Memory
JC memoryerror ; Carry is set if not enough memory
TEST AX, AX ;Test the AX register with itself
JZ memoryerror ; Zero is set if not enough memory
MOV SI, memory_enough ; string 'size is enough in RAM :D' message to SI
CALL PrintString ; printing the message 'size is enough in RAM :D'
JMP $ ;infinite loop
Welcome db 'Welcome User to the RATM V 0.5 BootLoader for ENSIASiX operating System',0 ;the welcome string ending with 0
Wait_MSG db 'Press any key to continue ...',0 ;wait message string ending with 0
errorr db 'Memory Error ... ',0 ;not enough memory error ending with 0
memory_enough db 'size is enough in RAM :D'
TIMES 510 - ($ - $$) db 0 ;Fill the rest of sector with 0
DW 0xAA55 ;Add boot signature at the end of boot-loader