OSDev.org

The Place to Start for Operating System Developers
It is currently Sat Apr 27, 2024 4:46 pm

All times are UTC - 6 hours




Post new topic Reply to topic  [ 10 posts ] 
Author Message
 Post subject: USHORT, BOOL, GDT, TSS, and ISRs
PostPosted: Fri Feb 08, 2002 11:06 pm 
I was trying out a part of code from df's OS Dev FAQ and couldn't get this to work:

     /* void update_cursor(int row, int col)
      * by Dark Fiber
      */
     void update_cursor(int row, int col)
     {
           USHORT      position=(row*80) + col;

           // cursor LOW port to vga INDEX register
           outb(0x3D4, 0x0F);
           outb(0x3D5, (UCHAR)(position&0xFF));
           // cursor HIGH port to vga INDEX register
           outb(0x3D4, 0x0E);
           outb(0x3D5, (UCHAR)((position>>8)&0xFF));
     };


The problem is that DJGPP doesn't know what USHORT is and I don't either(though I think that it's short something). I also can't seem to be able to have a function in DJGPP return a BOOL:

BOOL test_it();

DJGPP says that it doesn't know what BOOL is.

My last question is, does anyone know where I can find a good tutorial or doc that explains GDT, TSS, and how to setup ISRs?

Thanks in advance,
K.J.


Top
  
 
 Post subject: Re: USHORT, BOOL, GDT, TSS, and ISRs
PostPosted: Fri Feb 08, 2002 11:13 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 1076
UCHAR == unsigned char
USHORT == unsigned short
ULONG == unsigned long
UINT32 == unsigned long
UINT16 == unsigned short
UINT8 == unsigend char

SCHAR == signed char
SSHORT == signed short
SLONG == signed long
SINT32 == signed long
SINT16 == signed short
SINT8 == sigend char

_________________
-- Stu --


Top
 Profile  
 
 Post subject: Re: USHORT, BOOL, GDT, TSS, and ISRs
PostPosted: Fri Feb 08, 2002 11:16 pm 
USHORT == unsigned short

Integer?

K.J.


Top
  
 
 Post subject: Re: USHORT, BOOL, GDT, TSS, and ISRs
PostPosted: Sat Feb 09, 2002 12:29 am 
Yes... .
Just use the term "unsigned short" or make a typedef


Top
  
 
 Post subject: Re: USHORT, BOOL, GDT, TSS, and ISRs
PostPosted: Sat Feb 09, 2002 3:14 am 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 1076
Quote:
USHORT == unsigned short

Integer?


no. on 32bit architecture, a short is 16bits, an integer is 32bits.
in real mode, integer is 16bits.

short is always 16bits on x86, long is always 32bits. char is always 8.

_________________
-- Stu --


Top
 Profile  
 
 Post subject: Re: USHORT, BOOL, GDT, TSS, and ISRs
PostPosted: Sat Feb 09, 2002 9:30 pm 
Well I used this and it worked fine:

#define USHORT unsigned short int

Thanks,
K.J.


Top
  
 
 Post subject: Re: USHORT, BOOL, GDT, TSS, and ISRs
PostPosted: Sat Feb 09, 2002 11:18 pm 
Offline
Member
Member
User avatar

Joined: Fri Oct 22, 2004 11:00 pm
Posts: 1076
Code:
#ifndef __typedef_int
#define __typedef_int
typedef signed char SCHAR;
typedef unsigned char UCHAR;
typedef signed long SLONG;
typedef unsigned long ULONG;
typedef signed short SSHORT;
typedef unsigned short USHORT;
#endif

_________________
-- Stu --


Top
 Profile  
 
 Post subject: Re: USHORT, BOOL, GDT, TSS, and ISRs
PostPosted: Mon Feb 11, 2002 7:46 am 
#define's are ok, but for defining a new type, it's generally better to use typedef, and here's why: take the following code

#define PSTR char*

PSTR pszString1, pszString2;

this creates ONE char* variable called pszString1 and one CHAR (not char*) variable called pszString2 -- this is because #define essentially does a text replacement, making the above code equivalent to:

char *pszString1, *pszString2;

However, if you use a typedef:

typedef char* PSTR;

PSTR pszString1, pszString2;

this creates TWO char* variables, because PSTR becomes a full data type.

For something like unsigned short it's fine to #define, but if you do something like that with pointers it can come back and get you.


Top
  
 
 Post subject: Re: USHORT, BOOL, GDT, TSS, and ISRs
PostPosted: Mon Feb 11, 2002 7:48 am 
Oops...I meant that the #define code was equivalent to:

char *pszString1, pszString2;


Top
  
 
 Post subject: Re: USHORT, BOOL, GDT, TSS, and ISRs
PostPosted: Mon Feb 11, 2002 7:54 am 
by the way, BOOL is another thing that you'll have to typedef (or you can change it to bool if DJGPP supports ANSI C++).

BOOL can be defined as pretty much any integer type. When I define it, I usually just make it an int, though a shorter type like char would probably work fine.

typedef int BOOL;
#define TRUE 1
#define FALSE 0


Top
  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 10 posts ] 

All times are UTC - 6 hours


Who is online

Users browsing this forum: Bing [Bot], Majestic-12 [Bot] and 17 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group