Bootloader无法启动 - 键盘输入

时间:2016-06-11 16:16:13

标签: assembly virtual-machine bootloader

我试图制作自己的操作系统(它是一个项目)。对于这个项目,我创建了一个简单的引导加载程序,它等待用户输入几何图形的高度和宽度(如方形)。

然后引导加载程序将显示之后的数字< / strong>用户按下回车键。当我在Windows上运行它时(我运行了程序集的com版本)它完美无缺。但是在VM(oracle)上它只显示了&#34; _&#34;字符。这是引导程序:

[BITS 16]
[ORG 0x7C00]

main:
    ;mov ah,02h
    ;mov bh,0h
    ;mov dh,0h    <---tried even this(it suppose to create a cursor)
    ;mov dl,0h


    mov ax,00000011b   ;color
    push ax
    mov ax,0    ;fill
    push ax


    ;HEIGHT
    call read_one_key
    mov ah,0h;clear ax
    push ax

    ;WIDTH
    call read_one_key
    mov ah,0h;clear ax
    push ax

    mov ax,100    ;X POS
    push ax
    mov ax,100    ;Y POS
    push ax

    call pause ;wait for enter
    call rectangle

jmp $


rectangle:
    ;STACK:
    ; ----14  ->line color
    ; ----12  -> fill
    ; ----10  -> height
    ; ---- 8  -> width
    ; ---- 6  -> x pos  --|
    ; ---- 4  -> y pos  --| of the top left corner

    ;Reads from stack
    push bp
    mov bp,sp

    ;Switch to VGA mode
    mov ah,00h
    mov al,13h
    int 10h

    ;mov bx,[bp+4] ;takes the last registered parameter
    mov cx,[bp+6] ;takes the x (column)-will change
    mov dx,[bp+4] ;the line is being drwn on a single row
    mov al,[bp+14]

    loop_hor_to_R:
        ;Row remains the same
        ;The column changes
        inc cx

        call point

        mov bx,[bp+8]
        add bx,[bp+6]       
        cmp bx,cx
        jne loop_hor_to_R

    loop_ver_to_D:
        ;Row changes
        ;The column remains the same (was set previusly in bx)
        inc dx

        call point

        mov bx,[bp+4]
        add bx,[bp+10]
        cmp bx,dx
        jne loop_ver_to_D


    loop_hor_to_L:
        ;Row remains the same
        ;The column changes
        dec cx

        call point   

        mov bx,[bp+6] ;left limit of square(starting x)
        cmp bx,cx
        jne loop_hor_to_L   


     loop_ver_to_U:
        ;Row changes
        ;The column remains the same (was set previusly in bx)
        dec dx

        call point

        mov bx,[bp+4]
        cmp bx,dx
        jne loop_ver_to_U 

    pop bp
    ret

point:
    ;CX ,DX-column and row
    mov ah,0Ch
    mov bh,0h  ;page number
    int 10h
    ret

read_one_key:
    ;reads a letter from keyboard and transforms it in a number
    ;the number is stored in al
    mov ah,01h
    int 21h
    ret

pause:
    ;waits for enter to be pressed
    ;Switch to text mode

    text_loop:
        ;Read key
        mov ah,01h
        int 21h
        cmp al,0Dh;Enter code in hex
        jne text_loop

    ret

write_text:
    mov ah,02h
    mov dl,'!'
    int 21h
    ret

; End Matter
times 510-($-$$) db 0   ; Fill the rest with zeros
dw 0xAA55       ; Boot loader signature

我还没有实现填充。这是我在VM上运行它时得到的结果:


enter image description here

为什么?

0 个答案:

没有答案