ok, the d/b bit of a GDT entry controls whether the code segment is a 16 or 32 bit code segment right? well what does the d/b bit do for a read/write data segment? i am setting up a data segment and do not know what to set this bit to.
thanks
d/b bit of GDT entry
RE:d/b bit of GDT entry
I can't tell you want it means for a data descriptor. But i it should be set.
RE:d/b bit of GDT entry
The d/b bit does the same thing for the data segment as for code segment:
If you would read who asm is encoded in to bytes, then you will notice that there is such thin as a default arg size, which means if you have a 16-bit data seg, then your default args are ax,bx,... and al,ah,... . To use a eax in 16-bit data code, you would need to put a prefix overide(1 byte). If you are in 32-bit data seg, then the same insruction(in bytes) will mean eax,ebx,... and al,ah,... .
So thats way you need to tell the compiler the data seg you are using.
If you wrote :
mov ax,bx in 16 bit, then running this code on a 32-bit data seg will mean mox eax,ebx and vice-versa.
Anton
If you would read who asm is encoded in to bytes, then you will notice that there is such thin as a default arg size, which means if you have a 16-bit data seg, then your default args are ax,bx,... and al,ah,... . To use a eax in 16-bit data code, you would need to put a prefix overide(1 byte). If you are in 32-bit data seg, then the same insruction(in bytes) will mean eax,ebx,... and al,ah,... .
So thats way you need to tell the compiler the data seg you are using.
If you wrote :
mov ax,bx in 16 bit, then running this code on a 32-bit data seg will mean mox eax,ebx and vice-versa.
Anton
RE:d/b bit of GDT entry
OK, can you answer this than? if i set up a gdt entry to a read/write data segment and load the ds with that selector then execute a
mov dword [ds:00], 35
or
mov al, [ds:5] statement, will a different d/b bit setting in the gdt entry affect what happens when statements like this are executed? i am only using that segment for data, not code, so does it affect how i read/write stuff to the segment?
thanks
mov dword [ds:00], 35
or
mov al, [ds:5] statement, will a different d/b bit setting in the gdt entry affect what happens when statements like this are executed? i am only using that segment for data, not code, so does it affect how i read/write stuff to the segment?
thanks
RE:d/b bit of GDT entry
CS -> descriptor with d/b=1 means USE32/BITS32 code segment
CS -> descriptor with d/b=0 means USE16/BITS16 code segment
SS -> descriptor with d/b=1 means stack is 32 bits wide
SS -> descriptor with d/b=0 means stack is 16 bits wide
I don't think the d/b value matters for the descriptor referenced by DS.
To be on the safe side, just set d/b=1 for all the 32-bit descriptors, if you are making a 32-bit OS.
CS -> descriptor with d/b=0 means USE16/BITS16 code segment
SS -> descriptor with d/b=1 means stack is 32 bits wide
SS -> descriptor with d/b=0 means stack is 16 bits wide
I don't think the d/b value matters for the descriptor referenced by DS.
To be on the safe side, just set d/b=1 for all the 32-bit descriptors, if you are making a 32-bit OS.
RE:d/b bit of GDT entry
ok, that makes sense. so when you say the stack is 32 bits wide, what exactly does that mean? can i only push/pop eax, etc... (32 bit values) or can i still push/pop ax, bx... (16 bit values) ??? or does that refer to something besides pushing/popping values?
thanks in advance
thanks in advance