Instruction and Instruction Set 1. • An instruction is the basic command, in other words it is the most rudimentary programming command. • Instruction set refers to the set of all the instructions that can be executed by a microprocessor. • Instruction = Op-Code+Operands • Op-Code identifies the action to be taken and operands specify source and destination. Instruction and Instruction Set 2. • Op-Codes are also referred to as mnemonic, written in abbreviated form for ex: move is only mov as an instruction. • Instructions can use CPU register (including accumulator), memory locations or I/O ports as per need. • Simple instruction format : op-code destination, source mov ax, bx (comma separated.) Basic Instruction Know How? • When two operands are required for an instruction they are separated by comma. For example: REG, memory • When there are two operands, both operands must have the same size (except shift and rotate instructions). For example: AL, DL-- DX, AX • Some instructions allow several operand combinations. For example: memory, immediate -- REG, immediate memory, REG -- REG, REG Categorization of Instructions of 186 Mp. Examples of Instructions 1. • Data Transfer Instructions • General Purpose • MOV ax,bx ;will move contents of bx to ax • Conversion • CBW ; will convert 8 bits to word 16 bits ie if ;al<80h, then ah <- 00, if al>7f, then ah<-ffh • Arithmetic Instructions • Addition • ADD dx,ch; add dx and ch and put result in dx • Division • DIV bl; divide ah by bl and put result in ax Examples of Instructions 2. • String • LODSB; accesses data segment, al<- ;ds: [si] • CMPSB ; compare string byte pointer by ;ds:[si] and es:[si] • Logical • AND cx,dx ; perform bit by bit and ;between cx and dx, result in ;cx. • TEST cx,dx ;same as AND but will only ;update flags not cx’s contents. Examples of Instructions 3. • Shift And Rotate • SHL ax,1;shift word operand 1 to left • ROR membds,cl ; rotate data right cl ;times. • Program Control • Conditional Transfer • JO ;jump if zero flag is on • REPNE scasb;repeat if zf=0 cx is not equal to 0 • Iteration • LOOP mems ;cx<-cx-1, if cx is not equal to 0, ;the ip<-mems (short range) Examples of Instructions 4 & 186 Additions • Processor Control • NOP ;uses 3 clock cycles & increments ip ;to point to next instruction • Instruction added in 186 processor • ENTER Make stack frame for procedure parameters • LEAVE High-level procedure exit • PUSHA Push all general registers • POPAPop all general registers • BOUND Check array index against bounds • IMUL Signed (integer) multiply • INS Input from port to string • OUTS Output string to port