I Need help on how to write the full opcode of the above x86 codes.
i saw like for sgdt it is 0F 01 /1. the problem is i dont know the full opcode will it be 0F01[01-this is what am not sure][then the 48 bits]
FASM cannot compile the code

I need help on get features function. es:di what exact memory will these point to?
Also i need help on mode 116h [1024x768] how do i switch the banks? and also whre do i get the feature that gives me the direct pointer to the bank switch/ window changing vesa code?
Which will i change 1st the bank or window? anyway what do the window and the banks actually refer? please send me a picture showing the bank and window in a screeen.

could you please explain to me what do the x86 registers refer to and how to change them incase of protected or real mode?

Recommended Answers

All 9 Replies

SGDT is 0F 01 /0.
SIDT is 0F 01 /1
LGDT is 0F 01 /2
LIDT is 0F 01 /3

The /0, etc. refers to the R/M field of the ModR/M byte of the opcode. So SGDT would be coded as 0F 01 00 followed by three or four bytes (depending on the operand-size attribute) containing the address of where to store (or load) the global (or interrupt) descriptor table. Likewise, LGDT would be coded as 0F 01 02, followed by an address.

You need to find yourself a good reference. Make sure to look up the ModR/M byte format and the operand-size attribute bytes. Also, these are protected-mode opcodes, so you'll have to code appropriately.

Good luck.

The LGDT is stil causing me problems, what hapens to m16&m32 how many bytes wil folow and how wil the bytes represent the memory ofset?

This is why you need to find a reference. There isn't any m16 or m32, only an m, which is stored in the three or four bytes that follow the opcode and ModR/M byte.

Since these are protected-mode ops, the operand-size and address-size bit is stored in the D flag of the executable segment descriptor.

So in memory, the SGDT code looks like 0F 01 00 lo md hi 00 (offset is "hi md lo" [your m32])
or 0F 01 00 lo ml mh hi (offset is "hi mh ml lo" [your m16])

These opcodes are really only useful for writing operating system software. What exactly are you trying to do?

I am trying to load lgdtr. I am initializing protected mode. So it is writen that the opcode's operand will be a word for the ptr limit and double word for ptr of base. Lets say my 48bits are at 07a00h, nw show me the opcode

I am not looking for sgdt, i just want lgdt and the intel manual i am using is unclear. The code was executed in real mode using 3bytes while my operand overide was 66 or should i include 67h too for addres overide?just explain to me what the operand means pertaining to addres, lets say the addres is 07a00h

Look, I can't give you any more information than I've got. Here's what the manual says:

The LGDT and LIDT instructions load a linear base address and limit value from a six-byte data operand in memory into the GDTR ar IDTR, respectively. If a 16-bit operand is used with LGDT or LIDT, the register is loaded with a 16-bit limit and a 24-bit base, and the high-order eight bits of the six-byte data operand are not used. If a 32-bit operand is used, a 16-bit limit and a 32-bit base is loaded; the high-order eight bits of the six-byte operand are used as high-order base address bits.

The SGDT and SIDT instructions always store into all 48 bits of the six-byte data operand. With the 80286, the upper eight bits are undefined after SGDT or SIDT is executed. With the 80386, the upper eight bits are written with the high-order eight address bits, for both a 16-bit operand and a 32-bit operand. If LGDT or LIDT is used with a 16-bit operand to load the register stored by SGDT or SIDT, the upper eight bits are stored as zeros.

LGDT and LIDT appear in operating system software; they are not used in application programs. They are the only instructions that directly load a linear address (i.e., not a segment relative address) in 80386 Protected Mode.

SGDT/SIDT copies the contents of the descriptor table register to the six bytes of memory indicated by the operand. The LIMIT field of the register is assigned to the first word at the effective address. If the operand-size attribute is 32-bits, the next three bytes are assigned the BASE field of the register, and the fourth byte is written with zero. The last byte is undefined. Otherwise, if the operand-size attribute is 16 bits, the next four bytes are assigned the 32-bit BASE field of the register.

SGDT and SIDT are used only in operating system software; they are not used in application programs.

This is all I know.

That is the exact notes i have, i jus have a problem with if an operand or a memory ofset folows or es:di or ds:si. Thats all, nothng else i have 3 intel refrence books but none explains. How do i use the 3bytes? And why does my computer reboot when my boot program sets bit 1 of cr0

No segment registers are involved. The m address following the opcode is a direct, linear address. (It has to be for the purpose to which these opcodes are designed.)

What's cr0?

Hey people i got it, its lgdt [ds: (ofset) ] thank u guys and God bless u. Praise be to God

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.