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.
USHORT, BOOL, GDT, TSS, and ISRs
Re: USHORT, BOOL, GDT, TSS, and ISRs
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
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 --
Re: USHORT, BOOL, GDT, TSS, and ISRs
Yes... .
Just use the term "unsigned short" or make a typedef
Just use the term "unsigned short" or make a typedef
Re: USHORT, BOOL, GDT, TSS, and ISRs
no. on 32bit architecture, a short is 16bits, an integer is 32bits.USHORT == unsigned short
Integer?
in real mode, integer is 16bits.
short is always 16bits on x86, long is always 32bits. char is always 8.
-- Stu --
Re: USHORT, BOOL, GDT, TSS, and ISRs
Well I used this and it worked fine:
#define USHORT unsigned short int
Thanks,
K.J.
#define USHORT unsigned short int
Thanks,
K.J.
Re: USHORT, BOOL, GDT, TSS, and ISRs
Code: Select all
#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 --
Re: USHORT, BOOL, GDT, TSS, and ISRs
#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.
#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.
Re: USHORT, BOOL, GDT, TSS, and ISRs
Oops...I meant that the #define code was equivalent to:
char *pszString1, pszString2;
char *pszString1, pszString2;
Re: USHORT, BOOL, GDT, TSS, and ISRs
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
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