VOGONS


First post, by superfury

User metadata
Rank l33t++
Rank
l33t++

I currently have the LIDT/LGDT implemented as two word reads at location X+0(word), X+2(word) and X+4(byte). The SIDT/SGDT saves using two word and two byte writes(X+0(word), X+2(word), X+3(byte), X+4(byte)). Is this correct?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 2 of 4, by superfury

User metadata
Rank l33t++
Rank
l33t++

Just for correctness, is it actually three word reads or two word reads and two byte reads(high bytes) read from memory? What about protection? If only 5 bytes(two words and one byte) can be read from the address(due to limit or paging), will LIDT/LGDT fail? (16-bit instruction used on the 80286 btw, not the 32-bit 386+ instruction(so using 16-bit operand size))

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io

Reply 3 of 4, by vladstamate

User metadata
Rank Oldbie
Rank
Oldbie
superfury wrote:

Just for correctness, is it actually three word reads or two word reads and two byte reads(high bytes) read from memory? What about protection? If only 5 bytes(two words and one byte) can be read from the address(due to limit or paging), will LIDT/LGDT fail? (16-bit instruction used on the 80286 btw, not the 32-bit 386+ instruction(so using 16-bit operand size))

I do not know for sure but my educated guess would be that on 286 there are 3 WORD reads and on the 386 (where the IDT/GDT/LDT are 64bit) 2 DWORD reads (which can become 4 WORD reads on the SX version). I do not think there are any byte reads.

YouTube channel: https://www.youtube.com/channel/UC7HbC_nq8t1S9l7qGYL0mTA
Collection: http://www.digiloguemuseum.com/index.html
Emulator: https://sites.google.com/site/capex86/
Raytracer: https://sites.google.com/site/opaqueraytracer/

Reply 4 of 4, by superfury

User metadata
Rank l33t++
Rank
l33t++

I've adjusted the 80286 LIDT/LGDT and SIDT/SGDT to load the high 16-bits(of the 32-bits(actually only 24-bits used during loading by masking off the high 8 bits)) using a 16-bit access instead of 8-bit access.

So:
LGDT/LIDT: Load 16-bits from memory(Limit), Load 16-bits from memory+2(Base low), Load 16-bits from memory+4(Base high, high 8 bits are discarded on 16-bit LGDT/LIDT load).
SGDT/SIDT: Save 16-bits to memory(Limit), Save 16-bits to memory+2(Base low), Save 16-bits to memory+4(Base high).

Is that correct?

Author of the UniPCemu emulator.
UniPCemu Git repository
UniPCemu for Android, Windows, PSP, Vita and Switch on itch.io