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
0C5308A
MOV    AL, OPR1
0C53106
0C53200
0C53312
0C5348A
MOV    BL, OPR2
0C5351E
0C53620
0C5371C
0C53888
MOV    OPR2,AL
0C53906
0C53A20
0C53B1C
0C53C88
MOV    OPR1,BL
0C53D1E
0C53E00
0C53F12
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

Table of Contents | Next page | Previous page

This is page 26.