Bochs help

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
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

Bochs help

Post 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:

Code: Select all

B4 0E
B0 21
B3 CE
CD 10
Is it my problem or bochs'?
BTW this code came from http://joelgompert.com/OS/lesson2.htm
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: Bochs help

Post 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.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

Re: Bochs help

Post by kendfrey »

Is there a way to get color or not?
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: Bochs help

Post 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.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

Re: Bochs help

Post 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!
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: Bochs help

Post 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.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Bochs help

Post by egos »

kendfrey, maybe function 13h will help you.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: Bochs help

Post by Chandra »

egos wrote:kendfrey, maybe function 13h will help you.
You mean 10h?
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
kendfrey
Member
Member
Posts: 45
Joined: Mon Oct 17, 2011 7:44 am

Re: Bochs help

Post 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
User avatar
neon
Member
Member
Posts: 1567
Joined: Sun Feb 18, 2007 7:28 pm
Contact:

Re: Bochs help

Post 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.
OS Development Series | Wiki | os | ncc
char c[2]={"\x90\xC3"};int main(){void(*f)()=(void(__cdecl*)(void))(void*)&c;f();}
egos
Member
Member
Posts: 612
Joined: Fri Nov 16, 2007 1:59 pm

Re: Bochs help

Post 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.
If you have seen bad English in my words, tell me what's wrong, please.
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: Bochs help

Post 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.
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
User avatar
Chandra
Member
Member
Posts: 487
Joined: Sat Jul 17, 2010 12:45 am

Re: Bochs help

Post 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?
Programming is not about using a language to solve a problem, it's about using logic to find a solution !
Post Reply