
determine what instruction is represented by the opcode so that the instruction can be issued to the correct execution unit and that the correct operation is performed. In addition, some instructions may have prefixes (such as LOCK in x86) or function codes (such as the funct field for some MIPS instructions) that alter their functionality. These arguments may refer to specific registers or memory addresses or can be immediate values to be used directly during execution. No, it's more like decoding MPEG data into raw video data - the raw MPEG data can't be painted on the screen directly, it has to be processed and "unpacked" to find out what it means exactly.ĭecode means to parse the instruction to determine its meaning.Ī typical instruction consists of an opcode and (usually) one or more arguments. In fact, I understand decoding here in similar way as what you decode a message given a key in the field of security, which is what confuses me a bit. I believe PDP assembly from the late 60's/early 70's isn't too far from this. The "RAM equivalent" of this would be 1 instruction per bit in an 8-bit (or other) byte, and if multiple bits were on, all instructions (and yes you would be limited to 8 of them) would "fire" at that step. The decode step would not be necessary if you had a machine that had 1 switch for each possible instruction. Similar to how ASCII/Unicode is a scheme that "stands for" numbers, letters, and terminal control codes. A scheme has to exist whereby X = whatever instruction + whatever addressing mode. Instructions + addressing modes consist of an opcode and any immediate data (operands) following the opcode.īecause we are using values in RAM to "stand for" instructions and addressing modes. Instructions and adressing modes are what is decoded. So 0x90 decodes as "exchange AX with AX", which doesn't do much, AKA No Operation NOP
'reg' of binary 000, means 'with register AX'. the 3 bits denoted 'reg' define what register to exchange with. Summary: it figures out the optional details of an instructionĠx90 ( 10010000 binary ) is usually considered a NOP, no operation, for the 8086 instruction set.īut there is a XCHG instruction, represented as binary 10010reg (reg=3 bits), (0x90 + reg) that is an 16 bit exchange register with AX instruction. Assembly instructions, besides an opcode, often have bit fields that indicate registers and addressing modes (absolute, relative, auto-increment and more).ĭecoding is the cycle that interprets the opcode and those other bitfields to determine what the instruction will operate on, or otherwise do.