Text display oddities in VirtualBox and some real hardware

Question about which tools to use, bugs, the best way to implement a function, etc should go here. Don't forget to see if your question is answered in the wiki first! When in doubt post here.
Post Reply
User avatar
IanSeyler
Member
Member
Posts: 326
Joined: Mon Jul 28, 2008 9:46 am
Location: Ontario, Canada
Contact:

Text display oddities in VirtualBox and some real hardware

Post 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
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Text display oddities in VirtualBox and some real hardwa

Post 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.
User avatar
IanSeyler
Member
Member
Posts: 326
Joined: Mon Jul 28, 2008 9:46 am
Location: Ontario, Canada
Contact:

Re: Text display oddities in VirtualBox and some real hardwa

Post 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
BareMetal OS - http://www.returninfinity.com/
Mono-tasking 64-bit OS for x86-64 based computers, written entirely in Assembly
Gigasoft
Member
Member
Posts: 856
Joined: Sat Nov 21, 2009 5:11 pm

Re: Text display oddities in VirtualBox and some real hardwa

Post 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.
Post Reply