Unit 2.2 -- One more example--Handling a constant
PROG
Add A to B and then subtract one, putting the result into C
PED
To learn how to represent constants
CONCEPTS
Use
label DC f'nn'
to put a constant in a memory location at load time.
SF
2.html
Unit 2.2
English
Unit 2.2 performs the operation C:=A+B-1.
Notice the presence of the constant, -1, in the PASCAL
statement. The constant can be stored using the DC f'nn'
instruction we learned about earlier. The name of this
memory location is F1. It signifies the "F" in the DC
command followed by M for "Minus" and then 1. We could use
any name for our constant such as "SUGAR" or "BLAH" There
is no magic to the namin convention I am using.
This is done at line 16--memory location 000032.
Since this is only the second ASSEMBLER program, you have
been formally shown, I will describe the steps in the
execution once again.
The program executes as follows.
There are now four boxes. A, B and FM1 are initialized to
3,4 and -1, respectively. These values are loaded into
memory as the program itself, including the instructions,
are put into memory.
The "L 1,A" copies the 3 in the A box to register one.
Register one now will be three.
The "A 1,B" adds the 4 in the B box to register one.
Register one will now be seven.
The "A 1,FM1" adds the -1 in the C box to register one.
Register one will now be six.
The "ST 1,C" copies the six in register one to the memory
location. C is now six.