0

I need just welcome message printed.

There are some hints on this forum, however it's hard to put all up together.

So I've created a mininmal .asm similar to this one

[ORG 0x7c00]   
BITS 16

main:
                mov ax, 0x07C0                                  
                mov ds, ax         
                mov es, ax         

                mov bp, message    
                mov bh, 0          
                mov bl, 00001111b  
                                   
                mov cx, 13         
                mov al, 1          
                                   
                mov ah, 0x13       
                mov dx, 0          
                int 0x10           

                cli
                hlt
                
                jmp $

message     db      "Hello, World!"
length      db      (length - message)
                             
times   510-($-$$) db 0
dw      0xaa55           

Build:

nasm -f bin sboot.asm -o sboot.bin
dd if=sboot.bin of=sboot.img bs=512 count=1 conv=notrunc

And convert IMG file to ISO with program CDBurnerXP. I am using 'Boot options...' and select:

  • Emulation type = Diskette 1.44MB (boot image 95/98/ME)
  • Load segment = 7c0
  • Sectors: 1
  • Platform: x86-64 I also add dummy txt file, so that the ISO is not empty and save everything as ISO file.

Then I try to run it in Virtual Box with minimum options (disabled: audio, network, USB) and it crashes. Container goes into status 'Aborted'

Log from VirtualBox says nothing particular:

00:00:06.813147 PDMLdr: pdmR3LoadR0U: pszName="VMMR0.r0" rc=VERR_LDR_GENERAL_FAILURE szErr="SUP_IOCTL_LDR_OPEN failed"
00:00:06.813197 VMSetError: F:\tinderbox\win-rel\src\VBox\VMM\VMMR3\PDMLdr.cpp(750) int __cdecl pdmR3LoadR0U(struct UVM *,const char *,const char *,const char *); rc=VERR_LDR_GENERAL_FAILURE
00:00:06.813199 VMSetError: Failed to load R0 module C:\Program Files\Oracle\VirtualBox/VMMR0.r0: SUP_IOCTL_LDR_OPEN failed
00:00:06.813209 VMSetError: F:\tinderbox\win-rel\src\VBox\VMM\VMMR3\VM.cpp(585) int __cdecl vmR3CreateU(struct UVM *,unsigned int,int (__cdecl *)(struct UVM *,struct VM *,const struct VMMR3VTABLE *,void *) noexcept,void *); rc=VERR_LDR_GENERAL_FAILURE
00:00:06.813212 VMSetError: Failed to load VMMR0.r0
00:00:06.813425 ERROR [COM]: aRC=E_FAIL (0x80004005) aIID={6ac83d89-6ee7-4e33-8ae6-b257b2e81be8} aComponent={ConsoleWrap} aText={Failed to load R0 module C:\Program Files\Oracle\VirtualBox/VMMR0.r0: SUP_IOCTL_LDR_OPEN failed (VERR_LDR_GENERAL_FAILURE).
00:00:06.813445 Failed to load VMMR0.r0 (VERR_LDR_GENERAL_FAILURE)}, preserve=false aResultDetail=-618
00:00:06.813679 Console: Machine state changed to 'PoweredOff'
00:00:06.980955 Power up failed (vrc=VERR_LDR_GENERAL_FAILURE, rc=E_FAIL (0X80004005))
00:00:06.984607 GUI: UIMachineViewNormal::resendSizeHint: Restoring guest size-hint for screen 0 to 800x600

Any idea what went wrong?

  • 1
    You have put your code into the second sector which is not loaded (isn't even copied into the image). Move the padding to the end. – Jester May 07 '23 at 12:28
  • @Jester You were right. I changed the code, went one step further, but this time VirtualBox crashes. I have updated the post. Thanks – Jerzy z Bialowiezy May 07 '23 at 13:55
  • As a general tip, Bochs has better features for real-mode debugging than VirtualBox or qemu. You might want to start developing there. I believe it will also let you give it a flat "floppy disk image" without having to make an ISO first. – Nate Eldredge May 07 '23 at 14:34
  • In short, you really want to get past the stage where you have to throw up your hands when it crashes, because that is going to happen a lot. You want to be able to single-step and identify the exact instruction that doesn't do what you are expecting, the contents of memory and registers, etc. – Nate Eldredge May 07 '23 at 14:37
  • "Load segment = 7c" looks very suspicious. BIOS bootsectors are loaded at linear address 7C00h, so a 'load segment' of 07C**0**h would make sense. – Sep Roland May 07 '23 at 14:41
  • @SepRoland Thanks for pointing this out. I corrected, but that did not help. – Jerzy z Bialowiezy May 07 '23 at 15:37
  • I see you have added 2 zeroes! A correct *segment* value would be 7C0. – Sep Roland May 07 '23 at 15:56
  • 1
    After the fix for the bug Sep Roland told you about, if it is still a problem - Maybe the problem is the way the ISO is being generated. Have you tried booting as a floppy disk image and see what happens? – Michael Petch May 08 '23 at 14:31

1 Answers1

3
[ORG 0x7c00]   
BITS 16

main:
          mov ax, 0x07C0                                  
          mov ds, ax         
          mov es, ax

Your setup for DS and ES does not match the ORG settting!

If you use [ORG 0x7c00], then you have to set DS=0 and ES=0.
Since you only use the BIOS function 13h that depends on ES:BP, setting up ES would be enough:

xor  ax, ax
mov  es, ax
Sep Roland
  • 33,889
  • 7
  • 43
  • 76