Skip to content

Commit 4cbdac0

Browse files
Pretty much comoplete, just division is left
1 parent 35ba4a8 commit 4cbdac0

File tree

21 files changed

+923
-786
lines changed

21 files changed

+923
-786
lines changed
2.21 KB
Binary file not shown.

Assembler/cmake-build-debug/.ninja_log

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,7 @@
2727
1854 1937 1703536641127533671 Assembler 35cca99beb22f557
2828
1 2012 1703684675441054811 CMakeFiles/Assembler.dir/main.cpp.o a0649e1ce8eedca3
2929
2012 2100 1703684675529050080 Assembler 35cca99beb22f557
30+
0 1867 1703853619769087901 CMakeFiles/Assembler.dir/main.cpp.o a0649e1ce8eedca3
31+
1867 1946 1703853619853082172 Assembler 35cca99beb22f557
32+
1 1820 1703923522415465299 CMakeFiles/Assembler.dir/main.cpp.o a0649e1ce8eedca3
33+
1820 1897 1703923522495547896 Assembler 35cca99beb22f557
-72 Bytes
Binary file not shown.
-568 Bytes
Binary file not shown.
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
Start testing: Dec 28 21:40 IST
1+
Start testing: Dec 30 21:00 IST
22
----------------------------------------------------------
3-
End testing: Dec 28 21:40 IST
3+
End testing: Dec 30 21:00 IST

Assembler/main.cpp

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -405,11 +405,11 @@ int main(int argc, char* argv[]) {
405405
}
406406

407407
///the first two instructions at 0x000 are setting the conditional bit to 1 and jumping to the address at which instructions start indirectly.
408-
OutputInOrder << "0x000: 8800 b100 ";
409-
for (unsigned short i = 0x2; i < 0x100; i++) {
408+
OutputInOrder << "000: 8100 8800 b100 ";
409+
for (unsigned short i = 0x3; i < 0x100; i++) {
410410
if (i % RAM_FORMAT_LENGTH == 0) {
411411
OutputInOrder << "\n";
412-
OutputInOrder << "0x" << std::setw(3) << std::setfill('0') << std::hex << DATA_START_ADDRESS << ": ";
412+
OutputInOrder << std::setw(3) << std::setfill('0') << std::hex << DATA_START_ADDRESS << ": ";
413413
DATA_START_ADDRESS += RAM_FORMAT_LENGTH;
414414
}
415415
OutputInOrder << short_to_nibble(0) << " ";
@@ -421,7 +421,7 @@ int main(int argc, char* argv[]) {
421421
for (const auto& i : MachineStringData) {
422422
if (new_o % RAM_FORMAT_LENGTH == 0) {
423423
SubroutinesNInstructions << "\n";
424-
SubroutinesNInstructions << "0x" << std::setw(4) << std::hex << new_o << ": ";
424+
SubroutinesNInstructions << std::setw(4) << std::hex << new_o << ": ";
425425
}
426426
SubroutinesNInstructions << i << " ";
427427
new_o++;
@@ -437,7 +437,7 @@ int main(int argc, char* argv[]) {
437437
auto latest_return = PRESENT_ADDRESS;
438438
if (PRESENT_ADDRESS % RAM_FORMAT_LENGTH == 0) {
439439
SubroutinesNInstructions << "\n";
440-
SubroutinesNInstructions << "0x" << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
440+
SubroutinesNInstructions << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
441441
}
442442
SubroutinesNInstructions << "0000 ";
443443
PRESENT_ADDRESS++;
@@ -446,7 +446,7 @@ int main(int argc, char* argv[]) {
446446
try {
447447
if (PRESENT_ADDRESS % RAM_FORMAT_LENGTH == 0) {
448448
SubroutinesNInstructions << "\n";
449-
SubroutinesNInstructions << "0x" << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
449+
SubroutinesNInstructions << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
450450
}
451451
char first_hex = FIRST_BIT_MAP.at(tokens[SubroutineInstructionAddress]);
452452
char second_hex = SECOND_BIT_MAP.at(tokens[SubroutineInstructionAddress]);
@@ -486,7 +486,7 @@ int main(int argc, char* argv[]) {
486486
//Our machine jumps to +1 address when called , jumped or returned, so for instructions we need to have a gap(1 word), and we jump to the next address.
487487
if (PRESENT_ADDRESS % RAM_FORMAT_LENGTH == 0) {
488488
SubroutinesNInstructions << "\n";
489-
SubroutinesNInstructions << "0x" << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
489+
SubroutinesNInstructions << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
490490
}
491491
//This will take care of the edge case, in the hardware.
492492
SubroutinesNInstructions << "0000 ";
@@ -503,7 +503,7 @@ int main(int argc, char* argv[]) {
503503
char second_nibble = SECOND_BIT_MAP.at(*Instruction);
504504
if (PRESENT_ADDRESS % RAM_FORMAT_LENGTH == 0) {
505505
SubroutinesNInstructions << "\n";
506-
SubroutinesNInstructions << "0x" << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
506+
SubroutinesNInstructions << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
507507
}
508508
//if we can just get the whole word from the first two bits.
509509
if (first_nibble == '0' || first_nibble == '8') {
@@ -538,14 +538,14 @@ int main(int argc, char* argv[]) {
538538
for (;PRESENT_ADDRESS <= 0xfff; PRESENT_ADDRESS++) {
539539
if (PRESENT_ADDRESS % RAM_FORMAT_LENGTH == 0) {
540540
SubroutinesNInstructions << "\n";
541-
SubroutinesNInstructions << "0x" << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
541+
SubroutinesNInstructions << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
542542
}
543543
SubroutinesNInstructions << std::setw(4) << std::hex << "0000 ";
544544
}
545545

546546

547547
//Set the value at which we are jumping.
548-
OutputInOrder << "\n0x100: " << std::setw(4) << std::hex << InstructionStart << " ";
548+
OutputInOrder << "\n100: " << std::setw(4) << std::hex << InstructionStart << " ";
549549
OutputInOrder << SubroutinesNInstructions.str();
550550
OutputFile << OutputInOrder.str();
551551
std::cout << "Saving at : " << output_file_name << "\n";

Docs.txt

Lines changed: 13 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,8 @@ INSTRUCTIONS
126126
=> 6 X X X | E X X X -> LDI -> LOAD IMM -> LOAD IMMEDIATE VALUE INTO THE AC, (THE HIGHEST 4 BITS WILL BE FILLED WITH 0). -> 0f, 27 ---
127127
=> 7 X X X | F X X X -> SWP -> SWAP -> SWAPS THE VALUES OF AC AND THE OPERAND. -> 12, 2a
128128

129-
(--- means the rom is not written for these instructions, because the assembling program cannot actually produce the machine code for these, can be implemented by th user if intrested.)
129+
(--- means the rom is not written for these instructions, because the assembling program cannot actually produce the machine code for these,
130+
can be implemented by the user if intrested.)
130131

131132
-OPERAND IS NOT REQUIRED : INSTRUCTION FORMAT 0-X-X-X OR 8-X-X-X
132133

@@ -147,7 +148,7 @@ INSTRUCTIONS
147148
=> 0 2 X X -> ADD(34) -> ADD(DR + AC) -> ADD THE VALUE OF DR AND AC AND STORE IT IN AC.
148149
=> 0 3 X X -> MUL(4A) -> MULTIPLY(DR * AC) -> MULTIPLY THE VALUE OF DR WITH AC.
149150
=> 0 4 X X -> SUB(36) -> SUBTRACT(AC <- DR + (~AC + 1)) -> SUBTRACT AC FROM DR.
150-
=> 0 5 X X -> DIV(_-) -> DIVIDE(AC <- REMAINDER OF AC/DR, QR <- AC/DR) -> DIVIDE AC WITH DR.
151+
=> 0 5 X X -> DIV(9a) -> DIVIDE(AC <- REMAINDER OF AC/DR, QR <- AC/DR) -> DIVIDE AC WITH DR.
151152
=> 0 6 X X -> CMP(46) -> COMPARE THE VALUES OF DR AND AC -> WILL SET THREE BITS BASED ON THE COMPARISION(SMALLER, EQUAL, GREATER).
152153
=> 0 7 X X -> AND(3c) -> BITWISE AND(AC <- AC && DR) -> BITWISE AND WITH AC.
153154
=> 0 8 X X -> BOR(38) -> BITWISE OR(AC <- AC || DR) -> BITWISE OR WITH AC.
@@ -172,7 +173,7 @@ INSTRUCTIONS
172173
=> 8 C X X -> INP(91) -> LOAD THE VALUE FROM INPUT REGISTER INTO THE DATA REGISTER.
173174
=> 8 D X X -> OUT(94) -> PLACE THE VALUE OF AC IN THE OUPUT REGISTER.
174175
=> 8 E X X -> IEN(96) -> SET THE INTERRUPT ENABLE ON.
175-
=> 8 F X X -> IEF -> SET THE INTERRUPT ENABLE OF.
176+
=> 8 F X X -> IEF(98) -> SET THE INTERRUPT ENABLE OF.
176177

177178

178179
* CAN HAVE WAY MORE INSTRUCTIONS THAN THIS, BUT IT WILL OVERCOMPLICATE THE SYSTEM.
@@ -186,7 +187,7 @@ MAIN COMPUTER LOOP
186187

187188
BOOTSTRAP -> LOAD -> THE STARTING POINT OG THE PROGRAM IS GOING TO BE THE ADDRESS AT WHICH THE INSTRUCTIONS ARE GOING TO START(.instructions)
188189
we are going to jump to the starting point of the instructions indirectly from the end of the bootstrap, which will put the computer in the user written instruction loop.
189-
The instructions are going to be performed sequentially till they encounter "jmp", "cll" or "hlt" (or some other interrupt)
190+
The instructions are going to be performed sequentially till they encounter "jmp", "cal" or "hlt" (or some other interrupt)
190191
This is going to be repeated, thats it.
191192

192193
+++++++++++++++++++++++++++++
@@ -231,8 +232,14 @@ ROM OUTPUTS AND THE SIGNIFICANCE OF EACH BIT(STORED IN CONTROL DATA REGISTER, SH
231232
4 => ENABLE THE ALU MULTIPLEXER(USED WHEN THE MIROINSTRUCTION TAKES MORE THAN ONE-CLOCK CYCLE)
232233
5 => SHIFT THE AC REGISTER TO THE LEFT
233234
6 => FIRST BIT IS TO LOAD THE INPUT INTO mAC PARALLELY, AND THE SECOND BIT IS FOR LEFT SHIFTING mAC.
234-
7 => SETTING THE CONDITIONAL BIT(FIRST 2 BITS, CHOOSE FROM 'CARRY', 'LESS THAN', 'EQUALS', 'GREATER THAN'), THIS WILL BE ONLY CONSIDERED
235-
WHEN THE 3RD BIT IS 0, ELSE THE CONDITION STATUS WILL BE SET DIRECTLY TO ONE, WITHOUT DEPENDING ON ANY OTHER THINGS.
235+
7 => SETTING THE CONDITION STATUS BIT, THIS WILL CONTROL IF THE NEXT "JMP" SHOULD OCCUR OR NOT, THIS IS BASICALLY AN OCTAL NUMBER,
236+
*GENERALLY THIS IS DONE AFTER A "CMP",IT IS LIKE A PART OF THE COMPARE OPERATION.
237+
0, 6, 7 WILL SET THE NUMBERS TO VALUE TO ZERO.
238+
1 WILL SET IT TO ONE NO MATTER THE OTHER CONDITIONS(USE THIS WHEN YOU ARE JUMPING UNCONDITIONALLY AS WE DO NOT HAVE AN INSTRUCTION FOR IT).
239+
2 WILL SET THE VALUE TO CARRY FLIP-FLOP VALUE.
240+
3 WILL SET IT TO THE RESULT FROM THE LESSER FLIP-FLOP FROM THE COMPARISION RESULT.
241+
4 WILL SET IT TO EQUAL FLIP-FLOP FROM THE EQUALS TO FLIP-FLOP FROM THE COMPARISION RESULT.
242+
5 WILL SET TO THE GREATER THAN FLIP-FLOP FROM THE COMPARISION RESULT.
236243
8 => RESET dAC && mAC
237244
9 => LOAD Q PARALLELY
238245
A => FIRST BIT : STACK POINTER COUNT GO UP OR DOWN(IF 1 CYCLES WILL MATTER), SECOND BIT : IF 1 COUNT WILL GO UP, ELSE COUNT WILL GO DOWN(FOR PUSH AND POP RESPECTIVELY)
@@ -268,20 +275,3 @@ THE STARTING MICRO-OPERATION OF EVERY INSTRUCTION WILL BE THE EXACT SAME THAT IS
268275
+ BUT IN THE CASE OF JUMP(AS OUR JUMP IS ALWAYS CONDITIONAL) IF THE CONDITION IS "1" THE ADDRESS TO WHICH + 1 IS LOADED, BUT IF IT NOT, THEN WE LOAD THE ADDRESS "PC + 1",
269276
EQUIVALENTLY SKIPPING THE JUMP INSTRUCTION.
270277

271-
272-
273-
274-
275-
276-
277-
278-
279-
280-
281-
282-
283-
284-
285-
286-
287-

ROM.txt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@ v3.0 hex words addressed
1515
68: 00050000 20020000 02b80001 00000000 00000000 00000000 00000000 00000000
1616
70: 00000600 3f000001 00000000 00000401 00000000 ca000000 20800000 00000400
1717
78: ca000000 22280000 2f000001 00000000 c6000000 00000400 ca000000 20800000
18-
80: 6a000000 02380000 2f000001 00000000 ca000000 20800001 00000000 00002001
19-
88: 00000000 00004001 00000000 00006001 00000000 0000a001 00000000 0000d001
18+
80: 6a000000 02380000 2f000001 00000000 ca000000 20800001 00000000 00004001
19+
88: 00000000 00002001 00000000 00006001 00000000 00008001 00000000 0000a001
2020
90: 00000000 5a000000 00000003 00000000 2c000001 00000000 00000031 00000000
21-
98: 00000021 00000000 00000000 00000000 00000000 00000000 00000000 00000000
22-
a0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
23-
a8: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
24-
b0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
25-
b8: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
21+
98: 00000021 00000000 ca000400 02080000 ca000000 00001000 20020000 00050000
22+
a0: 20020000 00050000 20020000 00050000 20020000 00050000 20020000 00050000
23+
a8: 20020000 00050000 20020000 00050000 20020000 00050000 20020000 00050000
24+
b0: 20020000 00050000 20020000 00050000 20020000 00050000 20020000 00050000
25+
b8: 20020000 00050000 20020000 00050000 20020000 02b80000 2f000001 00000000
2626
c0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
2727
c8: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
2828
d0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
2929
d8: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
3030
e0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
3131
e8: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
32-
f0: 21000100 00000001 00000000 00000000 00000000 00000000 00000000 00000000
32+
f0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
3333
f8: 00000000 00000000 00000000 00000000 00000000 00000000 1b000040 00000000

0 commit comments

Comments
 (0)