Professional Documents
Culture Documents
Restrictions On MOV & XCHG: General Register Segment Register Memory Location Constant
Restrictions On MOV & XCHG: General Register Segment Register Memory Location Constant
Restrictions On MOV & XCHG: General Register Segment Register Memory Location Constant
General
Register yes yes yes no
Segment
Register yes no yes no
Memory
Location yes yes no no
Constant yes no yes no
1 12/12/2020
Restrictions on MOV & XCHG
XCHG Destination Operand
Source General Memory
Operand Register Location
General
Register yes yes
Memory
Location yes no
2 12/12/2020
Restrictions on MOV & XCHG
Example :
LEGAL:
MOV AX , WORD2
MOV WORD1 , AX
3 12/12/2020
ADD & SUB
– two registers,
– a register & memory location , or
– add ( subtract ) a number to ( from ) a register or a
memory location.
4 12/12/2020
Syntax
5 12/12/2020
Example
ADD WORD1 , AX
6 12/12/2020
ADD WORD1 , AX
Before After
01BC 01BC
AX AX
0523 06DF
WORD1 WORD1
7 12/12/2020
Example
SUB AX , DX
8 12/12/2020
SUB AX , DX
Before After
0000 FFFF
AX AX
0001 0001
DX DX
9 12/12/2020
Example
ADD BL , 5
10 12/12/2020
Legal combinations of operands for
ADD & SUB
Destination operand
Memory location General Register Source Operand
11 12/12/2020
ILLEGAL
12 12/12/2020
INC ( increment )
13 12/12/2020
DEC ( decrement )
14 12/12/2020
Syntax
INC destination
DEC destination
15 12/12/2020
Example
INC WORD1
16 12/12/2020
INC WORD1
Before After
0002 0003
WORD1 WORD1
17 12/12/2020
Example
DEC BYTE1
18 12/12/2020
DEC BYTE1
Before After
FE FD
BYTE1 BYTE1
19 12/12/2020
NEG
20 12/12/2020
Syntax
NEG destination
21 12/12/2020
NEG BX
Before After
0002 FFFE
BX BX
22 12/12/2020
Constant Declaration
23 12/12/2020
Constant Declaration
Examples:
1)
LF EQU 0AH ; LF can be used in place of 0Ah
MOV DL LF
MOV DL 0AH Have the same machine code
2)
PMT EQU ‘TYPE YOUR NAME‘ ;
instead of
We can use
MSG DB PMT
24 12/12/2020
Translation of HLL to
Assembly Language
Statement Translation
B = A
25 12/12/2020
Translation of HLL to
Assembly Language
Statement Translation
B = A MOV AX , A ; moves A into AX
26 12/12/2020
Translation of HLL to
Assembly Language
Statement Translation
A = 5–A
27 12/12/2020
Translation of HLL to
Assembly Language
Statement Translation
A = 5–A
MOV AX , 5 ; put 5 in AX
SUB AX , A ; AX…. 5 – A
MOV A , AX; put it in A
28 12/12/2020
NEG A ; A = -A
ADD A , 5 ;A = 5 - A
29 12/12/2020
Translation of HLL to
Assembly Language
Statement Translation
A= B–2*A
30 12/12/2020
Translation of HLL to
Assembly Language
Statement Translation
A = B – 2 * A MOV AX , B ; AX has B
SUB AX , A ; AX has B – A SUB AX
, A ; AX has B – 2 * A
MOV A , AX ; move results to B
31 12/12/2020