Example - 03move.asm - Data Moves |
; --------------------------------------------------------------- |
Step through the program and watch the register values changing. In particular, look at the RAM-Hex display and note the way that values in RAM change. Addresses [50] and [A0] are altered. You can copy the example program from the help page and paste it into the source code editor.
There are several ADDRESSING MODES available with move commands.
A hexadecimal number is copied into a register. Examples...
MOV AL,15 ; Copy 15 HEX into the AL register
MOV BL,40 ; Copy 40 HEX into the BL register
MOV CL,50 ; Copy 50 HEX into the CL register
MOV DL,60 ; Copy 60 HEX into the DL register
A value is moved to or from RAM. The ram address is given as a number like [22] in square brackets. Examples...
MOV [A0],AL ; Copy value in AL to RAM location [40]
MOV BL,[40] ; Copy value in RAM location [A0] into BL
Copy a value from RAM to a register or copy a value from a register to RAM. The RAM address is contained in a second register enclosed in square brackets like this [CL]. Examples ...
MOV [CL],AL ; Copy the value in AL to the RAM location that CL points to.
MOV BL,[CL] ; Copy the RAM location that CL points to into the BL register.
Not available in this simulation.
A register move looks like this
MOV AL,BL
To do this using simulator commands, use
PUSH BL
POP AL
Push and Pop are explained later.
Not available in this simulator.
Copy a value from RAM to a register or copy a value from a register to RAM. The RAM address is contained in square brackets and is calculated. This is done to simplify access to record structures. For example a surname might be stored 12 bytes from the start of the record. This technique is shown in the examples below.
MOV [CL + 5],AL ; Copy the value in AL to the RAM location that CL + 5 points
to.
MOV BL,[CL + 12] ; Copy the RAM location that CL + 12 points to into the BL
register.
Not available in this simulator.
In this case, memory locations are named. Address [50] might be called 'puppy'. This means that moves can be programmed like this.
MOV AL,puppy ; Copy the value in RAM at position puppy into the AL register.
MOV puppy,BL ; Copy BL into the RAM location that puppy refers to.
© C Neil Bauers 2003