// Data file for Mano Basic Computer bus, name BUS, size 16, inputCount 8 ram, name M, size 4096 16, control Read Write, destination BUS 0 register, name MAR, size 12, control LD INR CLR, destination BUS 1 register, name PC, size 12, control LD INR CLR, destination BUS 2 register, name MBR, size 16, control LD INR CLR, destination BUS 3 register, name AC, size 16, control LD INR CLR, destination BUS 4 // register, name InREG, size 8, control LD INR CLR, destination BUS 5 // register, name OutREG, size 8, control LD INR CLR, destination BUS 6 register, name IR, size 16, control LD , destination BUS 7 register, name SC, size 4 register, name CODE, size 4 //ALU flags: <0, =0, >0 // flag, name L // flag, name E // flag, name G // default is output not busy // setRegister, FGO, 1 // 10: 1234 ABCD // 30: FF01 00AA // 100: 2107 7200 7020 1106 3108 7001 0053 ffe9 0000 // loadRam // 21: 083 7001 7001 // 83: 50 // 50: b8f2 // endLoadRam // // setRegister, INPR, 8c // setRegister, FGI, 0 // setRegister, AC, A937 // setRegister, E, 1 // setRegister, PC, 21 // PCStart, PC, 21 RTLinstructions // Start computer here: s flag letter 00000, s, t 0, SC 0 00001, h, t 0 // start main instruction cycle 00200, f 00000 // regular processing - t0 - t2 10000, f 00200, t 0, MAR < PC, SC ++ 11000, f 10000, t 1, IR < M MAR, PC ++, SC ++ 12000, f 11000, t 2, CODE < IR 12 15, MAR < IR 0 11, SC ++ // instructions: // JnS X 13010, f 12000, t 3, c CODE EQ x0000, MBR < PC, SC ++ 13020, f 13010, t 4, M MAR < MBR, SC ++ 13030, f 13020, t 5, MBR < IR 0 11, SC ++ 13040, f 13030, t 6, AC 1, SC ++ 13050, f 13040, t 7, AC < AC ALU_Add MBR, SC ++ 13060, f 13050, t 8, PC < AC, SC 0, n 200 // Load X 13110, f 12000, t 3, c CODE EQ 1, MBR < M MAR, SC ++ 13120, f 13110, t 4, AC < MBR, SC 0, n 200 // Store X 13210, f 12000, t 3, c CODE EQ 2, MBR < AC, SC ++ 13220, f 13210, t 4, M MAR < MBR, SC 0, n 200 // Add X 13310, f 12000, t 3, c CODE EQ 3, MBR < M MAR, SC ++ 13320, f 13310, t 4, AC < AC ALU_Add MBR, SC 0, n 200 // Subt X 13410, f 12000, t 3, c CODE EQ 4, MBR < M MAR, SC ++ 13420, f 13410, t 4, AC < AC ALU_Sub MBR, SC 0, n 200 // Input 13510, f 12000, t 3, c CODE EQ 5, AC 0 7 < SimulatorInput, SC 0, n 200 // Output 13610, f 12000, t 3, c CODE EQ 6, SimulatorOutput < AC 0 7, SC 0, n 200 // Halt 13710, f 12000, t 3, c CODE EQ 7, SC 0, n 1 // Skipcond bb 13810, f 12000, t 3, c CODE EQ 8, c IR 0 11 EQ 0000, c AC 15 EQ 1, PC ++, SC 0, n 200 13815, f 12000, t 3, c CODE EQ 8, c IR 0 11 EQ 0000, c AC 15 EQ 0, SC 0, n 200 13820, f 12000, t 3, c CODE EQ 8, c IR 0 11 EQ 0400, c AC EQ 0, PC ++, SC 0, n 200 13825, f 12000, t 3, c CODE EQ 8, c IR 0 11 EQ 0400, c AC NE 0, SC 0, n 200 13830, f 12000, t 3, c CODE EQ 8, c IR 0 11 EQ 0800, c AC 15 EQ 0, c AC NE 0, PC ++, SC 0, n 200 13832, f 12000, t 3, c CODE EQ 8, c IR 0 11 EQ 0800, c AC EQ 0, SC 0, n 200 13835, f 12000, t 3, c CODE EQ 8, c IR 0 11 EQ 0800, c AC 15 EQ 1, SC 0, n 200 13850, f 12000, t 3, c CODE EQ 8, SC 0, n 200 // Jump X 13910, f 12000, t 3, c CODE EQ 9, PC < MAR, SC 0, n 200 // Clear 14010, f 12000, t 3, c CODE EQ A, AC 0, SC 0, n 200 // AddI X 14110, f 12000, t 3, c CODE EQ B, MBR < M MAR, SC ++ 14120, f 14110, t 4, MAR < MBR, SC ++ 14130, f 14120, t 5, MBR < M MAR, SC ++ 14140, f 14130, t 6, AC < AC ALU_Add MBR, SC 0, n 200 // JumpI X 14210, f 12000, t 3, c CODE EQ C, MBR < M MAR, SC ++ 14220, f 14210, t 4, PC < MBR, SC 0, n 200 // LoadI X 14310, f 12000, t 3, c CODE EQ D, MBR < M MAR, SC ++ 14320, f 14310, t 4, MAR < MBR, SC ++ 14330, f 14320, t 5, MBR < M MAR, SC ++ 14340, f 14330, t 6, AC < MBR, SC 0, n 200 // StoreI X 14410, f 12000, t 3, c CODE EQ E, MBR < M MAR, SC ++ 14420, f 14410, t 4, MAR < MBR, SC ++ 14430, f 14420, t 5, MBR < AC, SC ++ 14440, f 14430, t 6, M MAR < AC, SC 0, n 200 endInstructions // Start of next instruction state: InstructionCycleStart, 200 assembler word, bytes 2 format, name f1, words 1, fieldCount 0, codeBits 0 15 format, name f2, words 1, fieldCount 1, codeBits 12 15, f1 0 11 value label format, name f3, words 1, fieldCount 2, codeBits 12 15, f2 0 11 value label JnS , f2, 0000 Load , f2, 1000 Store , f2, 2000 Add , f2, 3000 Subt , f2, 4000 Input , f1, 5000 Output , f1, 6000 Halt , f1, 7000 Skipcond, f2, 8000 Jump , f2, 9000 Clear , f1, A000 AddI , f2, B000 JumpI , f2, C000 LoadI , f2, D000 StoreI , f2, E000 endAssembler helpComputer
ComputerSimulator - Marie basic computer HelpThe instructions are defined in Figure 4.7 - MARIE's Full
Instruction Set
Instruction initial processing for all instructions:
| Opcode |
Instruction |
RTN: ticks 3 + |
| 0000 |
JnS
X |
MBR
<-
PC M[MAR] < MBR MBR < X AC < 1 AC < AC + MBR PC < AC |
| 0001 |
Load
X |
MBR
< M[MAR] AC < MBR |
| 0010 |
Store
X |
MBR
< AC M[MAR] < MBR |
| 0011 |
Add
X |
MBR
< M[MAR] AC < AC + MBR |
| 0100 |
Subt
X |
MBR
< M[MAR] AC < AC - MBR |
| 0101 |
Input |
AC
<
InREG |
| 0110 |
Output |
OutREG
<
AC |
| 0111 |
Halt |
|
| 1000 |
Skipcond |
If
IR[11-10]
= 00 AND AC < 0 then PC < PC + 1 If IR[11-10] = 01 AND AC = 0 then PC < PC + 1 If IR[11-10] = 10 AND AC > 0 then PC < PC + 1 |
| 1001 |
Jump
X |
PC
<
MAR |
| 1010 |
Clear |
AC
<
0 |
| 1011 |
AddI
X |
MBR
< M[MAR] MAR < MBR MBR < M[MAR] AC < AC + MBR |
| 1100 |
JumpI
X |
MBR
< M[MAR] PC < MBR |
| 1101 |
LoadI
X |
MBR
< M[MAR] MAR < MBR MBR < M[MAR] AC < MBR |
| 1110 |
StoreI
X |
MBR
< M[MAR] MAR < MBR MBR < AC M MAR < AC |
Load Addr /Load address of first number to be added
Store Next / Store this address as out Next pointer
Load Num / Load the number of items to be added
Subt One / Decrement
Store Ctr / Store this value in Ctr to control looping
Loop, Load Sum / Load the Sum into AC
AddI Next / Add the value pointed to by location Next
Store Sum / Store this sum
Load Next / Load Next
Add One / Increment by one to point to the next address
Store Next / Store in out pointer Next
Load Ctr / Load the loop control variable
Subt One / Subtract one from the loop control variable
Store Ctr / Store the new value in loop control variable
Skipcond 000 / If the control variable <0, skip the next instruction
Jump Loop / Otherwise, go to Loop
Halt / Terminate the program
Addr, HEX 117 / Numbers to be summed start at location 117
Next, HEX 0 / A pointer to the next number to add
Num, DEC 5 / The number of values to add
Sum, DEC 0 / The sum
Ctr, HEX 0 / The loop ccontrol variable
One, DEC 1 / Used to increment and decrement by 1
DEC 10 / The values to be added together
DEC 15
DEC 20
DEC 25
DEC 30
If, Load X / Load the first value
Subt Y / Subtract the value of Y, store the result in AC
Skipcond 400 / If AC = 0, skip the next instruction
Jump Else / Jump to Else part of if AC is not equal to 0
Then, Load X / Reload X so it can be doubled
Add X / Double X
Store X / Store the new value
Jump Endif / Skip over the false, or else, part to end of if
Else, Load Y / Start the else part by loading Y
Subt X / Subtract X from Y
Store Y / Store Y-X in Y
Edif, Halt / Terminate the program
X, DEC 12 / The X value
Y, DEC 20 / The Y value
Getch, LoadI Chptr / Load the character found at address Chptr
Skipcond 400 / if AC=0, skip the next instruction
Jump Outp / Otherwise, proceed with program
Halt / Terminate the program
Outp, Output / Output the character
Load Chptr / Move pointer to next character
Add One /
Store Chptr /
Jump Getch / Process the next character - loop
One, HEX 0001 /
Chptr, HEX String /
String, DEC 072 / H
DEC 101 / e
DEC 108 / l
DEC 108 / l
DEC 111 / o
DEC 032 / " "
DEC 119 / w
DEC 111 / o
DEC 114 / r
DEC 108 / l
DEC 100 / d
DEC 033 / !
DEC 000 / null
Load X / Load the first number to be doubled
Store Temp / Use Temp as a parameter to pass value to Subr
JnS Subr / Store return address, jump to procedure
Store X / Store the first number doubled
Load Y / Load the second number to be doubled
Store Temp / Use Temp as a parameter to pass value to Subr
JnS Subr / Store return address, jump to procedure
Store Y / Store second number, doubled
Halt / End program
X, DEC 20
Y, DEC 48
Temp, DEC 0
Subr, HEX 0 / Store return address here
Load Temp / Subroutine to double numbers
Add Temp
JumpI Subr