Search code examples
assemblykernelvirtualboxbootloaderemu8086

Kernel worked in emu8086 but not in virtual box with floppy controller


I am writing a simple OS, I wrote the bootloader and kernel in emu8086, and then I write to the floppy sectors. When I boot from floppy drive inside emu, everything works normal, but when I boot from floppy inside virtual box - it can't do operations.

For example the following command gets the system date and time:

infoCommand:
lea si, info_msg
call printString  

;Day Part
mov ah, 2Ah    ; To get System Date
int 21h
mov al, dl   ; Day is in DL
aam
mov bx, ax
call disp

mov dl, '/'
mov ah, 02h    ; To Print / in DOS
int 21h

;Month Part
mov ah, 2Ah    ; To get System Date
int 21h
mov al, dh     ; Month is in DH
aam
mov bx, ax
call disp

mov dl, '/'
mov ah,02h    ; To Print / in DOS
int 21h

;Year Part
mov ah, 2Ah    ; To get System Date
int 21h
add cx, 0F830h ; To negate the effects of 16bit value,
mov ax, cx     ; since AAM is applicable only for AL (YYYY -> YY)
aam
mov bx, ax
call disp     

mov dl, ' '
mov ah,02h    ; To Print '' in DOS
int 21h

;Hour Part
mov ah, 2Ch    ; To get System Time
int 21h
mov al, ch     ; Hour is in CH
aam
mov bx,ax
call disp

mov dl, ':'
mov ah,02h    ; To Print : in DOS
int 21h

;Minutes Part
mov ah, 2Ch    ; To get System Time
int 21h
mov al, cl     ; Minutes is in CL
aam
mov bx, ax
call disp

mov dl, ':'
mov ah,02h    ; To Print : in DOS
int 21h

;Seconds Part
mov ah, 2Ch    ; To get System Time
int 21h
mov al, dh     ; Seconds is in DH
aam
mov bx,ax
call disp  

ret  
     
;Display Part
disp proc
mov dl, bh      ; Since the values are in BX, BH Part
add dl, 30h     ; ASCII Adjustment
mov ah, 02h     ; To Print in DOS
int 21h
mov dl, BL      ; BL Part 
add dl, 30h     ; ASCII Adjustment
mov ah, 02h     ; To Print in DOS
int 21h
ret
disp endp      ; End Disp Procedure
  1. In emu I get this enter image description here

  2. in virtual box I get this enter image description here

Can you help with what is wrong?


Solution

  • int 21h is a DOS call.

    DOS is an operating system.

    You're writing your own operating system.

    In VirtualBox there is no OS loaded except for yours.

    You can't call DOS if you're the only OS.

    You call BIOS services, but generally operating systems talk to the hardware directly.


    If you look at the tag wiki for emu8086, you'll see (emphasis mine):

    8086 source editor, assembler, disassembler, and software emulator (a virtual PC with MSDOS Interface)