Search code examples
bootloaderbiosvmware-workstation

VMWare Workstation's strange bootloader behaviour (failing to print a character)


.code16
.text
.org 0x0 

.global _start

_start:
  jmp _testing
  nop

_testing:
  mov $0x0E, %ah 
  mov the_byte, %al       #the line in question
  int $0x10

  jmp .

the_byte: .byte 0x41

.fill (510-(.-_start)), 1, 0
.word 0xAA55   

This simple 'bootloader', as it were, is supposed to print out A to the screen, but it fails to do so when I'm using VMWare Workstation 16 (unlike Bochs, which happily shows A on its screen). If I change the line in question to

mov $0x41, %al

I can see A on VMWare Workstation as well. Have you by any chance got any idea what can be causing such strange behaviour?

PS. It is indeed loaded into 0x7C00 with a separate linker file.


Solution

  • Apparently, mov the_byte, %al is assembled into something akin to mov %ds:0x7C0C, %al, hence DS had to be zeroed out (along with other segment pointers):

    cli
    mov  %cs, %ax # CS is set to 0x0
    mov  %ax, %es # ES = CS = 0x0           
    mov  %ax, %ds # DS = CS = 0x0            
    mov  %ax, %ss # SS = CS = 0x0
    sti