To investigate assembly language programs and to see how pseudocode, and high-level programming languages, expressions and control structures may be expressed using assembly language.
The Assembly Language Simulator allows you to write instructions in assembly language and then run them on our machine.
Programs are entered into the Editor in assembly language. When the Assemble & Load button is pushed the assembly language program is translated into a machine language program and loaded into the simulator.
The simulator shows the memory addresses, the machine language instructions in the memory at each address, and the corresponding assembly language instruction.
Each press of the Step button carries out one instruction in the program.
Enter the following assembly language program into the machine simulator:
Example 1. Simple Assembly Language Program
halt X: .data 1
Press Assemble & Load to translate the assembly language program into machine language and to load it into the simulator.
In the first column of the Assembly Listing you will see the machine language program. In the second column you will see corresponding steps of the assembly language program.
Copy the Assembly Listing into your Lab Notebook. For each step write down the memory address that it will take.
Go back to edit mode and change the 1 on the .data line to 3. Now press Assemble again to translate it. Record the changes between this Assembly Listing and the previous one.
Now enter a value of your own for that data X. Keep it under 200. Record the machine language part and the assembly language part of this line.
Describe in your Lab Notebook what the .data assembly directive (that is what it is actually called) does.
Enter the following assembly language program into the machine simulator:
Example 2. Simple Calculation Assembly Language Program
load X add Y store Z halt X: .data 3 Y: .data 4 Z: .data 0
Assemble the program and copy down the original assembly language program and the translated machine language program.
Step through the program and observe what it does.
Edit the initial value of the memory location X so that instead of the value 3 it contains the value of your age (you may use a fake age if you want to). Do the same to the memory location Y changing it from the value 4 to the value 7.value 7. Step through the program and observe what it does.
Write down in your Lab Notebook an english description of what this assembly language programs does.
Write the pseudocode statement that is equivalent to these assembly language instructions.
Record what memory addresses contain machine language instructions, and record what memory addresses contain data.
Enter the following assembly language program into the machine simulator:
Example 3. Less Simple Calculation Assembly Language Program
load A add B subtract C store D halt A: .data 11 B: .data 3 C: .data 8 D: .data 0
Assemble the program. Write down in your Lab Notebook the original assembly language program and the translated machine language program.
Step through the program and observe what it does.
Edit the program changing the value of A to 14, B to 2 and C to 1. Assemble the program and record any differences between the machine language program from the original example and the one after you have made your changes.
Step through the program and observe what it does.
Write down in your Lab Notebook an english description of what this assembly language programs does.
Write the pseudocode statement that is equivalent to these assembly language instructions.
Record what memory addresses contain machine language instructions, and record what memory addresses contain data.
Enter the following assembly language program into the machine simulator:
Example 4. Conditional Assembly Language Program
load X compare Y jumpgt OVER load X store T load Y store X load T store Y OVER: halt X: .data 11 Y: .data 3 T: .data 0
Assemble, Load and Step through the program recording what it does at each step.
Change the values of X and Y to see what the program is doing. Record the values that you tried and the results that you observed.
Write down in your Lab Notebook an english description of what this assembly language programs does.
Write the pseudocode statement that is equivalent to these assembly language instructions.
Record what memory addresses contain machine language instructions, and record what memory addresses contain data.
Enter the following assembly language program into the machine simulator:
Example 5. Another Conditional Assembly Language Program
load X compare Y jumpgt ELSE load X store M jump OVER ELSE: load Y store M OVER: halt X: .data 3 Y: .data 11 M: .data 0
Assemble, Load and Step through the program recording what it does at each step.
Change the values of X and Y to see what the program is doing. Record the values that you tried and the results that you observed.
Write down in your Lab Notebook an english description of what this assembly language programs does.
Write the pseudocode statement that is equivalent to these assembly language instructions.
Record what memory addresses contain machine language instructions, and record what memory addresses contain data.
Enter the following assembly language program into the machine simulator:
Example 6. Iterative Assembly Language Program
clear S clear I TOP: load N compare I jumpgt DONE load S add I store S increment I jump TOP DONE: halt N: .data 5 I: .data 0 S: .data 0
Assemble, Load and Step through the program recording what it does at each step.
Using small values for N, change the values of N and look carefully at the value of S to see what the program is doing. Record the values that you tried and the results that you observed.
Write down in your Lab Notebook an english description of what this assembly language programs does.
Write the pseudocode statement that is equivalent to these assembly language instructions.
Record what memory addresses contain machine language instructions, and record what memory addresses contain data.
Enter the following assembly language program into the machine simulator:
Example 7. Math Function Assembly Language Program
load N store CURN clear COUNT clear ODD increment ODD TOP: load ODD compare CURN jumplt DONE load CURN subtract ODD store CURN increment ODD increment ODD increment COUNT jump TOP DONE: halt N: .data 9 CURN: .data 0 COUNT: .data 0 ODD: .data 0
This program does a well-know mathematical operation. If you have a calculator it probably has a button for this. It works on positive integers only, no floating point values.
Run the program and record what it does. Try changing the values of N and look carefully at the value of COUNT to see what the program is doing. Record the values that you tried and the result that you got. You will want to use small values for N at first, but make sure to try some values up to 100. Make a chart of your results.
Write down in your Lab Notebook an english description of what this assembly language programs does.
Write the pseudocode statement that is equivalent to these assembly language instructions.
Record what memory addresses contain machine language instructions, and record what memory addresses contain data