Due Date: Next class after your lab session.
The assembly language program that you copied and ran in Lab 2 is very simple, and just does the following computations:
testv = param2
result = param2 + 5 + param1
In this lab, copy the test.asm file to lab3a.asm using the cp command, and then modify lab3a.asm to do the following computations:
testv = param2 + 12
result = param1 - param2 + 7
Hint: Similar to the “ABA” instruction that the example program uses, there is an “SBA” instruction that means subtract B from A. There is not a subtract A from B instruction!
Questions:
Write an assembly program named lab3b.asm that, given one corner and the center of a rectangle, computes the other three corners. You might declare the given data (the one corner and the center) as constants such as:
Xcnr1 FCB 9
Ycnr1 FCB 0 Xcntr FCB 12 Ycntr FCB 5 |
Then, you will declare six variables to hold the X and Y coordinates of the other three corners. At the end of your program, the values must be correct in memory, not just in registers. You can assume that all values (including those you will compute) are 8-bit positive integer values. You do not need to deal with fractional coordinates.
Hints: It doesn’t matter which corner you are given, the computation is the same. Think about the diagonal across the rectangle that starts at the corner you are given. The center of the rectangle is the midpoint of that line, thus, you can use the midpoint formula and a little algebra to calculate the corner at the other side of the diagonal. Once you have that, the rest is easy. Work it out on paper before you start programming. You do not need to multiply or divide anything – adds and subtracts are enough. Also make sure you pay attention to how you use the HC11 registers.
Assemble your source code file to generate the machine code file. Run your program using the simulator.
Questions:
For this lab, you must hand in the following:
Lab report must be named “LastName-Lab3.???” and contains your report and answers to the questions.
Please write the lab report using the template available online at
http://www.cs.nmsu.edu/~joemsong/273/labtemplate.html (HTML version)
or,
http://www.cs.nmsu.edu/~joemsong/273/labtemplate.pdf (PDF version)
Submit these through the web submission page at: