Assembly
CST8216 Processor Architecture Lab Exercises Last Revision Winter 2021 Page 1 of 7 ©2021 D. Haley 21W CST8216 Lab Assignment 3A - Lab Week Ten.docx Assignment 3A (50 marks) – Lab Week 10 – More Assembly Language Analysis and Coding Approximate time to complete: 3 – 4 hours. Due Dates: Part A – By 11:30 PM of Friday of Week 11 – Assignment 3A – Lab Week 10 – Quiz Questions Part B – By 11:30 PM of Friday of Week 11 – Submission Link for Assignment 3A – Lab Week 10 GradesII.asm and FX.asm – Code Submissions (use 2 separate files – DO NOT place them into a compressed file) There is no requirement to submit Grades.txt Purpose of the LAB: The purpose of this lab is to confirm your problem solving skills by implementing solutions to two problems using 68HCS12 Assembly Language, based upon Week 9 and 10’s Lectures and various Hybrid Lectures. Part A (20 marks) – Lab Week 10 - Assignment 3A Quiz Questions A3A Quiz – Questions 1 – 10 (1 mark each) test your understanding of tracing through an Assembly Language program that uses various Addressing Modes by evaluating the contents of Registers and Memory Address locations, including various Addressing Modes used within the code listing. A3A Quiz – Questions 11 – 15 (2 marks each) test your understanding of simple Assembly Language branch instructions as we have discussed in various lectures. A reminder to use the “$” sign in your answers in this quiz. Structured Programming in Assembly Language This lab exercise challenges your problem solving abilities to effectively and efficiently determine a solution to two given problems. You are advised to think through these problems and solve them on paper prior to coding them as “jumping into” Assembly Language coding without an already workable solution can be very frustrating and likely cause you to spend an inordinate amount of time attempting a solution. GradesII.asm Week 9’s Assignment 2B saw us convert Marks into Grades using Selection Structure in 68HCS12 Assembly Language. This lab exercise will see us create GradesII.asm, which iterates through a provided grades and Tally (count) the number of As, Bs, Cs, Ds, and Fs. Implementation Details The following information expands upon the Marking Rubric provided for this assignment. • Name the program: GradesII.asm and create it using AsmIDE • Use $2000 as the program code origin and initialize the Stack Pointer to $2000 as your first instruction. • Use the supplied Grades.txt file in your solution. It must originate in the memory locations illustrated in the example program run screen shot example. • The Tally of the Grades must appear in the memory locations illustrated in the example program run screen shot. CST8216 Processor Architecture Lab Exercises Last Revision Winter 2021 Page 2 of 7 ©2021 D. Haley 21W CST8216 Lab Assignment 3A - Lab Week Ten.docx • All Labels must follow course standards o e.g. Num_As, Num_Bs, Grades, End_Grades, and so on • The Expected Results of the program run must be included within the code, ideally immediately following the Grades Array as per the supplied example • Appropriate documentation must be used both in the Program Header and within the code so that the program functionally is clear. Describe WHAT the program is doing, NOT the instruction set. Very Important • Iteration must be used in your solution and I recommend that you use the Memory Address approach for iteration versus using loop counter • Your code must use the Register Offset Addressing Mode in its solution • Your code must produce identical results if it is run more than once – e.g. you run the code in the Simulator and then use FileReset and run the code again. GradesII.asm Hint, Expected Results and Sample Program Run Week 10’s lecture includes a review of Register Offset Indexed Addressing, which was already discussed in an earlier Hybrid Lecture. This Addressing Mode will be very useful in your solution. Analyze the Grades ASCII values as indicated in the partial ASCII Table below to best determine how you can use this Addressing Mode, noting that the values presented are in base 16. For the Expected Results, document your code as per the following example: The following example screen shot provides the Memory Map that you must use in your program. Note that the Tally of each grade falls underneath the appropriate Memory Address Label in the Simulator. (Highlighting added for emphasis). CST8216 Processor Architecture Lab Exercises Last Revision Winter 2021 Page 3 of 7 ©2021 D. Haley 21W CST8216 Lab Assignment 3A - Lab Week Ten.docx FX.asm In this part of the assignment, we will create FX.asm, which iterates through a given mathematical formula, calculates and stores the results in Memory. Implementation Details The following information expands upon the Marking Rubric provided for this assignment. • Name the program: FX.asm and create it using AsmIDE • Use $2000 as the program code origin and initialize the Stack Pointer to $2000 as your first instruction. • Solve the equation f(x) = 3x + 5 for x = 0 to 9, using 8-bit Multiplication • Place the x values into a X_Values array, which starts at the Memory Location indicated in the example program run and in the same loop, place the calculated f(x) values into the Results array, which starts at the Memory Location indicated in the example program run • All Constants and Labels must follow course standards o e.g. THREE, ARRAY_LEN, Loop, Results, End_Results, and so on • The Expected Results of the program run must be included within the code, ideally immediately following the X_Values array for the x values and the Results array for the calculated values of f(x) • Appropriate documentation must be used both in the Program Header and within the code so that the program functionally is clear. Describe WHAT the program is doing, NOT the instruction set. • I recommend that you use the Memory Address approach for iteration versus using loop counter Very Important • Iteration must be used in your solution and either the Memory Address or Loop Counter approach for iteration would work well in this program • Your code must use the 8-bit mul instruction in its solution. • Your code must use Constant Offset Indexed Addressing Mode in its solution. (This will save you a LOT of unnecessary coding if you think through the problem before coding its solution. FX.asm Hints and Sample Program Run Solving mathematical equations may seem to be an overwhelming task to do in a programming language; however, I find that if I layout the problem using a tool such as Excel, then it makes the problem easier to understand and implement. Here is the problem solved in Excel. Here we should be able to extract the concept of a loop counter from the values in the x column, the multiplication of the x value by 3 in the 3x column and the Expected Results after adding 5 in the 3x + 5 column. All that remains is for the solution to be coded. Then we confirm the program’s output against the Excel solution, which forms our Test Plan. Note: Just before using the mul instruction, you may have to temporarily store the x value in a temporary memory location and then retrieve it back after the mul instruction. CST8216 Processor Architecture Lab Exercises Last Revision Winter 2021 Page 4 of 7 ©2021 D. Haley 21W CST8216 Lab Assignment 3A - Lab Week Ten.docx Expected Program Output Note that your solution must exactly match this program snap-shot of the output. (Highlighting added for emphasis). Assessment Note: If your Name and Student Number are missing in the Program Header on any Code Submission, you will receive a mark of zero for the submission, as you are not indicating that it is your original, independently created work. You will be assessed in accordance with the following marking rubrics, which are also available on the Assignment link. Grades.asm CST8216 Processor Architecture Lab Exercises Last Revision Winter 2021 Page 5 of 7 ©2021 D. Haley 21W CST8216 Lab Assignment 3A - Lab Week Ten.docx CST8216 Processor Architecture Lab Exercises Last Revision Winter 2021 Page 6 of 7 ©2021 D. Haley 21W CST8216 Lab Assignment 3A - Lab Week Ten.docx FX.asm CST8216 Processor Architecture Lab Exercises Last Revision Winter 2021 Page 7 of 7 ©2021 D. Haley 21W CST8216 Lab Assignment 3A - Lab Week Ten.docx Should you have any questions regarding this assignment, please ask your Lab Professor or myself during a Lab period, Consultation Hours or at the end of any Lecture period. Purpose of the LAB: Part A (20 marks) – Lab Week 10 - Assignment 3A Quiz Questions Implementation Details Implementation Details Expected Program Output Assessment