Figure 3-8 Program sequence for interchanging the contents of two locations.
| Data related directives, input, and other code OPR1 and OPR2 are defined as byte variables MOV AL,OPR1 ;(OPR1) TO AL
MOV BL,OPR2 ;(OPR2) TO BL
MOV OPR2,AL ;(AL) TO (OPR2)
MOV OPR1,BL ;(BL) TO (OPR1)
Output and other code |
| (a) Code |
![]() |
| (b) Action taken |
Figure 3-9 Machine language code for the program sequence given in Fig 3-8(a).
| Physical Address | Machine Code | |||
|---|---|---|---|---|
| 0C530 | 8A | MOV AL, OPR1 | ||
| 0C531 | 06 | |||
| 0C532 | 00 | |||
| 0C533 | 12 | |||
| 0C534 | 8A | MOV BL, OPR2 | ||
| 0C535 | 1E | |||
| 0C536 | 20 | |||
| 0C537 | 1C | |||
| 0C538 | 88 | MOV OPR2,AL | ||
| 0C539 | 06 | |||
| 0C53A | 20 | |||
| 0C53B | 1C | |||
| 0C53C | 88 | MOV OPR1,BL | ||
| 0C53D | 1E | |||
| 0C53E | 00 | |||
| 0C53F | 12 | |||
| 0C540 | . |
Figure 3-10 Interchanging bytes in memory using XCHG.
| Data related directives, input, and other code OPR1 and OPR2 are defined as byte variables MOV AL,OPR1 ;LOAD AL WITH (OPR1)
XCHG AL,OPR2 ;EXCHANGE AL WITH (OPR2)
MOV OPR1,AL ;MOVE (AL) TO (OPR1)
Output and other code |
This is page 26.