ArmToHack.h
: contains the class with method signaturesArmToHack.cpp
: contains the method implementations
Student.h | Student.cpp | main.cpp
Stack
to the first address of Video memory.
The user may change that value later, but the initial value should be as specified above. (For example, the VisUAL IDE always starts with SP=0xFF000000
although we sometimes switched it to 0x1100
).
LDMIA
and STRDB
. To simplify, for now assume that the register list has a single entry:
STMDB Rn!, {R7}
LDMIA Rn!, {R7}
Here are sample test programs. The first writes three registers on the stack, the second reads three values from the stack.
For convenience each changes the default value of SP
and sets it closer to the the top. What should be the value of SP
when the first program is done? the second?
program11.arm (should see12,13,11
in cells19,18,17
)program12.arm (should see
R1=11,R2=12,R3=13
)
LDMIA
and STRDB
with multi-entry register list. The ARM user will be expected to list the registers in the same order for related STMDB
and LDMIA
instructions (for example saving and restoring registers for a function call).
STMDB Rn!, {R7, R2, R11}
LDMIA Rn!, {R7, R2, R11}
Here are sample test programs. The first writes three registers on the stack, the second reads three values from the stack.
For convenience each changes the default value of SP
and sets it closer to the top. What should be the value of SP
when the first program is done? the second?
program13.arm | program14.arm
LDR
and STR
:
STR Rs, [Rb, Ri]
LDR Rd, [Rb, Ri]
Here Rb
is the base register and Ri
is the index which may also be a numeric value (i.e. Operand2).
program15.arm (should seeR7=42
)program16.arm (should see
R3=42, R4=24, R5=66
)program17.arm (should see 42 in cell 19)
program18.arm (should see 42, 24, 66 in cells 18,19,20)
numbers DCD 1, +2, -3
value DCD 4
All user defined variables will start immediately after the registers, i.e. from index 16.
Each value will be allocated just one Hack cell. In the above example, the array numbers
will occupy cells 16-18
and the array value
will occupy cells 19
.
program19.arm (should see1..4
in cells16..19
)program20.arm (should see
1..8
in cells16..23
)
LDR
to include the option of loading the base of an array:
LDR Rd, =array
This will require another lookup table to store the base of each array. In the above example, the base of array numbers
is 16
and the base of array value
is 19
.
program21.arm (should see4,2,-3,1
in cells16..19
)program22.arm (should see
1,4,5,5,4,5,7
in registersR4..R10
)
Upload a screenshot named program23.png of Hardware Simulator / CPU Emulator that shows the contents of the RAM.
program23.arm (should see1,3,6,10,15,21
in cells22..27
)
ArmToHack.h
, ArmToHack.cpp
, main.cpp
, program23.png
to the Moodle dropbox.