Page 1 of 1

Text display oddities in VirtualBox and some real hardware

Posted: Fri Jul 09, 2010 10:05 am
by IanSeyler
I have an odd problem with trying to update the text display in 64-bit mode. Writing 64-bit values to VGA memory in Oracle VirtualBox and at least one physical machine (An Intel Atom-330 based motherboard) doesn't display what I am expecting. The screenshots below are from VirtualBox.

Good:

Code: Select all

    mov rax, 0x8720872087208720	; 0x87 for dark grey background/white foreground, 0x20 for space (black) character
    mov rdi, 0x00000000000B8000
    mov rcx, 40
    rep stosd
    mov rdi, 0x00000000000B8000
    mov al, '['
    stosb
    add rdi, 1
    mov eax, 0x8F708F63		; 'cp'
    stosd
    mov eax, 0x8F3A8F75		; 'u:'
    stosd
    mov rdi, 0x00000000000B8080
    mov eax, 0x87618742        ; 'Ba'
    stosd
    mov eax, 0x87658772        ; 're'
    stosd
    mov eax, 0x8765874D        ; 'Me'
    stosd
    mov eax, 0x87618774        ; 'ta'
    stosd
    mov eax, 0x8720876C        ; 'l '
    stosd
    mov eax, 0x87308776        ; 'v0'
    stosd
    mov eax, 0x8734872E        ; '.4'
    stosd
    mov eax, 0x8738872E        ; '.8'
    stosd
Image

Bad:

Code: Select all

    mov rax, 0x8720872087208720    ; 0x87 for dark grey background/white foreground, 0x20 for space (black) character
    mov rdi, 0x00000000000B8000
    mov rcx, 20
    rep stosq
    mov rdi, 0x00000000000B8000
    mov al, '['
    stosb
    add rdi, 1
    mov rax, 0x8F3A8F758F708F63	; 'cpu:'
    stosq
    mov rdi, 0x00000000000B8080
    mov rax, 0x8765877287618742    ; 'Bare'
    stosq
    mov rax, 0x876187748765874D    ; 'Meta'
    stosq
    mov rax, 0x873087768720876C    ; 'l v0'
    stosq
    mov rax, 0x8738872E8734872E    ; '.4.8'
    stosq
Image

Any ideas on why this could be occurring? I thought something was trashing the high 32-bits of the RAX register but I have verified it contains the right data. The physical Atom-330 exhibits similar results to VirtualBox. QEMU, Bochs, and a Pentium-D do not have the problem.

Thanks

Re: Text display oddities in VirtualBox and some real hardwa

Posted: Fri Jul 09, 2010 12:22 pm
by Gigasoft
64-bit access to display memory is not part of the VGA specification, so you can't expect it to work with all cards.

Re: Text display oddities in VirtualBox and some real hardwa

Posted: Fri Jul 09, 2010 8:27 pm
by IanSeyler
Thanks for the tip. I'll stick to working with 16-bit values (character + attribute) for the screen related functions.

As for the Atom-330 PC.. It has built-in video that uses shared memory. I plugged in an old PCI video card in and the display works normally.

With a working display I could finally see the execution time for a test application.

Intel D945GCLF2 board - Atom 330 CPU (Dual Core 1.6GHz), 2GiB RAM

Hyper-threading off : 269 seconds
Hyper-threading on : 223 seconds

46 seconds less for the total test app runtime (~20% faster). Not too bad.

-Ian

Re: Text display oddities in VirtualBox and some real hardwa

Posted: Sat Jul 10, 2010 7:06 am
by Gigasoft
I think 32-bit access should always work, though. In the case of ISA VGA cards, the 32-bit accesses were split into two 16-bit ones, and therefore newer VGA-compatibles have to implement 32-bit accesses too, to avoid breaking old programs.