Frage

Here is my code: http://pastebin.com/pSncVNPK

    [BITS 16]           ;Tells the assembler that its a 16 bit code
    [ORG 0x7C00]        ;Origin, tell the assembler that where the code will
                        ;be in memory after it is been loaded

    MOV SI, HelloString ;Store string pointer to SI
    CALL PrintString    ;Call print string procedure
    JMP $       ;Infinite loop, hang it here.


PrintCharacter: ;Procedure to print character on screen     
                ;Assume that ASCII value is in register
    AL MOV AH, 0x0E ;Tell BIOS that we need to print one charater on screen.
    MOV BH, 0x00    ;Page no.
    MOV BL, 0x07    ;Text attribute 0x07 is lightgrey font on black background

    INT 0x10    ;Call video interrupt RET       ;Return to calling procedure



PrintString:    ;Procedure to print string on screen
                ;Assume that string starting pointer is in register SI

next_character: ;Label to fetch next character from string
    MOV AL, [SI]    ;Get a byte from string and store in AL register
    INC SI      ;Increment SI pointer
    OR AL, AL   ;Check if value in AL is zero (end of string)
    JZ exit_function ;If end then return
    CALL PrintCharacter ;Else print the character which is in AL register
    JMP next_character  ;Fetch next character from string
exit_function:  ;End label
    RET     ;Return from procedure


    ;Data
    HelloString db 'Hello World', 0 ;HelloWorld string ending with 0

    TIMES 510 - ($ - $$) db 0   ;Fill the rest of sector with 0
    DW 0xAA55           ;Add boot signature at the end of bootloader

As you can see the syntax appears to be correct, compiled it into a .bin file, BUT I'm trying to figure out how to test it. Please treat me like I'm a bit slow because I've spent HOURS googling this topic and nothing seems to work, I've even tried using a hex editor as per some tutorial but it didn't work. This seems to be the closest I've gotten is using these instructions: http://puu.sh/6KzUo.png

from this link: How to make an bootable iso(not cd or flash drive) for testing your own boot loader?

Except I don't quite understand step 6 because VM box won't let me select the img file as a bootable disk.

Thanks!

War es hilfreich?

Lösung

If you just need to add a Floppy Disk into the disk controller, this is how to do it:

Click on the Floppy Controller. An icon of a floppy with a green plus sign should come up on the left of your selection. Click on this small icon.

enter image description here


A dialog should now come up:

enter image description here

Select "Choose Disk"

The file selection box will come up---at this point, choose your .img file from the file selection box.

enter image description here

From this point you should be able to boot the virtual machine from the floppy disk and test your bootloader.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top