- •Course project handbook on “Programming” Donetsk, DonNtu, 2012
- •Contents
- •Introduction
- •1 Technical task
- •Technical task
- •2 Analyses of virtual computer
- •2.1 General architecture
- •2.2 Memory organizations. Data formats. Addressing modes
- •3 Programming in code of virtual computer
- •3.1 Programming in code of One-address Virtual Computer
- •3.2 Programming in code of Two-address Virtual Computer
- •3.3 Programming in code of Three-address Virtual Computer
- •4 Simulation program developing
- •4.3 Alu simulation and visualization
- •Void alu(int cop)
- •Appendix a general requests to the reports’ preparing
- •1. Program documentation
- •1.2. Programmer’s Manual
- •Formal report example
- •Title Page example
Title Page example
Ministry of science and education of Ukraine Donetsk National Technical University
English Engineering Faculty
Explanatory note for the Course Project «Simulation of virtual computer” on the course «Programming»
Developer: _El Alami Imad_ Student of KIA-11 group
Supervisor: R.V. Malcheva Prof. of Computer Engineering Department
Donetsk - 2012
|
Appendix C
THE STRUCTURES AND INSTRUCTIONS’ SETS OF VC
Table A.1 - Instruction System of VC A1
Operation code |
Command name |
Indications |
Commands execution | |||
|
|
S |
Z |
P |
E |
|
0000 |
Stop |
|
|
|
|
|
0001 |
Subroutine call |
– |
– |
– |
– |
(SAK) RAM(0); AexSAK |
0010 |
Return from subroutine |
– |
– |
– |
– |
(RAM(0))SAK |
0011 |
Loading |
– |
– |
– |
– |
(Aex)AC |
0100 |
Writing |
– |
– |
– |
– |
(AC) Aex |
0101 |
Unconditional jump |
– |
– |
– |
– |
AexSAK |
0110 |
Conditional jump by P |
– |
– |
– |
– |
AexSAK, if P = 1 |
0111 |
Conditional jump by Z |
– |
– |
– |
– |
AexSAK, if Z = 1 |
1000 |
Conditional jump by S |
– |
– |
– |
– |
AexSAK, if S = 1 |
1001 |
Disjunction |
+ |
+ |
+ |
– |
(AC) v (Aex)AC |
1010 |
Modulo 2 sum |
+ |
+ |
+ |
– |
(AC) (Aex)AC |
1011 |
Conjunction |
+ |
+ |
+ |
– |
(AC) & (Aex)AC |
1100 |
Shift to the right |
+ |
+ |
+ |
– |
(AC) |
1101 |
Shift to the left |
+ |
+ |
+ |
– |
(AC) |
1110 |
Addition |
+ |
+ |
+ |
+ |
(AC) + (Aex)AC |
1111 |
Multiplication |
+ |
+ |
+ |
+ |
(AC) * (Aex)AC |
Table A.2 - Instruction System of VC A2
Operation code |
Command name |
Indications |
Commands execution | ||
|
|
S |
Z |
C |
|
0000 |
Stop |
– |
– |
– |
|
0001 |
Return from subroutine |
– |
– |
– |
(RAM(8)) SAK |
0010 |
Subroutine call |
– |
– |
– |
(SAK) RAM(8); AexSAK |
0011 |
Loading |
– |
– |
– |
(Aex)AC |
0100 |
Writing |
– |
– |
– |
(AC) Aex |
0101 |
Addition |
+ |
+ |
+ |
|
0110 |
Subtraction |
+ |
+ |
+ |
|
0111 |
Multiplication |
+ |
+ |
+ |
(AC)(Aex)AC |
1000 |
Division |
+ |
+ |
+ |
|
1001 |
Disjunction |
+ |
+ |
– |
|
1010 |
Shift to the right |
+ |
+ |
– |
(AC) |
1011 |
Shift to the left |
+ |
+ |
– |
(AC) |
1100 |
Conditional jump by C |
– |
– |
– |
AexSAK, if C = 1 |
1101 |
Conditional jump by Z |
– |
– |
– |
AexSAK, if Z = 1 |
1110 |
Conditional jump by S |
– |
– |
– |
AexSAK, if S = 1 |
1111 |
Unconditional jump |
– |
– |
– |
AexSAK |
Table A.3 - Instruction System of VC B1
Operation code |
Command name |
Indications |
Commands execution | |||
|
|
S |
Z |
C |
E |
|
0000 |
Stop |
– |
– |
– |
– |
|
0001 |
Addition |
+ |
+ |
+ |
– |
(AC) + (Aex)AC |
0010 |
Subtraction |
+ |
+ |
+ |
– |
(AC) – (Aex)AC |
0011 |
Multiplication |
+ |
+ |
+ |
– |
(AC) * (Aex)AC |
0100 |
Division |
+ |
+ |
+ |
– |
(AC) / (Aex)AC |
0101 |
Subtraction of modulus |
+ |
+ |
+ |
– |
|(AC)| – |(Aex)|AC |
0110 |
Subroutine call |
– |
– |
– |
– |
(SAK) 16; Aex SAK |
0111 |
Conjunction |
+ |
+ |
– |
– |
(AC) & (Aex)AC |
1000 |
Return from subroutine |
– |
– |
– |
– |
(16) SAK |
1001 |
Logical shift to the right |
+ |
+ |
– |
– |
(AC)
|
1010 |
End of cycle |
– |
– |
– |
+ |
See in the text |
1011 |
Loading |
+ |
+ |
– |
– |
(Aex) AC |
1100 |
Writing to memory |
– |
– |
– |
– |
(AC) Aex |
1101 |
Unconditional jump |
– |
– |
– |
– |
AexSAK |
1110 |
Jump if (AC) < 0 |
– |
– |
– |
– |
AexSAK, if S=1 |
1111 |
Jump if (AC) = 0 |
– |
– |
– |
– |
AexSAK, if Z=1 |
Table A.4 - Instruction System of VC B2
Operation code |
Command name |
Indications |
Commands execution | |||
|
|
S |
Z |
C |
E |
|
0000 |
Stop |
– |
– |
– |
– |
|
0001 |
Subroutine call |
– |
– |
– |
– |
(SAK) RAM(8); AexSAK |
0010 |
Return from subroutine |
– |
– |
– |
– |
(RAM(8)) SAK |
0011 |
Loading |
+ |
+ |
– |
– |
(Aex)AC |
0100 |
Writing |
– |
– |
– |
– |
(AC) Aex |
0101 |
Shift to the left |
+ |
+ |
– |
– |
(AC) |
0110 |
Shift to the right |
+ |
+ |
– |
– |
(AC) |
0111 |
Addition |
+ |
+ |
+ |
+ |
(AC) + (Aex)AC |
1000 |
Subtraction |
+ |
+ |
+ |
+ |
(AC) – (Aex)AC |
1001 |
Conjunction |
+ |
+ |
– |
– |
(AC) & (Aex)AC |
1010 |
Disjunction |
+ |
+ |
– |
– |
(AC) v (Aex)AC |
1011 |
Conditional jump by S |
– |
– |
– |
– |
AexSAK, if S = 1 |
1100 |
Conditional jump by Z |
– |
– |
– |
– |
AexSAK, if Z = 1 |
1101 |
Unconditional jump |
– |
– |
– |
– |
AexSAK |
1110 |
Increment of location |
– |
– |
– |
+ |
1) (Aex )+1Aex 2) (Aex) = 0 => ignoring next command |
1111 |
Modulo 2 sum |
+ |
+ |
– |
– |
(AC) (Aex)AC |
Table A.5 - Instruction System of VC C1
Operation code |
Command name |
Indications |
Commands execution | |||
|
|
S |
Z |
C |
E |
|
0000 |
Stop |
– |
– |
– |
– |
|
0001 |
End of cycle |
– |
– |
– |
+ |
See description |
0010 |
Transfer |
– |
– |
– |
– |
(A1ex)A2ex |
0011 |
Return from subroutine |
– |
– |
– |
– |
(A2ex)SAK |
0100 |
Conditional jump by S and Z |
– |
– |
– |
– |
See description |
0101 |
Conditional jump by C |
– |
– |
– |
– |
See description |
0110 |
Unconditional jump |
– |
– |
– |
– |
A1exSAK |
0111 |
Subroutine call |
– |
– |
– |
– |
(SAK) A2;A1SAK |
1000 |
Addition |
+ |
+ |
+ |
– |
MK = 00; |
1001 |
Subtraction |
+ |
+ |
+ |
– |
(A1ex)(A2ex)AC, A2ex |
1010 |
Multiplication |
+ |
+ |
+ |
– |
MK = 01; |
1011 |
Division |
+ |
+ |
+ |
– |
(A1ex)(A2ex)AC |
1100 |
Subtraction of modulus |
+ |
+ |
– |
– |
MK = 10; |
1101 |
Modulo 2 sum |
+ |
+ |
– |
– |
(A1ex)(AC)AC,A2ex |
1110 |
Conjunction |
+ |
+ |
– |
– |
MK = 11; |
1111 |
Disjunction |
+ |
+ |
– |
– |
(A1ex)(A2ex)AC |
Table A.6 - Instruction System of VC C2
Operation code |
Command name |
Indications |
Commands execution | |||
|
|
S |
Z |
C |
E |
|
0000 |
Stop |
– |
– |
– |
– |
|
0001 |
Addition |
+ |
+ |
+ |
– |
|
0010 |
Subtraction |
+ |
+ |
+ |
– |
|
0011 |
Multiplication |
+ |
+ |
+ |
– |
(A1ex)(A2ex)A3ex |
0100 |
Division |
+ |
+ |
+ |
– |
|
0101 |
Subtraction of modulus |
+ |
+ |
– |
– |
|
0110 |
Writing of scratch pad memory |
– |
– |
– |
– |
(M) A1 |
0111 |
Loading of scratch pad memory |
– |
– |
– |
– |
(A1) M |
1000 |
Logical shift to the right |
+ |
+ |
– |
– |
(A1ex)A3ex |
1001 |
Conjunction |
+ |
+ |
– |
– |
(A1ex)(A2ex)A3ex |
1010 |
Disjunction |
+ |
+ |
– |
– |
|
1011 |
Return from subroutine |
– |
– |
– |
– |
(A3ex)SAK |
1100 |
Subroutine call |
– |
– |
– |
– |
(SAK) A3ex; A1exSAK |
1101 |
Conditional jump |
– |
– |
– |
– |
See description |
1110 |
Unconditional jump |
– |
– |
– |
– |
A1exSAK |
1111 |
End of cycle |
– |
– |
– |
+ |
See description |
Table A.7 - Instruction System of VC D1
Operation code |
Command name |
Indications |
Commands execution | |||
|
|
< 0 |
> 0 |
= 0 |
OF |
|
0000 |
Stop |
– |
– |
– |
– |
|
0001 |
Accumulator loading |
+ |
+ |
+ |
– |
(Aex)AC |
0010 |
Accumulator storing |
– |
– |
– |
– |
(AC) Aex |
0011 |
Addition |
+ |
+ |
+ |
+ |
(AC) + (Aex)AC |
0100 |
Subtraction |
+ |
+ |
+ |
+ |
(AC) – (Aex)AC |
0101 |
Multiplication |
+ |
+ |
+ |
+ |
(AC) * (Aex)AC |
0110 |
Division |
+ |
+ |
+ |
+ |
(AC) / (Aex)AC |
0111 |
Conjunction |
+ |
+ |
+ |
– |
(AC) & (Aex)AC |
1000 |
Disjunction |
+ |
+ |
+ |
– |
(AC) v (Aex)AC |
1001 |
Subroutine call |
– |
– |
– |
– |
(SAK) 16;AexSAK |
1010 |
Logical shift to the right |
+ |
+ |
+ |
– |
(AC) |
1011 |
Logical shift to the left |
+ |
+ |
+ |
– |
(AC) |
1100 |
Jump |
– |
– |
– |
– |
See description |
1101 |
Comparison |
+ |
+ |
+ |
– |
(AC) >< (Aex) => RP |
1110 |
Loading |
– |
– |
– |
– |
(Aex)XR |
1111 |
Increment |
– |
– |
– |
– |
(XR) + 1 Aex |
Table A.8 - Instruction System of VC D2
Operation code |
Command name |
Indications |
Commands execution | |||
|
|
S |
Z |
C |
E |
|
0000 |
Stop |
– |
– |
– |
– |
|
0001 |
Addition |
+ |
+ |
+ |
– |
|
0010 |
Subtraction |
+ |
+ |
+ |
– |
(AC)(Aex)AC |
0011 |
Multiplication |
+ |
+ |
+ |
– |
|
0100 |
Division |
+ |
+ |
+ |
– |
|
0101 |
Return from subroutine |
– |
– |
– |
– |
(16) SAK |
0110 |
Modulo 2 sum |
+ |
+ |
– |
– |
(AC)(Aex)AC |
0111 |
Accumulator loading |
+ |
+ |
– |
– |
(Aex)AC |
1000 |
Writing to memory |
– |
– |
– |
– |
(Aex)AC |
1001 |
Modificator loading |
– |
– |
– |
– |
(A) M |
1010 |
Modificator writing |
– |
– |
– |
– |
(M) A |
1011 |
Subroutine call |
– |
– |
– |
– |
(SAK) 16;AexSAK |
1100 |
End of cycle |
– |
– |
– |
– |
See description |
1101 |
Unconditional jump |
– |
– |
– |
– |
AexSAK |
1110 |
Conditional jump by Z |
– |
– |
– |
– |
Aex SAK, if Z = 1 |
1111 |
Conditional jump by S |
– |
– |
– |
– |
AexSAK, if S = 1 |
Table A.9 - Instruction System of VC F1
Operation code |
Command name |
Indications |
Commands execution | ||
|
|
S |
Z |
C |
|
0000 |
Stop |
– |
– |
– |
|
0001 |
Unconditional jump |
– |
– |
– |
A1 SAK |
0010 |
Conditional jump by S and Z |
– |
– |
– |
See description |
0011 |
Conditional jump by C |
– |
– |
– |
See description |
0100 |
Transfer |
+ |
+ |
0 |
(A1) A2 |
0101 |
Addition |
+ |
+ |
+ |
M = 00; |
0110 |
Subtraction |
+ |
+ |
+ |
(A1) (A2)AC, A2 |
0111 |
Multiplication |
+ |
+ |
+ |
M = 01; |
1000 |
Division |
+ |
+ |
+ |
(A1) (A2)AC |
1001 |
Subtraction of modulus |
+ |
+ |
+ |
M = 10; |
1010 |
Modulo 2 sum |
+ |
+ |
0 |
(A1) (AC)AC, A2 |
1011 |
Logical shift to the right |
+ |
+ |
0 |
M = 11; |
1100 |
Arithmetic shift to the right |
+ |
+ |
0 |
(A1) (AC)AC |
1101 |
Conjunction |
+ |
+ |
0 |
|
1110 |
Return from subroutine |
– |
– |
– |
(A2) SAK |
1111 |
Subroutine call |
– |
– |
0 |
(SAK) A2;A1SAK |
Table A.10 - Instruction System of VC F2
Operation code |
Command name |
Indications |
Commands execution | |||
|
|
S |
Z |
C |
E |
|
0000 |
Stop |
– |
– |
– |
– |
|
0001 |
Addition |
+ |
+ |
+ |
– |
(A1ex) + (A2ex)A3ex |
0010 |
Subtraction |
+ |
+ |
+ |
– |
(A1ex) – (A2ex)A3ex |
0011 |
Multiplication |
+ |
+ |
+ |
– |
(A1ex) * (A2ex)A3ex |
0100 |
Division |
+ |
+ |
+ |
– |
(A1ex) / (A2ex)A3ex |
0101 |
Conjunction |
+ |
+ |
– |
– |
(A1ex) & (A2ex)A3ex |
0110 |
Disjunction |
+ |
+ |
– |
– |
(A1ex) v (A2ex)A3ex |
0111 |
Negation |
+ |
+ |
– |
– |
¬ (A1ex)A3ex |
1000 |
Subtraction of modulus |
+ |
+ |
+ |
– |
|(A1ex)| – |(A2ex)|A3ex |
1001 |
Modulo 2 sum |
+ |
+ |
– |
– |
(A1ex)(A2ex)A3ex |
1010 |
Logical shift to the right |
+ |
+ |
– |
– |
(A1ex); 0A3ex |
1011 |
Subroutine call |
– |
– |
– |
– |
(SAK) A3ex; A1ex SAK |
1100 |
Conditional jump |
– |
– |
– |
– |
See description |
1101 |
Unconditional jump |
– |
– |
– |
– |
A1ex |
1110 |
End of cycle |
– |
– |
– |
+ |
See text |
1111 |
Return from subroutine |
– |
– |
– |
– |
(A3ex)SAK |
Table A.11 - Instruction System of VC G1
Operation code |
Command name |
Indications |
Commands execution | |||
|
|
< 0 |
> 0 |
= 0 |
OF |
|
0000 |
Stop |
|
|
|
|
|
0001 |
Transfer to the left |
– |
– |
– |
– |
(A2ex)A1ex |
0010 |
Transfer to the right |
– |
– |
– |
– |
(A1ex)A2ex |
0011 |
Addition |
+ |
+ |
+ |
+ |
(A1ex) + (A2ex)A1ex |
0100 |
Subtraction |
+ |
+ |
+ |
+ |
(A1ex) – (A2ex)A1ex |
0101 |
Multiplication |
+ |
+ |
+ |
+ |
(A1ex) * (Aex2)A1ex |
0110 |
Division |
+ |
+ |
+ |
+ |
(A1ex) / (A2ex)A1ex |
0111 |
Conjunction |
+ |
+ |
+ |
– |
(A1ex) & (A2ex)A1ex |
1000 |
Disjunction |
+ |
+ |
+ |
– |
(A1ex) v (A2ex)A1ex |
1001 |
Modulo 2 sum |
+ |
+ |
+ |
– |
(A1ex)(A2ex)A1ex |
1010 |
Logical shift to the right |
+ |
+ |
+ |
– |
(A1ex) |
1011 |
Logical shift to the left |
+ |
+ |
+ |
– |
(A1ex) |
1100 |
Jump |
– |
– |
– |
– |
See description |
1101 |
Comparison |
+ |
+ |
+ |
– |
(A1ex) >< (A2ex) => RP |
1110 |
Subroutine call |
– |
– |
– |
– |
(SAK) A1ex; A2ex SAK |
1111 |
Return from subroutine |
– |
– |
– |
– |
(A1ex)SAK |
Table A.12 - Instruction System of VC G2
Operation code |
Command name |
Indications |
Commands execution | |||
|
|
S |
Z |
C |
E |
|
0000 |
No operation |
– |
– |
– |
– |
|
0001 |
Stop |
– |
– |
– |
– |
|
0010 |
Loading |
– |
– |
– |
– |
(Aex)AC* |
0011 |
Writing |
– |
– |
– |
– |
(AC) Aex |
0100 |
Negation |
+ |
+ |
– |
– |
()AC |
0101 |
Disjunction |
+ |
+ |
– |
– |
|
0110 |
Conjunction |
+ |
+ |
– |
– |
|
0111 |
Addition |
+ |
+ |
+ |
– |
(AC)(Aex)AC |
1000 |
Multiplication |
+ |
+ |
+ |
– |
|
1001 |
Division |
+ |
+ |
+ |
– |
|
1010 |
Modulo 2 sum |
+ |
+ |
– |
– |
|
1011 |
Conditional jump by S |
– |
– |
– |
– |
AexSAK, if S = 1 |
1100 |
Conditional jump by Z |
– |
– |
– |
– |
AexSAK, if Z = 1 |
1101 |
Unconditional jump |
– |
– |
– |
– |
AexSAK |
1110 |
Increment of location |
– |
– |
– |
+ |
1) (Aex )+1Aex 2) (Aex) = 0 => ignoring next command |
1111 |
Subroutine call |
– |
– |
– |
– |
See remark ** |
Remarks: *as accumulator one of the registers RA or RB is used depending on the indication of RR command.
** During subroutine call return address is stored in the first location of the subroutine, that is why the subroutine must begin from the command “no operation”. Control transfer is realized by Aex.