From: Vik Heyndrickx Newsgroups: comp.os.msdos.djgpp Subject: Re: Operations on conventional memory Date: Wed, 07 Jan 1998 11:01:40 +0100 Organization: University of Ghent, Belgium Lines: 37 Message-ID: <34B35284.38E1@rug.ac.be> References: <1B6D42C6A39 AT fs2 DOT mt DOT umist DOT ac DOT uk> NNTP-Posting-Host: eduserv1.rug.ac.be Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk 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 / \ /-_-_-_-_-_-_/