Presentation is loading. Please wait.

Presentation is loading. Please wait.

NEG Instruction Change operand content into two’s complement (negative value) and stored back into its operand mov bl,00000001b neg bl; bl = 11111111 mov.

Similar presentations


Presentation on theme: "NEG Instruction Change operand content into two’s complement (negative value) and stored back into its operand mov bl,00000001b neg bl; bl = 11111111 mov."— Presentation transcript:

1 NEG Instruction Change operand content into two’s complement (negative value) and stored back into its operand mov bl,00000001b neg bl; bl = 11111111 mov ah,11001101b neg ah; ah = 00110011 mov al,-128 neg al ; al = 80h, OF=1

2 MUL and IMUL Instruction Multiplication operation to multiply two numbers Format : MUL Operand IMUL Operand where operand might be general register or memory MUL : for unsigned multiplication operation IMUL : for signed multiplication operation

3 MUL/IMUL result will be stored in : AX if byte type source DX:AX if word type source EDX:EAX if dword type source

4 DIV and IDIV Instruction Two division instruction: DIV operand : unsigned number IDIV operand: signed number Operand must be register or memory

5 Example DIV and IDIV Instruction DX = 0000h, AX = 0005h, BX = FFFEh: InstructionQuot.Rem.AXDX divbx0500000005 idivbx-21FFFE0001 DX = FFFFh, AX = FFFBh, BX = 0002h: InstructionQuot.Rem.AXDX idivbx-2-1FFFEFFFF divbxDivide Overflow

6 Control bit instruction Logic instruction Shift instruction Rotate instruction

7 Logik instruction Table 1. Boolean Instructions

8 AND Operation Truth table which shows operation result of AND 10 110 000 bit-1 bit-2 op-1:1 1 0 1 0 0 1 1 op-2:0 1 0 0 1 1 0 1 result:0 1 0 0 0 0 0 1

9 Instruction Example and ax,bx and var1,edx and bl,var2 and dx,02FAh and al,00001111b targetsource

10 OR Instruction Truth table which show OR operation result 10 111 010 bit-1 bit-2 op-1:1 1 0 1 0 0 1 1 op-2:0 1 0 0 1 1 0 1 result:1 1 0 1 1 1 1 1

11 Instruction example or ax,bx or var1,edx or bl,var2 or dx,02FAh or al,00001111b targetsource

12 XOR Instruction Truth table shows XOR operation result 10 101 010 bit-1 bit-2 op-1:1 1 0 1 0 0 1 1 op-2:0 1 0 0 1 1 0 1 result:1 0 0 1 1 1 1 0

13 Instruction example mov al,10110011b xor al,11111111b ; AL = 01001100 XORing any bit with 0 leaves the bit unchanged: mov al,10110011b xor al,00000000b ; AL = 10110011

14 Instruction example mov al,10110011b xor al,10101100b ; AL = 00011111 xor al,10101100b ; AL = 10110011 same

15 NOT instruction Execute NOT operation at each bit at operand mov bh,11001101b not bh; bh = 00110010

16 Shift instruction To shift one bit to left SHL O1, O2 –Each bit is shifted one place to the left –Right most will be filled with 0 –Bit output from left most is inserted to carry flag, CF (original CF content will disappear) –Example: mov bl,80h ; BX = 0080h shl bl,1 ; BX = 0000h, CF=1

17 Shift bit right To shift right, with method: SHR O1, O2 O1= first operand (general register or memory) O2= second operand (immediate or valid value) O1 content change after operation

18 SAL Instruction As SHL instruction Format –SAL O1, O2 O1= first operand, O2= second operand Eg: SAL AH,CL where AH=42H, CL=2 CF=0 –This instruction will caused 8-bit in AH is shifted 2- bit to the left. –Output bit at the right most is inserted to CF and bit which is emptied will be replaced by 0 –Last result, AH=O8H

19 SAR Instruction As in SHR Format –SAR O1,O2 O1= first operand, O2= second operand Eg: SAR AH, 1 where AH=35H, CF=0 This instruction will caused bit in AH is shifted 1-bit to the right Output bit is inserted to CF and empty bit is replace with sign bit Last result, AH=1AH

20 Rotate Instruction Similar to shift instruction, but rotate instruction will input again bit which has been exited at other end There are 4 instructions –ROR – rotate right –ROL – rotate left –RCR – rotate right with carry –RCL – rotate left with carry

21 ROR and ROL Instruction ROL rotate bits to the left Format : ROL O1, O2 ROR rotate bits to the right Format : ROR O1, O2 Final bit is also stored in CF

22 RCR and RCL Instruction RCL rotate left and take CF into consideration Format RCL O1, O2, RCR rotate right and take CF into consideration Format RCR O1, O2

23 Compare Instruction Its function is to set flag register as ready stae before conditional jump instruction is executed Format : CMP OD,OS ;OD= destination operand ;OS= source operand –Both operand must be general register, memory or immediate value

24 Flags Set by the CMP Instruction Signed: Unsigned:

25 Jump Instruction There are two jump instruction –Unconditional jump instruction –Conditional jump instruction Format –Arahan_Lompat label where Arahan_Lompat is an instruction label is the destination where jump will target program execution (label is a name not a register,memory or any value)

26 Some example of conditional jump instruction InstructionDescription JMPJump JAJump Above JAEJump Above or Equal JBJump Below JBEJump Below or Equal JCJump on Carry JCXZJump if CX register is Zero

27 Loop instruction One method that can represent high level language instruction such as “do_while” and “repeat_until” Format –LOOP Operand where Operand=label for instruction at the beginning of the loop Instructions will be executed until loop counter CX=0.

28 LOOP instruction variations InstructionDescription LOOPE/ LOOPZ LOOP while Equal/LOOP while Zero Jump to label if CX=0 and ZF=1 LOOPNE/ LOOPNZ LOOP while Not Equal/LOOP while Not Zero Jump to label if CX=0 and ZF=0


Download ppt "NEG Instruction Change operand content into two’s complement (negative value) and stored back into its operand mov bl,00000001b neg bl; bl = 11111111 mov."

Similar presentations


Ads by Google