Assembly Language Exercise Part 1

Note

XCHG (exchange data) 
 Changes the contents of two operands.
  Three variant: o XCHG reg, reg o XCHG reg, mem o XCHG mem, reg
  The rules for XCHG are the same as MOV except that XCHG does not except immediate operand that is xchg ax, 4 is prohibited.
  Examples: o xchg ax, bx ; ax bx exchange
16-bit registers o xchg ah, al ; ah al exchange
8-bit registers o xchg var1, bx ; var1 bx exchange
 16-bit memory op with bx

INC (increment) 
 Add 1 from the single operand.
 Format: o INC reg o INC mem
 Examples:
 o inc ax ; ax ax + 1
o inc var1 : var1 var1 + 1

DEC (decrement) 
 Subtract 1 from the single operand.
 Format: o DEC reg o DEC mem
 Examples:
o dec ax ; ax  ax - 1
o dec var1 : var1 var1 - 1

NEG (negate)
  Reverse the sign of the number by converting the number to its two’s complement
 Format: o NEG reg o NEG mem
 Examples:
o neg ax ; ax  -ax
o neg var1 : var1  - var1

MUL (multiply) 
DIV (divide) 
 Examples:
o Divide 8003h by 100h, using 16-bit operands:
 mov dx,0 ; clear dividend, high
mov ax,8003h ; dividend, low
mov cx,100h ; divisor
div cx ; AX = 0080h, DX = 3


o Same division, using 32-bit operands:
 mov edx,0 ; clear dividend, high
mov eax,8003h ; dividend, low
mov ecx,100h ; divisor
 div ecx          ; EAX = 00000080h, DX = 3



Post a Comment

0 Comments