Mail Archives: djgpp/1998/01/07/05:30:31
Anthony.Appleyard wrote:
> and its relatives similarly. Which PC instructions can I prefix `byte 0x65'
> to to make them operate on conventional memory? If e.g. I wanted a quick way
> to compile `x &= y', where x is in conventional memory, would this work?:-
You can prefix any instruction with ".byte 0x65", even though, some
instructions do not benefit from it. In general you can (should) only
use it before instructions that do explicit memory addressing (excluding
the implicit push/pop argument) with %ds or %ss as default segment
register.
".byte 0x65" is a way in gnu assembler to let the CPU know it should use
the %gs register to reference the offset against. A full table (by
heart)
.byte 0x26 ES
.byte 0x2e CS
.byte 0x36 SS
.byte 0x3e DS
.byte 0x64 FS
.byte 0x65 GS
Know what you do when using this table! You can't use any segment
register in general just for any purpose. Wrong use can and will crash
your compu.
> extern __inline__ void farpokeandb(unsigned short selector,
> unsigned long offset, unsigned char value) {
> __asm__ __volatile__ ("movw %w0,%%gs\n" " .byte 0x65 \n" " andb %b1,(%k2)"
> : : "g" (selector), "qi" (value), "r" (offset)); }
Looks fine to me (after a quick look).
BTW "x&=y" will work faster (and allows for optimization).
--
\ Vik /-_-_-_-_-_-_/
\___/ Heyndrickx /
\ /-_-_-_-_-_-_/
- Raw text -