Laboratory 1
Machine Language Instructions
and Arithmetic
After this laboratory exercise, you should understand how a computer executes simple machine language instructions, and how instructions and data are stored in memory and arithmetic for computers. You should also be acquainted with the MIPS simulator.
Study the following small assembly program and explain how it works.
In the Examples directory you will find several simple well-documented MIPS assembly
programs. Run the code in the order below of increasing complexity. 1, 2, 3, 4, 5. 1. add2numbersProg1
2. add2numbersProg2
3. storeWords
4. swap2memoryWords 5. branchJump
Assignment 1
Translate the five programs above to machine code and record them.
Assignment 2
The lab computer will execute a program, instruction by instruction, when you give the command step in the console window. Use this command and execute the program step by step, and inspect what happens with the registers and program counter after each step.
Try to record and explain the execution of two of the example programs above.
Conclusions
After you finish the laboratory exercise, think about the questions below and answer them:
■ Which registers are affected by a branch instruction?
■ How many bytes are used to store one instruction?
■ Can the computer execute an assembly instruction?
CS Help, Email: tutorcs@163.com