程序代写代做代考 assembly compiler go assembler 2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
Workshop 07 – Virtual Machine Translaon
Virtual Machine Translaon Overview
Completing this workshop should expose you to the keys ideas required to translate Jack Virtual Machine Code into Hack Assembly Language. To simplify the task we have skipped the parsing component of the relevant Nand2Tetris projects and have provided two useful programs,
bin/assembler and bin/simulator. You can use these to write Hack Assembly Language implementations of individual VM commands and see
what happens as they are executed.
Parcipaon Marks
Up to 5 participation marks are available for every workshop, 2 for preparation, 1 for attendance and 2 for completing an activity, subject to the conditions described on the Participation Marks (https://myuni.adelaide.edu.au/courses/54311/pages/participation-marks) page.
Aendance
One participation mark will be awarded if your workshop attendance is recorded and you make a submission to the Workshop 07 assignment in the Web Submission System by Friday 11.55pm of week 7. Do not leave a workshop until you have checked your attendance mark.
If you are using a CAT suite computer running Linux in a timetabled workshop, your presence should be automatically recorded when you visit our practical marker (https://cs.adelaide.edu.au/services/pracmarker/) . If your attendance mark is not displayed when you visit our practical marker (https://cs.adelaide.edu.au/services/pracmarker/) , your presence will need to be manually recorded. Do not click on the “flag me for marking” button until a supervisor is standing next to you and is ready to record your presence. The flag is only to speed up the data entry and is only visible for 30 seconds.
Workshop 07 Background Reading
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 1/15

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
Before attending the workshop you should read the full workshop description, review the startup files provided below and you may wish to re- read chapter 7 of the textbook.
Workshop 07 Preparaon Acvity
Two participation marks will be awarded for completion of this preparation activity if it is completed at least 10 minutes before the first timetabled workshop of the week, see Participation Marks (https://myuni.adelaide.edu.au/courses/54311/pages/participation-marks) for details.
Note: in example commands % is the shell’s prompt, it is not part of the command.
Note: this workshop assumes that you have already created directories for every assignment, workshop project and exam in your svn repository, as described on the Startup Files for Workshops and Assignments (https://myuni.adelaide.edu.au/courses/54311/pages/startup-files-for- workshops-and-assignments) page.
Note: the web submission system will record 0 marks for completing this activity, the 2 marks are awarded later if and only if your attendance is recorded.
1. If required, checkout a working copy of the workshop07 directory from your svn repository.
2. Change directory to the working copy of the workshop07 directory.
3. Copy the newest zip file attached below into the updates sub-directory and add it to svn.
4. Run the following command to place the workshop’s startup files in the correct locations:
% make install
5. Add all the question files to your svn repository:
6. Goto the Web Submission System and make a submission to the Workshop 07 assignment. A successful submission that passes the preparation tests will complete the preparation activity.
Workshop 07 Acvity
% svn add question*
% svn commit -m “Workshop 07 Startup Files”
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 2/15

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
Two participation marks will be awarded for completing the following activity. This need not be completed during the workshop but no participation marks will be awarded if the activity is not completed by Friday 11.55pm of week 7.
After completing the VM command implementations in each question*.vm-asm file, commit your changes to svn: % svn commit -m workshop07-activity
After each commit, go to the Web Submission System and make a submission to the Workshop 07 assignment. A successful submission that passes the tests of question00.vm-asm, question01.vm-asm and question02.vm-asm will complete the workshop activity.
VM Translaon
When translating VM commands into Hack Assembly Language there are a number of conventions that you must observe, some of which will be checked by the tools that we are using:
Notes:
VM commands produced by the Jack compiler always start with a function command.
All function names are prefixed by the name of the class being compiled and the character ‘.’, eg a function “func” inside a class “Silly” would be named “Silly.func”.
If the first VM command is not a function command, the initial function name is “Unknown.unknown”.
Function names are translated into an assembly language label of the same name.
VM label names are translated into an assembly language label that is prefixed by the name of the current function and the character ‘$’, eg inside the VM function “Silly.func”, the label “LL” would be translated into “Silly.func$LL”.
Static variables, referred to by offsets into the static segment, are translated into an assembly language symbol that prefixes the offset with the current classname and the character ‘.’, eg inside the function “Silly.func”, references to “static 6” would be translated into references to “Silly.6”.
bin/assembler
The bin/assembler program assumes that its input is a series of VM commands each followed by their implementation and a blank line or the end of input. If no implementation is provided for a VM command it is immediately followed by a blank line or the end of input. Here is an
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 3/15

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
example input for a function Silly.func that has no local variables and calculates the sum of 5 and static variable 6. The first contains a question file without the implementations and the second contains possible implementations.
Example Input – No Implementaons
function Silly.func 0
push constant 5
push static 6
add
Example Input – Full Implementaons
function Silly.func 0
(Silly.func)
push constant 5
@5
D=A
@SP
AM=M+1
A=A-1
M=D
push static 6
@Silly.6
D=M
@SP
AM=M+1
A=A-1
M=D
add
@SP
AM=M-1
D=M
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 4/15

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 5/15
Example Outputs
The output of bin/assembler is highly structured and is designed to be read by the bin/simulator program, not by humans. It contains extra data so that the instructions that implement each command can be safely executed as part of testing by the simulator. For example, each command’s implementation is enclosed in its own STRTVM, STOPVM section, there are no_op sections following any implementation that contain no instructions and if any VM language labels are left undefined they are added to the EXTERNALS section. The output for our second example looks like this:
A=A-1 M=D+M
STRT CLASS
STRTVM function Silly.func 0
00000: // function Silly.func 0
00000: (Silly.func)
STOPVM function Silly.func 0
STRTVM no_op
00000: 1110101010000000 0
STOPVM no_op
STRTVM push constant 5
00001: // push constant 5
00001: 0000000000000101 @5 @5
00002: 1110110000010000 D=A
00003: 0000000000000000 @0 @SP
00004: 1111110111101000
00005: 1110110010100000
00006: 1110001100001000
STOPVM push constant 5
STRTVM push static 6
00007:
00007: 0000000000010110 @22 @Silly.6
00008: 1111110000010000 D=M
00009: 0000000000000000 @0 @SP
00010: 1111110111101000 AM=M+1
AM=M+1
A=A-1
M=D
// push static 6

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 6/15
bin/simulator
The bin/simulator program will attempt to execute each VM command’s implementation to see if it works. After executing a command’s implementation, checks are made to ensure that only the correct memory locations were read, that the correct values were written to the correct memory locations and that the final program counter value is correct. In some cases a command’s implementation may be executed several times unless it fails. If a command fails or makes too many changes to memory, the simulator will reinitialise itself before the next test. A random number generator is used so that not all tests are quite the same.
00011: 1110110010100000
00012: 1110001100001000
STOPVM push static 6
A=A-1 M=D
// add
STRTVM add
00013:
00013: 0000000000000000 @0
00014: 1111110010101000
00015: 1111110000010000
00016: 1110110010100000
00017: 1111000010001000
STOPVM add
@SP
AM=M-1
D=M
A=A-1
M=D+M
STRT CLEANUP
STRT EXECUTION STOP
00018:
00018: 0000000000010010 @18 @Silly..end
00019: 1110101010000111 0;JMP
00020: (Silly..return)
00020: 0000000000010100 @20
00021: 1110101010000111
STOP EXECUTION STOP
STRT EXTERNALS
STOP EXTERNALS
STOP CLEANUP
STOP CLASS
@Silly..return
0;JMP
(Silly..end)

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
The full output from the simulator shows a before and after section for the VM command showing you what should happen. This is followed by an instruction by instruction trace of the execution of the implementation. In both cases only memory locations relevant to the command are shown.
Here is the full output from simulating the example:
% cat question01.vm-asm | bin/assembler | bin/simulator
SIM: Starting Testing of VM Class
SIM: Initialising the Hack Computer
SIM: Simulation of VM command function Silly.func 0
HVM: ———————
HVM: function Silly.func 0
HVM: ———————
HVM:
HVM:
HVM:
HVM: ———————
CPU: —————————-
CPU: PC | Assembly Language
CPU: —————————-
CPU: 0 | executed 0 instructions
CPU: —————————-
SIM: Simulation of VM command was successul!
SIM: Simulation of VM command push constant 5
HVM: ——————————-
HVM: push constant 5 | SP | RAM[sp]
HVM: ——————————-
address
before
after
HVM:
HVM:
HVM:
HVM: ——————————-
CPU: ———————————————————————————————
CPU: PC | Binary | A | RAM[A] | D | ALU | A’ | RAM[A]’ | D’ | Assembly Language
CPU: ———————————————————————————————
address | 0 | 631
before | 631 | .
after | 632 | 5
CPU: 1 | 0000000000000101 |
CPU: 2 | 1110110000010000 |
CPU: 3 | 0000000000000000 |
CPU: 4 | 1111110111101000 |
. | 5 | . | 0 |
. | . |
. | . |
. | . |
. | 5 | . |
5 | . | 0 |
. | . | . |
632 |
. | @5 // @5
5 | D=A
. | @0 // @SP
. | AM=M+1
631 | . | 632 | 632 |
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 7/15

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 8/15
CPU: 5| 1110110010100000 | 632 |. |. | 631 | 631 |
CPU: 6| 1110001100001000 | 631 |. |5 | 5 | . |
CPU: 7| | | | | | |
CPU: ——————————————————————————————— SIM: Simulation of VM command was successul!
SIM: Simulation of VM command push static 6
HVM: —————————————-
HVM: push static 6 | SP | static 6 | RAM[sp]
HVM: —————————————-
HVM:
HVM:
HVM:
HVM: —————————————-
CPU: ————————————————————————————————
CPU: PC | Binary | A | RAM[A] | D | ALU | A’ | RAM[A]’ | D’ | Assembly Language
CPU: ————————————————————————————————
address | 0 |
before | 632 |
after | 633 |
22 | 632
935 | .
. | 935
CPU: 7| 0000000000010110 |
CPU: 8| 1111110000010000 |
CPU: 9| 0000000000000000 |
CPU: 10 | 1111110111101000 |
CPU: 11 | 1110110010100000 | 633 |
CPU: 12 | 1110001100001000 | 632 |
CPU: 13 | | |
CPU: ———————————————————————————————— SIM: Simulation of VM command was successul!
SIM: Simulation of VM command add
HVM: ————————————-
HVM: add | SP | RAM[sp-2] | RAM[sp-1]
HVM: ————————————-
CPU: 13 | 0000000000000000 | . |
CPU: 14 | 1111110010101000 | 0 |
CPU: 15 | 1111110000010000 | 632 |
.| . | . | 0 | 633 | . | 632 | 632 | 935 | . | 935 | . |
. | . | @0 // @SP
632 | . | AM=M-1
. | 935 | D=M
. | 22 | . | 0 |
. |
935 |
. |
632 |
. |
. | . | . |
. | @22
935 | D=M
631 | 632
5 | 935
940 | .
. | . |
. | 935 |
. | . |
. | 633 | 633 |
. | 632 | 632 |
. | 935 | 935 | . |
| | | |
633 | . | 935 | |
| executed 6 instructions
HVM: address | 0 |
HVM: before | 633 |
HVM: after | 632 |
HVM: ————————————-
CPU: ————————————————————————————————
CPU: PC | Binary | A | RAM[A] | D | ALU | A’ | RAM[A]’ | D’ | Assembly Language
CPU: ————————————————————————————————
22 | . | 0 |
. | @0
. | AM=M+1
. | A=A-1
. | M=D
// @Silly.6
// @SP
. | . | A=A-1
5 | . | M=D
| | executed 6 instructions

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 9/15
CPU: 16 | 1110110010100000 | 632 |
CPU: 17 | 1111000010001000 | 631 |
CPU: 18 | | |
CPU: ————————————————————————————————
SIM: Simulation of VM command was successul!
SIM: Simulation of VM command add
HVM: ————————————-
HVM: add | SP | RAM[sp-2] | RAM[sp-1]
HVM: ————————————-
. |. | 631 | 631 | 5 | 935 | 940 | . | | | | |
. | 940 | |
. | A=A-1
. | M=D+M
HVM: address | 0 |
HVM: before | 632 |
HVM: after | 631 |
HVM: ————————————-
CPU: ————————————————————————————————-
CPU: PC | Binary | A | RAM[A] | D | ALU | A’ | RAM[A]’ | D’ | Assembly Language
CPU: ————————————————————————————————-
630 | 631
2190 | 940
3130 | .
CPU: 13 | 0000000000000000 | . |
CPU: 14 | 1111110010101000 | 0 |
CPU: 15 | 1111110000010000 | 631 |
CPU: 16 | 1110110010100000 | 631 |
CPU: 17 | 1111000010001000 | 630 |
CPU: 18 | | |
CPU: ————————————————————————————————-
SIM: Simulation of VM command was successul!
SIM: Simulation of VM command add
HVM: ————————————-
HVM: add | SP | RAM[sp-2] | RAM[sp-1]
HVM: ————————————-
. |
632 |
940 |
. |
. | . | . | . |
. | 0 |
631 | 631 |
940 | . |
630 | 630 |
. | . | @0 // @SP
631 | . | AM=M-1
2190 | 940 | 3130 | . |
| | | |
. | 3130 | |
. | A=A-1
. | M=D+M
HVM: address | 0 |
HVM: before | 631 |
HVM: after | 630 |
HVM: ————————————-
CPU: —————————————————————————————————
CPU: PC | Binary | A | RAM[A] | D | ALU | A’ | RAM[A]’ | D’ | Assembly Language
CPU: —————————————————————————————————
629 | 630
2148 | 3130
5278 | .
CPU: 13 | 0000000000000000 | .| . | . | . | 0 | CPU: 14 | 1111110010101000 | 0 | 631 | . | 630 | 630 | CPU: 15 | 1111110000010000 | 630 | 3130 | . | 3130 | . | CPU: 16 | 1110110010100000 | 630 | . | . | 629 | 629 |
. | . | @0 // @SP
630 | . | AM=M-1
. | 3130 | D=M
. | . | A=A-1
. | 940 | D=M
| executed 5 instructions
| executed 5 instructions

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 10/15
You can turn off most of this output by setting the following environment variables to iob_disable:
CPU: 17 | 1111000010001000 | 629 | 2148 | 3130 | 5278 | . | 5278 | . | M=D+M
CPU: 18 | | | | | | | | | executed 5 instructions
CPU: —————————————————————————————————
SIM: Simulation of VM command was successul!
SIM: Simulation of VM command add
HVM: ————————————-
HVM: add | SP | RAM[sp-2] | RAM[sp-1]
HVM: ————————————-
HVM: address | 0 |
HVM: before | 630 |
HVM: after | 629 |
HVM: ————————————-
CPU: —————————————————————————————————
CPU: PC | Binary | A | RAM[A] | D | ALU | A’ | RAM[A]’ | D’ | Assembly Language
CPU: —————————————————————————————————
CPU: 13 | 0000000000000000 | . |
CPU: 14 | 1111110010101000 | 0 |
CPU: 15 | 1111110000010000 | 629 |
CPU: 16 | 1110110010100000 | 629 |
CPU: 17 | 1111000010001000 | 628 |
CPU: 18 | | |
CPU: —————————————————————————————————
SIM: Simulation of VM command was successul!
|———————————————————————————-|
| | | | Instructions Executed | Implementation Sizes |
| VM Commands | Tests | Passed | Min | Max | Total | Min | Max | Total |
|———————————————————————————-|
628 | 629
612 | 5278
5890 | .
. |
630 |
5278 |
. |
. | . | 0 |
. | 629 | 629 |
. | 5278 | . |
. | 628 | 628 |
. | . | @0 // @SP
629 | . | AM=M-1
612 | 5278 | 5890 | . |
| | | |
. | 5890 | |
. | A=A-1
. | M=D+M
| add |
| function f 0 |
| push constant 2+ |
| push static 2+ |
|———————————————————————————-|
| Totals | 4 | 4 | 17 | 17 |
|———————————————————————————-|
1 | 1 | 1 | 1 |
1| 5 | 5| 1| 0 | 0| 1| 6 | 6| 1| 6 | 6|
5 | 5 | 5 |
0 | 0 | 0 |
6 | 6 | 6 |
6 | 6 | 6 |
5 | 0 | 6 | 6 |
. | 5278 | D=M
| executed 5 instructions
% export CSTOOLS_IOBUFFER_TRACES=iob_disable
% export CSTOOLS_IOBUFFER_LOGS=iob_disable

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
This will reduce the final output to:
|———————————–| | VM Commands | Tests | Passed | |———————————–| | add | 1| 1| | function f 0 | 1| 1| | push constant 2+ | 1| 1| | push static 2+ | 1| 1| |———————————–| | Totals | 4 | 4 | |———————————–|
Wring Assembler
Writing Hack Assembly language to implement the Hack Virtual Machine can be greatly simplified by making a few observations about the common components of the virtual machine commands.
For example, lots of command need to either push a value onto the stack or pop one off, so you could write yourself a sequence of instructions that push or pop a value to / from register D. Every time you need to push or pop a value just copy-paste your instruction sequence.
The add, sub, and, or, eq, lt and gt commands all replace the top two elements on the stack with a result. The first four instructions for each these could be those in the example above. That would leave the address of the left operand in register A and the value of the right operand in register D. So again, once you have written yourself an appropriate sequence of instructions, you can copy-paste whenever it is required.
Push and pop commands both involve two steps, calculate the address of the part of the segment to read or write and either a push or pop operation. In the general case, the address calculation will need to use both the A and D registers which is a problem for a pop command. A good approach is to calculate the address then save it into a temporary memory location until it is needed. You can safely use memory locations 13, 14 and 15 because these three locations cannot be referenced by any virtual machine commands.
Automac Tesng
You can automatically test your implementations of the VM commands in all of the question*.vm-asm files using the following command:
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 11/15

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
If a test fails you can cut-paste the relevant commands that are printed and run the test yourself. You will then get to see the actual output from the simulator rather than just passed / failed.
Manual Tesng
To manually test your implementation of a VM command, you can run the bin/assembler and bin/simulator programs in a pipe: % bin/assembler | bin/simulator
The first line of input you type is expected to be a VM command. All the following lines up to the first blank line or the end of input are expected to be the Hack Assembler that implements the command. When you have finished entering commands and assembler the simulator will test your implementation. For example, here is how an implementation of the add command might look if you type control-D after entering the M=D+M instruction:
% make
% bin/assembler | bin/simulator
add
@SP
AM=M-1
D=M
A=A-1
M=D+M
SIM: Starting Testing of VM Class
SIM: Initialising the Hack Computer
SIM: Simulation of VM command add
HVM: ————————————-
HVM: add | SP | RAM[sp-2] | RAM[sp-1]
HVM: ————————————-
HVM: address | 0 |
HVM: before | 836 |
HVM: after | 835 |
HVM: ————————————-
CPU: ————————————————————————————————
CPU: PC | Binary | A | RAM[A] | D | ALU | A’ | RAM[A]’ | D’ | Assembly Language
834 | 835
90 | 262
352 | .
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 12/15

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 13/15
CPU: ————————————————————————————————
CPU: 0|
CPU: 1|
CPU: 2|
CPU: 3|
CPU: 4|
CPU: 5|
CPU: ———————————————————————————————— SIM: Simulation of VM command was successul!
SIM: Simulation of VM command add
HVM: ————————————-
HVM: add | SP | RAM[sp-2] | RAM[sp-1]
HVM: ————————————-
0000000000000000
1111110010101000
1111110000010000
1110110010100000
1111000010001000
| . |
| 0 |
| 835 |
| 835 |
| 834 |
| |
. |
836 |
262 |
. |
90 |
|
. | . | . | . |
262 | |
. |
835 |
262 |
834 |
352 |
|
0 |
835 |
. |
834 |
. |
|
. |
835 |
. |
. |
352 |
|
.
. 262 . .
| @0 // @SP
| AM=M-1
| D=M
| A=A-1
HVM: address | 0 |
HVM: before | 835 |
HVM: after | 834 |
HVM: ————————————-
CPU: ————————————————————————————————
CPU: PC | Binary | A | RAM[A] | D | ALU | A’ | RAM[A]’ | D’ | Assembly Language
CPU: ————————————————————————————————
833 | 834
118 | 352
470 | .
CPU: 0|
CPU: 1|
CPU: 2|
CPU: 3|
CPU: 4|
CPU: 5|
CPU: ———————————————————————————————— SIM: Simulation of VM command was successul!
SIM: Simulation of VM command add
HVM: ————————————-
HVM: add | SP | RAM[sp-2] | RAM[sp-1]
HVM: ————————————-
0000000000000000
1111110010101000
1111110000010000
1110110010100000
1111000010001000
| . |
| 0 |
| 834 |
| 834 |
| 833 |
| |
. |
835 |
352 |
. |
118 |
|
. | . | . | . |
352 | |
. |
834 |
352 |
833 |
470 |
|
0 |
834 |
. |
833 |
. |
|
. |
834 |
. |
. |
470 |
|
.
. 352 . .
| @0 // @SP
| AM=M-1
| D=M
| A=A-1
HVM: address | 0 |
HVM: before | 834 |
HVM: after | 833 |
HVM: ————————————-
CPU: ——————————————————————————————————
CPU: PC | Binary | A | RAM[A] | D | ALU | A’ | RAM[A]’ | D’ | Assembly Language
CPU: ——————————————————————————————————
832 | 833
-2000 | 32767
30767 | .
| M=D+M
| executed 5 instructions
| M=D+M
| executed 5 instructions

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 14/15
Startup Files
CPU: 0|
CPU: 1|
CPU: 2|
CPU: 3|
CPU: 4|
CPU: 5|
CPU: —————————————————————————————————— SIM: Simulation of VM command was successul!
SIM: Simulation of VM command add
HVM: ————————————-
HVM: add | SP | RAM[sp-2] | RAM[sp-1]
HVM: ————————————-
0000000000000000
1111110010101000
1111110000010000
1110110010100000
1111000010001000
| . |
| 0 |
| 833 |
| 833 |
| 832 |
| |
. |
834 |
32767 |
. |
-2000 |
|
. | . | . | . |
32767 | |
. |
833 |
32767 |
832 |
30767 |
|
0 |
833 |
. |
832 |
. |
|
. |
833 |
. |
. |
30767 |
|
.
| @0 // @SP
| AM=M-1
| D=M
| A=A-1
0000000000000000
1111110010101000
1111110000010000
1110110010100000
1111000010001000
| . |
| 0 |
| 832 |
| 832 |
| 831 |
| |
. |
833 |
-2000 |
. |
32767 |
|
. | . | . | . |
-2000 | |
. |
832 |
-2000 |
831 |
30767 |
|
0 |
832 |
. |
831 |
. |
|
. |
832 |
. |
. |
30767 |
|
.
| @0 // @SP
| AM=M-1
| D=M
| A=A-1
831 | 832
32767 | -2000
30767 | .
HVM: address | 0 |
HVM: before | 833 |
HVM: after | 832 |
HVM: ————————————-
CPU: ——————————————————————————————————
CPU: PC | Binary | A | RAM[A] | D | ALU | A’ | RAM[A]’ | D’ | Assembly Language
CPU: ——————————————————————————————————
CPU: 0|
CPU: 1|
CPU: 2|
CPU: 3|
CPU: 4|
CPU: 5|
CPU: —————————————————————————————————— SIM: Simulation of VM command was successul! |———————————————————————————-|
| | | | Instructions Executed | Implementation Sizes |
| VM Commands | Tests | Passed | Min | Max | Total | Min | Max | Total |
|———————————————————————————-|
| add | 1 | 1 | 5 | 5 | 5 | 5 | 5 | 5 |
|———————————————————————————-|
| Totals | 1 | 1 | 5 | 5 |
|———————————————————————————-|
. 32767 . .
| M=D+M
| executed 5 instructions
. -2000 . .
| M=D+M
| executed 5 instructions

2020/10/10 Workshop 07 – Virtual Machine Translation: Computer Systems (2000_7081 Combined)
The newest of the following zip file(s) must be placed in the updates sub-directory and added to svn. When make is run, the newest zip file in the updates directory is used to update the startup files. Any files you are required to edit will not be updated but, a copy of the latest version of those files will be placed in the sub-directory originals.
workshop07-20200923-120407.zip (https://myuni.adelaide.edu.au/courses/54311/files/7490704/download?wrap=1)
https://myuni.adelaide.edu.au/courses/54311/pages/workshop-07-virtual-machine-translation 15/15