Coen311 lab4 .docx - lab 4 coen 311 PDF

Title Coen311 lab4 .docx - lab 4 coen 311
Author Dantès Le Magnifique
Course Computer Organization and Software
Institution Concordia University
Pages 5
File Size 295 KB
File Type PDF
Total Downloads 38
Total Views 146

Summary

lab 4 coen 311...


Description

Concordia University

Coen 311 Computer organization and software Lab Section: SM-X Lab Report #4 Time: 2:45pm Labs instructor’s name: Mustafa Daragraph

Performed by: Jack Pan Student ID: 40097563 Performed on: October 30, 2019 Summited on: November 13, 2019

Objectives The objective of this experiment was to investigate subroutines. Introduction A subroutine is a sequence of program instructions that perform a specific task, packaged as a unit. This unit can then be used in programs wherever that task is needed. Subprograms may be defined within programs or separately in libraries that can be used by multiple programs. With assembly programming the MC68000 when using subroutines to perform a specific task we will need to make sure that when the program jumps to the subroutine, the registers contain the same data before and after the subroutine to commence the normal sequence of instructions after calling the subroutine. Also, another parameter that must be kept is the return address to which the processor should follow when coming back from the subroutine. The stack, an assigned portion of the memory will be made use of to keep track of the registers and the return address. The stack works with the mechanism of “last in/first out” thus we will be using the push and pop mechanisms. The stack grows from higher to lower address locations. Results & Discussion

Figure 1.0 showing code with subroutine

In the main part of the program an origin of $4000 was declared as the start point of the execution. The numbers 8, 7, and 5 are moved to registers D0, D1 and D2 respectively. These registers are then pushed onto to the stack with D2 being the last one on top of the stack. The program will then go to MySUB. Inside the stack subroutine, there are some displacement values in front of the stack pointer before moving the values from the stack to the required register. This is because we need to make sure we know where the stack pointer is so the correct values are able to go to the correct registers. Register D3 is then cleared, the contents of D0 is added to it and the results is stored in it. The contents of D1 is then added to it again and the results are stored in it. Finally, the results of D2 is subtracted from it and then stored in it, making the final value in register D3 being 10. The figure below confirms this final value in D3 and the list file shows all generated machine code confirming everything was done correctly.

Figure 2.0: listing file showing no errors compiled

Figure 2.1: final results in D3 $A=10

Questions 1. Which register is used as the stack pointer in the 6800 microprocessor? The register A7 is used as the stack pointer in the 6800 microprocessor. 2. Why is it important to modify the stack pointer register upon a return from a subroutine when parameters have been pushed onto the stack? It is important to modify the stack pointer upon a return from a subroutine because each time parameters are pushed onto the stack the stack pointer position changes. If it is not modified the pointer may not know exactly where to go after it returns from the subroutine. 3. What is another way of passing parameters to a subroutine other than pushing them onto the stack? Parameters can also be passed by value through data registers or by reference through address registers.

Conclusion. After performing this experiment, we learned that subroutines will basically act as a function in high-level programming languages. It is only called when needed, after execution control is returned to the caller and parameters can be passed to and from it either by reference or by value. Since the correct result was obtained after the experiment was performed, it is safe to say that this experiment was a success and met its objective.

Appendix...


Similar Free PDFs