Assembly 无法从引导加载程序获取结果

Assembly 无法从引导加载程序获取结果,assembly,nasm,boot,qemu,Assembly,Nasm,Boot,Qemu,我只是在汇编中编写了这段代码,但当我用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 这是我写的汇编代码,我不知道问

我只是在汇编中编写了这段代码,但当我用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

第一行不应该是第16位吗?引导加载程序代码总是16位,然后它可以切换到32位或64位代码。我将其更改为16位,但仍然是一样的,没有显示任何消息。在这里工作正常。尽管如此,您还是应该初始化CS和DS,因为BIOS可能没有按预期设置它。此外,这是高级编程,您应该能够使用调试器。Thnx解决了许多问题您的源代码注释良好。我只是因为这个原因点击了你的问题+1。确保在将来的任何问题中,您也像这里一样清楚地注释您的源代码。干得好@RidaAmine!