Page 1 of 1
Bochs help
Posted: Mon Oct 17, 2011 7:56 am
by kendfrey
I am using bochs for testing my OS work, to keep my PC safe. I am having an issue with the bochs BIOS. I am trying to set the color of a character when I display it with a BIOS interrupt. It always shows as the default light grey on black. My code:
Code: Select all
mov ah, 0E
mov al, 21 ; All numbers here in hex
mov bl, CE ; The color code
int 10
Machine code:
Is it my problem or bochs'?
BTW this code came from
http://joelgompert.com/OS/lesson2.htm
Re: Bochs help
Posted: Mon Oct 17, 2011 8:27 am
by Chandra
Bochs doesn't support color attributes under text mode. That's not a big issue from my point of view. I'm not quite sure about the newer releases, you may want to check it to be sure.
Re: Bochs help
Posted: Mon Oct 17, 2011 8:29 am
by kendfrey
Is there a way to get color or not?
Re: Bochs help
Posted: Mon Oct 17, 2011 8:31 am
by Chandra
kendfrey wrote:Is there a way to get color or not?
Try the latest version of Bochs. If it still doesn't help, there are other emulators that do support color attributes. IIRC, Microsoft Virtual PC does.
Re: Bochs help
Posted: Mon Oct 17, 2011 8:43 am
by kendfrey
I doubt there will be a newer version, since I downloaded it last week. If I feel a dire need for color, I will look into another emulator. Otherwise, bochs seems to be working great. Thanks for your help!
Re: Bochs help
Posted: Mon Oct 17, 2011 8:53 am
by Chandra
kendfrey wrote:I doubt there will be a newer version, since I downloaded it last week. If I feel a dire need for color, I will look into another emulator. Otherwise, bochs seems to be working great.
It really does work great. You can still try other emulators to see how well your code runs under them.
Re: Bochs help
Posted: Mon Oct 17, 2011 9:11 am
by egos
kendfrey, maybe function 13h will help you.
Re: Bochs help
Posted: Mon Oct 17, 2011 9:23 am
by Chandra
egos wrote:kendfrey, maybe function 13h will help you.
You mean 10h?
Re: Bochs help
Posted: Mon Oct 17, 2011 10:06 am
by kendfrey
Writing directly to video memory works for color. I got both background and foreground colors. I couldn't get 'bright' background colors, because that bit makes the character blink.
Code: Select all
mov ax, 0b800h ; video segment
mov ds, ax ; does not work with immediate operand
mov ax, 0721h ; 07 = default color, 21 = '!'
mov bx, 0h ; address into video segment
mov ds:[bx], ax ; WRITE CHARACTER!!! :D
Re: Bochs help
Posted: Mon Oct 17, 2011 11:18 am
by neon
Bochs doesn't support color attributes under text mode.
Incorrect. The interrupt he is using is wrong -- its not for colored text output. The color attribute in that interrupt service is for graphics modes only. Try INT 0x10 function 9 - it works in Bochs.
Re: Bochs help
Posted: Mon Oct 17, 2011 11:32 am
by egos
Chandra wrote:You mean 10h?
No, I meant 13h.
kendfrey wrote:Writing directly to video memory works for color. I got both background and foreground colors. I couldn't get 'bright' background colors, because that bit makes the character blink.
It's normal behaviour. You can try to change this directly through "attribute controller" or you can use function 10h, subfunction 3.
Re: Bochs help
Posted: Mon Oct 17, 2011 8:33 pm
by Chandra
neon wrote:Bochs doesn't support color attributes under text mode.
Incorrect. The interrupt he is using is wrong -- its not for colored text output. The color attribute in that interrupt service is for graphics modes only. Try INT 0x10 function 9 - it works in Bochs.
This document claims that the color attributes doesn't work under Bochs. It features the example code of
Teletype Output, so any statement it makes about text color must be wrong. You see it's not a surprise to find broken tutorials over the net.
Anyway, thanks for the correction.
Re: Bochs help
Posted: Tue Oct 18, 2011 3:02 am
by Chandra
berkus wrote:Chandra wrote:This document claims that the color attributes doesn't work under Bochs.
This document is for bochs 1.4.1 from 2002.
That's why I made this statement, being not pretty sure of the reality:
Chandra wrote:I'm not quite sure about the newer releases, you may want to check it to be sure.
Besides, I've been corrected, haven't I?