=========================================================================== Assignment #12 - LMC Linking, Relocation, and Loading =========================================================================== - Ian! D. Allen - idallen@idallen.ca - www.idallen.com Available online: Thursday April 14, 2011 Upload due date: Upload answer file before 23:59 (midnight) on Thursday April 21, 2011 Answers will be posted shortly after the due date/time. Late assignments may or may not be marked. Submission method: Create a plain text file using the exact name "assignment12.txt" Upload the file via the Assignment12 "Upload File" facility in Blackboard. Use "Attach File" and "Submit" to upload your plain text file. No wordprocessor documents. Do not send email. Use only "Attach File". Use the file name given above. Upload only one single file of plain text, not HTML, not MSWord. No fonts, no word-processing. Plain text only. Did I mention that the format is plain text (VIM/Nano/Pico/Gedit or Notepad)? NO WORD PROCESSOR DOCUMENTS ACCEPTED. No marks are awarded for submitting under the wrong assignment number. Not all assignments will be marked. See the Week 1 Notes for details. Answers will be posted after the due date/time. Questions similar to ones on these assignments will appear on your tests and exams. ============================================================================== DO THIS: Edit this file and answer the following questions underneath each question. Upload the file containing the questions and answers before the due date. Some of the answers below will require reading the links published in the weekly course notes. ============================================================================== 0. Did you fill out your online course evaluation yet? Surveys close on Friday, April 22. You can win prizes, but only if you fill out the survey! And don't forget to VOTE on May 2. Rick Mercer Report: http://www.youtube.com/watch?v=UOWtXc2dUHw *** Z+C+S+O Flags Section *** 1. Perform the indicated 8-bit hexadecimal arithmetic. Show the 8-bit result value and indicate by check marks the correct "ON" states of the Zero, Carry, Sign, and Overflow flags after the arithmetic. Indicate by check marks (type an X in the space) if the 8-bit result is correct for signed two's complement arithmetic (OK-SIGN) and/or correct for unsigned arithmetic (OK-UNSIGN). Leave flags that are OFF blank: (Reference: Assignment 8) 90 + B0 = _______ Z___ C___ S___ O___ OK-SIGN___ OK-UNSIGN___ 80 + 70 = _______ Z___ C___ S___ O___ OK-SIGN___ OK-UNSIGN___ 70 + 50 = _______ Z___ C___ S___ O___ OK-SIGN___ OK-UNSIGN___ FF + FF = _______ Z___ C___ S___ O___ OK-SIGN___ OK-UNSIGN___ 80 + 80 = _______ Z___ C___ S___ O___ OK-SIGN___ OK-UNSIGN___ *** Linking and Object Files Section *** Reference: 370_LMC_link.html - Linking and Generation of Executable Code from Source Program Files Reference: 373_LMC_object_file_format.html - Linking and External "Object" Files and Libraries 2. What is the difference between a Public Symbol and a Global Symbol? (trick question) 3. What is the purpose of the LMC mnemonic pseudo-instruction PUB? 4. What is the purpose of the LMC mnemonic pseudo-instruction EXT? 5. Identify the four components of an "Object" file and describe the purpose of each component in your own words. 6. In your own words, explain how a "linker" program uses the relocatable address list, the public (or "global") label definition table, and the external reference table (all from within a collection of object files) to generate an "executable" version of a program. In the course notes (370_LMC_link.html) you will find an LMC main program and two subroutines "Pause" and "Dble". These questions are based on those three modules, their machine code, and their object file tables. 7. Provide the contents of each of the three relocated external tables that would be associated with the object code for each of the three modules Main, Pause, and Dble. (That means 3 tables for each of the three modules: 9 tables in all; some of the tables may be empty.) The tables should reflect the relocated locations of the modules loaded in the given order: Main, Pause, Dble. Hint: All this information is already worked out in the web page. 8. Delete the first two instructions from the MAIN program (LDA COUNT, OUT) and move the MAIN and Repeat labels to the CALL PAUSE instruction that is now the first instruction of the new, shorter MAIN program. Re-assemble the new, shorter MAIN program to produce a new object file. Give the new, shorter MAIN Object File here (14 instructions of machine code and three tables); 9. Do a link and load of the New MAIN (previous question), Pause, and Dble. Load the three modules into memory in the order: New MAIN, Pause, Dble. New MAIN loads starting at zero, followed by Pause, followed by Dble. Generate the nine new relocated tables that would be associated with the object code for each of the three modules New MAIN, Pause, and Dble. (That means 3 tables for each of the three modules: 9 tables in all; some of the tables may be empty.) The tables should reflect the relocated locations of the modules loaded in the given order starting at 00: New MAIN, Pause, Dble. 10. Using the tables from the previous question, generate the relocated and linked machine code for the Dble module loaded at its new address. Show the original object code of Dble (before any modifications), followed by the fully modified (relocated and linked) code for the Dble module in its new location in memory. Beside each location that has been modified, give the reason why the modification was made. Answer this question using a multi-column table: Column 1: original address Column 2: original object code before any modifications Column 3: new address in memory Column 4: new object code (fully relocated and linked) Column 5: reason for object code change (if any change) Example five-column table format for your answer: Original New Reason for change -------- ------- ------------------------------------------- 00: 117 20: 137 local memory reference relocated by +20 01: 000 21: 023 "CALL foo" external subroutine located at 23 02: 700 22: 700 no change ... This question usually appears on the Final Exam. Original New Reason for change -------- ------- ------------------------------------------- -- | Ian! D. Allen - idallen@idallen.ca - Ottawa, Ontario, Canada | Home Page: http://idallen.com/ Contact Improv: http://contactimprov.ca/ | College professor (Free/Libre GNU+Linux) at: http://teaching.idallen.com/ | Defend digital freedom: http://eff.org/ and have fun: http://fools.ca/