Page 1 of 1

Weird? (VirtualPC)

Posted: Wed Nov 19, 2008 9:51 pm
by neon
Hey everyone,

I am kind of curious at what can cause this. I have the following code in my bootloader (for temporary debugging purposes):

Code: Select all

char* p = (char*)0x100000;

for (int i=0; i<30; i++)
	get_bios()->puts ("%c", p[i]);
If i<10 it works fine in Bochs and Virtual PC (It displays garbage as expected). if i<30 (in the above case) it works okay in Bochs, however VirtualPC stalls and beeps (A very long beep in fact). It continues soon after the beep.

However, if I have valid data there it works fine. Does anyone know why this can be? I never seen that happen before... :/

Its not a problem; its more of a curiosity question. Thanks for any input :)

Re: Weird? (VirtualPC)

Posted: Wed Nov 19, 2008 10:04 pm
by Brendan
Hi,

One of the ASCII characters is called "bell" (character 0x07). The when the BIOS "output a character" function sees this character it's meant to do a short beep on the PC speaker. If the BIOS outputs several beep characters they run together and sound like one long beep instead of many short beeps.

I'd assume that you're using the BIOS function, and there's several "bell" characters in the garbage you're displaying; and that either the garbage is different on Bochs or Bochs emulates a disconnected PC speaker.

Note: I honestly don't know if sound works in Bochs or not - I know it doesn't use the host PC speaker to emulate the guest PC speaker, but it might use the host sound card to emulate the guest PC speaker. My development machines/servers have always been "soundless" (no sound driver or speakers for my current machine and no sound card in the previous machine).


Cheers,

Brendan

Re: Weird? (VirtualPC)

Posted: Wed Nov 19, 2008 10:04 pm
by Zenith
Maybe there's a bunch of bell characters at that area in Virtual PC :D

Edit: Damn, I was beaten to it by Brendan. I thought phpBB3 warned if someone made a post before you submit yours?

Re: Weird? (VirtualPC)

Posted: Wed Nov 19, 2008 10:18 pm
by neon
Brendan wrote:One of the ASCII characters is called "bell" (character 0x07). The when the BIOS "output a character" function sees this character it's meant to do a short beep on the PC speaker.
That is what I was originally thinking, it just seemed kind of strange for it to beep for as long as it did. I suppose its possible though. After I used memset() to clear the 30 bytes at that location before the for loop executed (in the original post) it worked fine. I just think its strange for a long series of beep characters to be in array within an area of garbage memory (Which is why I posted out of interest).

Thanks for your answers! :D

Re: Weird? (VirtualPC)

Posted: Wed Nov 19, 2008 10:47 pm
by Brendan
Hi,
neon wrote:I just think its strange for a long series of beep characters to be in array within an area of garbage memory (Which is why I posted out of interest).
The bell characters don't need to be in series - if you've got a bell character, then 20 other characters, then another bell character, then the computer will display those other character so fast that you won't be able to notice the extremely tiny gap between the bell characters.

Statistically, the chance of getting 1 bell character in 30 random bytes is 30/256 (11.7% chance), and the chance of getting 2 bell characters in 30 random bytes is about 1.37%. Garbage memory isn't truly random though. For example, maybe the area of memory was previously used as a buffer for text mode video data, and every second byte is 0x07 (the attribute bytes were "light grey foreground with black background").

Lastly, different virtual machines handle time differently. For example, one "guest second" might actually be 4 "host seconds", so maybe there's only one bell character...


Cheers,

Brendan

Re: Weird? (VirtualPC)

Posted: Wed Nov 19, 2008 11:10 pm
by Love4Boobies
Actually there's no such thing as "random" at all. There's pseudo-random, though (off-topic).

Anyway, you can check by putting bell characters there yourself and seeing what Virtual PC has to say about it.