From: Jeff Weeks Newsgroups: comp.lang.asm.x86,comp.os.msdos.djgpp Subject: Intel opcodes: ModR/M and SIB bytes Date: Thu, 24 Jul 1997 21:47:24 -0400 Organization: Code X Software Lines: 41 Message-ID: <33D805AC.172F8780@execulink.com> NNTP-Posting-Host: ppp35.leo.execulink.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit CC: dj AT delorie DOT com To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Alright. I'm writting this message to two newsgroups and DJ Delorie, in the hopes that one of you might know the answer to this question regarding Intel opcode formatting. Here goes: I'm writting a little paper describing the intruction format of Intel CPU's (which I'll later use to write my own assembler) and I'm confused by the ModR/M and SIB bytes (the two optional bytes immediately following the opcode). I think I've got the SIB byte down: The first two bits are the scale (00 = 1, 01 = 2, 10 = 4, 11 = 8... is that correct?), the next three bits are the index register, and the next three bits are the base register. Is that all correct? Are there any catches there? Okay, now what about the ModR/M byte? That one really confuses me. I really don't know much about it at all. I don't understand the function of the first two bits. The next three bits, to my understanding hold either a register (the first operand?), or another three bits of the opcode, is that right? And the last three bits, to my understanding, hold either another register (the second operand?) or something else (what?)? Lastly, how do you know, for example, wether certain bits form a register, or their other purpose? Is that designated by each certain opcode? Thank you very much, Jeff Weeks PS to DJ: Sorry for writting to you directly. I just figured you'd be the best to ask regarding this. It's my last question for quite a while, I believe. -------------------------------------------- - Code X Software - Programming to a Higher Power email: mailto:pweeks AT execulink DOT com web: http://www.execulink.com/~pweeks/ --------------------------------------------