x86 - OS's Boot-loader doesn't work -


I am creating a custom operating system. I have two NASM files:

boot.asm:

  [bits 16]; The assembler points out that its a 16 bit code [ORG 0x7C00]; Origin, tell the assembler where the code will be; After this INT 0x13 JMP $ is loaded in memory; Infinite Loop Times 510 - ($ - $$) Database 0; Fill the rest of the field with 0 DW 0xAA55; Add boot signature  

start.asm:

  [16 bit] MOV AL, 72 calls PrintCharacter MOV AL, 101 calls PrintCharacter MOV AL, 108 calls PrintCharacter MOV AL, 108 Call PrintCharacter MOV AL, 111 Call PrintCharacter MOV AL, 44 Call PrintCharacter MOV AL, 32 Call PrintCharacter MOV AL, 87 Call PrintCharacter MOV AL, 111 Call PrintCharacter MOV AL, 114 Call PrintCharacter MOV AL, 108 Call PrintCharacter MOV AL , 100 calls PrintCharacter MOV AL, 33 calls PrintCharacter PrintCharacter: MOV AH, 0x0E MOV Bihar, 0x00 MOV BL, 0x07 INT 0x10 REIT Times 512 - ($ - $$) Database 0  

I Compile them into .bin files using these commands:

  nasm boot.asm -f bin -o boot Then add them to the floppy image with these commands:  
  DD if = boot .bin BS = 512 = MyOS.img count = 1 dd if = start.bin BS = 512 = MyOS.img count = 2  

When I boot from the floppy image in VirtualBox It shows 2 exclamation instead of one and instead it does not boot in QEmu (Q.app). I am new to the development of the operating system and it would be good if someone told me what I did and I have been given some hints how to better set up my OS.

Of course, it prints two exclamation points. Let's look at your code:

  ... MOV AL, 33 call printcracker; | 1; | ^ | 4 printcracker:; Wei | 2 | | MOV AH, 0x0 E; | | | MOV BH, 0x00; | | | MOV BL, 0x07; | | | INT 0x10; | | | 5; V | 3 v ---- & gt; Leave for LA LAND  

Note: I show some arrows how the program execution income is added

The first two lines are the last ! are responsible for printing. You already have the output Hello, World this is achieved by calling your PrintCharacter sub-process (arrow 1 and 2 .) When printCharacter returns (arrow 3 ), your program runs straight ahead (Arrow 4 ) ... and the next line of code again starts from PrintCharacter as the AL register still contains 33 (i.e. < Code>! for AN SI code), another exclamation mark is printed.

Then, the execution once again happens to RET , but this time, since you actually have call PrintCharacter was not there, there is no defined place to go back, so it ... some undefined location, most probably (arrow 5 ). I think it immediately starts where your OS stops continuing with the boot process.

Conclusion: Print your code Hello World! After , something else (it should be at least paused ), otherwise you should not be surprised if unchecked behavior or hanging ...


Comments