Segment descriptor and endianness
Posted: Fri Oct 03, 2014 9:51 pm
Hi guys!
I'm trying to write functions that set up gdt in c.
My definition of segment descriptor is:
My problem is about the first uint16 field.
I know 80386 is little-endian. So when writing a 16-bit value to mem(let's say 0x1234), the actual data in ram would be
Suppose I have a limit of 0x123456, I assign 0x1234 to limit_low and if you look at the binary of bits 0-15 of segment descriptor, it should be
But intel seems to expect this:
I've seen fair amount of tutorials. Some of them do 0x12 0x34 and the others do 0x34 0x12.
So I'm confused here:
Should it be 0x12 0x34 or 0x34 0x12(little-endian form)?
Thanks!
I'm trying to write functions that set up gdt in c.
My definition of segment descriptor is:
Code: Select all
typedef struct
{
uint16 limit_low;
uint16 base_low;
uint8 base_middle;
uint8 access;
uint8 limit_mid_flag;
uint8 base_high;
} gdt_descriptor;
I know 80386 is little-endian. So when writing a 16-bit value to mem(let's say 0x1234), the actual data in ram would be
Code: Select all
Addr Data
0x0 0x34
0x1 0x12
Code: Select all
Bit Data
0-7 0x34
8-15 0x12.
Code: Select all
Bit Data
0-7 0x12
8-15 0x34.
So I'm confused here:
Should it be 0x12 0x34 or 0x34 0x12(little-endian form)?
Thanks!