120 likes | 260 Views
Chapter 7:. 22342 – Computer Organization & Assembly Language. Integer Arithmetic. Shift & Rotate Instructions. SHL (Shift Left) SHL reg , imm8 SHL mem , imm8 SHL reg , CL SHL mem , CL In bit = 0, Out bit goes to CF SHR (Shift Right) ROL (Rotate Left) ROR (Rotate Right).
E N D
Chapter 7: 22342 – Computer Organization & Assembly Language Integer Arithmetic
Shift & Rotate Instructions • SHL (Shift Left) • SHL reg, imm8 • SHLmem, imm8 • SHL reg, CL • SHL mem, CL In bit = 0, Out bit goes to CF • SHR (Shift Right) • ROL (Rotate Left) • ROR (Rotate Right)
Arithmetic Shift Instructions • SAL (Shift Arithmetic Left) • Same as SHL • SAR (Shift Arithmetic Right) • SAR reg, imm8 • SARmem, imm8 • SARreg, CL • SAR mem, CL In bit = SF, Out bit goes to CF
Sign Extension Instructions • Convert Byte to Word • CBW • Convert Word to Double • CWD
Addition & Subtraction • ADD Instruction • ADD reg, reg • ADD reg, mem • ADD reg, imm • ADD mem, reg • ADD mem, imm • SUB Instruction • INC Instruction • INC reg • INC mem • DEC Instruction
Multiply Instruction • MUL (Unsigned Multiply) • IMUL (Signed Multiply) • MUL reg or IMUL reg • MUL mem or IMUL mem • 8-bit Multiply • 16-bit Multiply AL × 8-bit AX AX × 16-bit DX AX
Multiply Instruction Program File Example: .Data Var1 DB 2 Var2 DB 3 Var3 DW 3 Var4 DW 4 .Code END
Multiply Instruction Program File Example: .Data Var1 DB 2 Var2 DB - 3 Var3 DW - 3 Var4 DW 4 .Code END
Divide Instruction • DIV (Unsigned Divide) • IDIV (Signed Divide) • DIV reg or IDIV reg • DIV mem or IDIV mem • 8-bit Divide • 16-bit Divide AL 8-bit AX AH AX DX AX 16-bit DX
Divide Instruction Program File Example: .Data Var1 DB 20 Var2 DB 3 Var3 DW 45 Var4 DW 4 .Code END
Divide Instruction Program File Example: .Data Var1 DB - 48 Var2 DB 5 Var3 DW - 1002 Var4 DW 249 .Code END