Presentation is loading. Please wait.

Presentation is loading. Please wait.

Intel’s 8086 instruction-set

Similar presentations


Presentation on theme: "Intel’s 8086 instruction-set"— Presentation transcript:

1 Intel’s 8086 instruction-set
A look at the main categories of processor instructions for the earliest Intel x86 CPU

2 Data-Transfer These instructions simply copy some data from one place in the system to another From one register to another register From a memory location to a register From a register to a memory location From within an instruction to a register From within an instruction to a memory cell

3 ‘mov’ It’s the most frequently-used instruction immediate data
general register general register or memory segment register

4 Some other data-transfers
Exchange (‘xchg’) Push/Pop Pushf/Popf In/Out Load pointer (‘lds’, ‘les’, ‘lfs’, lgs’, ‘lss’) Note: A distinctive feature data-transfers is that FLAGS are unmodified (except ‘popf’)

5 Arithmetic Instructions
Addition: ‘add’ and ‘adc’ Subtraction: ‘sub’ and ‘sbb’ Multiplication: ‘mul’ and ‘imul’ Division: ‘div’ and ‘idiv’ Increment/Decrement: ‘inc’ and ‘dec’ Comparison/Negation: ‘cmp’ and ‘neg’ All these instructions do modify FLAGS

6 Boolean Logic Instructions
Bitwise AND: ‘and’ Bitwise OR: ‘or’ Bitwise XOR: ‘xor’ Bitwise TEST: ‘test’ Bitwise complement: ‘not’ These instructions also modify FLAGS

7 Shift/Rotate Instructions
Left-shifts: ‘shl’ and ‘sal’ Right-shifts: ‘shr’ and ‘sar’ Left-rotations: ‘rol’ and ‘rcl’ Right-rotations: ‘ror’ and ‘rcr’ These instructions affect the Carry-Flag

8 Control Transfers These instructions modify register RIP so as to alter the normal fetch-execute cycle Unconditional Jumps: ‘jmp’ and ‘ljmp’ Subroutine Calls: ‘call’ and ‘lcall’ Subroutine Returns: ‘ret’ and ‘lret’ Conditional Jumps: ‘jz’, ‘jnz’, ‘jc’, ‘jnc’, etc These transfers do not modify the FLAGS

9 String Manipulations This unusual group of complex instructions is for efficient word-processing operations Move string: ‘movs’ Compare string: ‘cmps’ Scan string: ‘scas’ Store string: ‘stos’ Load string: ‘lods’ Repeat prefixes: ‘rep’, ‘repe’ and ‘repne’

10 Processor Control This group of instructions is for specialized systems programming situations Halt the fetch-ececute cycle: ‘hlt’ Wait for coprocessor to finish: ‘wait’ Lock the system bus temporarily: ‘lock’ Adjust the Direction Flag: ‘cld’ or ‘std’ Adjust the Interrupt Flag: ‘cli’ or ‘sti’ Adjust the Carry Flag: ‘cmc’, ‘clc’ or stc’

11 Special-purpose instruction
initializations the loop body This two-step construct occurs so often within ordinary programs that a special instruction is available to do both in a single instruction decrement RCX RCX == 0? no yes

12 Stack operation: ‘push’
register data 64-bits 64-bits data data data data data data SS:RSP unused data SS:RSP unused unused unused unused before ‘push’’ after ‘push’ The ‘push’ instruction, applied to a register, performs a two-step operation: first, the value in the stack-pointer register is decreased by 8, and then the value in the register operand is copied into the stack-location at SS:RSP

13 Stack operation: ‘pop’
register 64-bits 64-bits data data data data data data SS:RSP data unused SS:RSP unused unused unused unused before ‘pop’’ after ‘pop’ The ‘pop’ instruction, applied to a register, performs a two-step operation: first, the value in the stack-location at SS:RSP is copied into that register, and afterward the value in the stack-pointer register is increased by 8.

14 An application We can apply these stack-operations to a string of characters in a memory-buffer, so as to reverse the order of those characters stack A B C D RSP buffer buffer A B C D D C B A pop pop pop pop push push push push

15 ‘reverse.s’ We’ve constructed a demo-program that reverses the order of characters which a user types in It uses the ‘push’ and ‘pop’ operations, as well as the special x86 ‘loop’ instruction It also employs the ‘read’ system-call to get a string of characters typed by a user

16 The program’s flow Prompt the user for input INPUT
Accept the user’s response Loop to ‘push’ each buffer character onto stack PROCESS Loop to ‘pop’ each character to output buffer Show rearranged characters in output buffer OUTPUT

17 Loops are ‘consecutive’

18 Loops are ‘nested’

19 In-class exercise Can you modify the ‘reverse.s’ program so all words remain in the same order, but the order of the letters within each word do get reversed? HINT: You will need a loop-within-a-loop This is our moment, this is our time. INPUT sihT si rou themom, siht si rou emit. OUTPUT


Download ppt "Intel’s 8086 instruction-set"

Similar presentations


Ads by Google