Skip to content

Commit

Permalink
Pretty much comoplete, just division is left
Browse files Browse the repository at this point in the history
  • Loading branch information
Harsha-vardhan-R committed Dec 30, 2023
1 parent 35ba4a8 commit 4cbdac0
Show file tree
Hide file tree
Showing 21 changed files with 923 additions and 786 deletions.
Binary file modified Assembler/cmake-build-debug/.ninja_deps
Binary file not shown.
4 changes: 4 additions & 0 deletions Assembler/cmake-build-debug/.ninja_log
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,7 @@
1854 1937 1703536641127533671 Assembler 35cca99beb22f557
1 2012 1703684675441054811 CMakeFiles/Assembler.dir/main.cpp.o a0649e1ce8eedca3
2012 2100 1703684675529050080 Assembler 35cca99beb22f557
0 1867 1703853619769087901 CMakeFiles/Assembler.dir/main.cpp.o a0649e1ce8eedca3
1867 1946 1703853619853082172 Assembler 35cca99beb22f557
1 1820 1703923522415465299 CMakeFiles/Assembler.dir/main.cpp.o a0649e1ce8eedca3
1820 1897 1703923522495547896 Assembler 35cca99beb22f557
Binary file modified Assembler/cmake-build-debug/Assembler
Binary file not shown.
Binary file modified Assembler/cmake-build-debug/CMakeFiles/Assembler.dir/main.cpp.o
Binary file not shown.
4 changes: 2 additions & 2 deletions Assembler/cmake-build-debug/Testing/Temporary/LastTest.log
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
Start testing: Dec 28 21:40 IST
Start testing: Dec 30 21:00 IST
----------------------------------------------------------
End testing: Dec 28 21:40 IST
End testing: Dec 30 21:00 IST
20 changes: 10 additions & 10 deletions Assembler/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -405,11 +405,11 @@ int main(int argc, char* argv[]) {
}

///the first two instructions at 0x000 are setting the conditional bit to 1 and jumping to the address at which instructions start indirectly.
OutputInOrder << "0x000: 8800 b100 ";
for (unsigned short i = 0x2; i < 0x100; i++) {
OutputInOrder << "000: 8100 8800 b100 ";
for (unsigned short i = 0x3; i < 0x100; i++) {
if (i % RAM_FORMAT_LENGTH == 0) {
OutputInOrder << "\n";
OutputInOrder << "0x" << std::setw(3) << std::setfill('0') << std::hex << DATA_START_ADDRESS << ": ";
OutputInOrder << std::setw(3) << std::setfill('0') << std::hex << DATA_START_ADDRESS << ": ";
DATA_START_ADDRESS += RAM_FORMAT_LENGTH;
}
OutputInOrder << short_to_nibble(0) << " ";
Expand All @@ -421,7 +421,7 @@ int main(int argc, char* argv[]) {
for (const auto& i : MachineStringData) {
if (new_o % RAM_FORMAT_LENGTH == 0) {
SubroutinesNInstructions << "\n";
SubroutinesNInstructions << "0x" << std::setw(4) << std::hex << new_o << ": ";
SubroutinesNInstructions << std::setw(4) << std::hex << new_o << ": ";
}
SubroutinesNInstructions << i << " ";
new_o++;
Expand All @@ -437,7 +437,7 @@ int main(int argc, char* argv[]) {
auto latest_return = PRESENT_ADDRESS;
if (PRESENT_ADDRESS % RAM_FORMAT_LENGTH == 0) {
SubroutinesNInstructions << "\n";
SubroutinesNInstructions << "0x" << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
SubroutinesNInstructions << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
}
SubroutinesNInstructions << "0000 ";
PRESENT_ADDRESS++;
Expand All @@ -446,7 +446,7 @@ int main(int argc, char* argv[]) {
try {
if (PRESENT_ADDRESS % RAM_FORMAT_LENGTH == 0) {
SubroutinesNInstructions << "\n";
SubroutinesNInstructions << "0x" << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
SubroutinesNInstructions << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
}
char first_hex = FIRST_BIT_MAP.at(tokens[SubroutineInstructionAddress]);
char second_hex = SECOND_BIT_MAP.at(tokens[SubroutineInstructionAddress]);
Expand Down Expand Up @@ -486,7 +486,7 @@ int main(int argc, char* argv[]) {
//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.
if (PRESENT_ADDRESS % RAM_FORMAT_LENGTH == 0) {
SubroutinesNInstructions << "\n";
SubroutinesNInstructions << "0x" << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
SubroutinesNInstructions << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
}
//This will take care of the edge case, in the hardware.
SubroutinesNInstructions << "0000 ";
Expand All @@ -503,7 +503,7 @@ int main(int argc, char* argv[]) {
char second_nibble = SECOND_BIT_MAP.at(*Instruction);
if (PRESENT_ADDRESS % RAM_FORMAT_LENGTH == 0) {
SubroutinesNInstructions << "\n";
SubroutinesNInstructions << "0x" << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
SubroutinesNInstructions << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
}
//if we can just get the whole word from the first two bits.
if (first_nibble == '0' || first_nibble == '8') {
Expand Down Expand Up @@ -538,14 +538,14 @@ int main(int argc, char* argv[]) {
for (;PRESENT_ADDRESS <= 0xfff; PRESENT_ADDRESS++) {
if (PRESENT_ADDRESS % RAM_FORMAT_LENGTH == 0) {
SubroutinesNInstructions << "\n";
SubroutinesNInstructions << "0x" << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
SubroutinesNInstructions << std::setw(3) << std::hex << PRESENT_ADDRESS << ": ";
}
SubroutinesNInstructions << std::setw(4) << std::hex << "0000 ";
}


//Set the value at which we are jumping.
OutputInOrder << "\n0x100: " << std::setw(4) << std::hex << InstructionStart << " ";
OutputInOrder << "\n100: " << std::setw(4) << std::hex << InstructionStart << " ";
OutputInOrder << SubroutinesNInstructions.str();
OutputFile << OutputInOrder.str();
std::cout << "Saving at : " << output_file_name << "\n";
Expand Down
36 changes: 13 additions & 23 deletions Docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,8 @@ INSTRUCTIONS
=> 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 ---
=> 7 X X X | F X X X -> SWP -> SWAP -> SWAPS THE VALUES OF AC AND THE OPERAND. -> 12, 2a

(--- 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.)
(--- 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 the user if intrested.)

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

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


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

BOOTSTRAP -> LOAD -> THE STARTING POINT OG THE PROGRAM IS GOING TO BE THE ADDRESS AT WHICH THE INSTRUCTIONS ARE GOING TO START(.instructions)
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.
The instructions are going to be performed sequentially till they encounter "jmp", "cll" or "hlt" (or some other interrupt)
The instructions are going to be performed sequentially till they encounter "jmp", "cal" or "hlt" (or some other interrupt)
This is going to be repeated, thats it.

+++++++++++++++++++++++++++++
Expand Down Expand Up @@ -231,8 +232,14 @@ ROM OUTPUTS AND THE SIGNIFICANCE OF EACH BIT(STORED IN CONTROL DATA REGISTER, SH
4 => ENABLE THE ALU MULTIPLEXER(USED WHEN THE MIROINSTRUCTION TAKES MORE THAN ONE-CLOCK CYCLE)
5 => SHIFT THE AC REGISTER TO THE LEFT
6 => FIRST BIT IS TO LOAD THE INPUT INTO mAC PARALLELY, AND THE SECOND BIT IS FOR LEFT SHIFTING mAC.
7 => SETTING THE CONDITIONAL BIT(FIRST 2 BITS, CHOOSE FROM 'CARRY', 'LESS THAN', 'EQUALS', 'GREATER THAN'), THIS WILL BE ONLY CONSIDERED
WHEN THE 3RD BIT IS 0, ELSE THE CONDITION STATUS WILL BE SET DIRECTLY TO ONE, WITHOUT DEPENDING ON ANY OTHER THINGS.
7 => SETTING THE CONDITION STATUS BIT, THIS WILL CONTROL IF THE NEXT "JMP" SHOULD OCCUR OR NOT, THIS IS BASICALLY AN OCTAL NUMBER,
*GENERALLY THIS IS DONE AFTER A "CMP",IT IS LIKE A PART OF THE COMPARE OPERATION.
0, 6, 7 WILL SET THE NUMBERS TO VALUE TO ZERO.
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).
2 WILL SET THE VALUE TO CARRY FLIP-FLOP VALUE.
3 WILL SET IT TO THE RESULT FROM THE LESSER FLIP-FLOP FROM THE COMPARISION RESULT.
4 WILL SET IT TO EQUAL FLIP-FLOP FROM THE EQUALS TO FLIP-FLOP FROM THE COMPARISION RESULT.
5 WILL SET TO THE GREATER THAN FLIP-FLOP FROM THE COMPARISION RESULT.
8 => RESET dAC && mAC
9 => LOAD Q PARALLELY
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)
Expand Down Expand Up @@ -268,20 +275,3 @@ THE STARTING MICRO-OPERATION OF EVERY INSTRUCTION WILL BE THE EXACT SAME THAT IS
+ 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",
EQUIVALENTLY SKIPPING THE JUMP INSTRUCTION.


















16 changes: 8 additions & 8 deletions ROM.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,19 @@ v3.0 hex words addressed
68: 00050000 20020000 02b80001 00000000 00000000 00000000 00000000 00000000
70: 00000600 3f000001 00000000 00000401 00000000 ca000000 20800000 00000400
78: ca000000 22280000 2f000001 00000000 c6000000 00000400 ca000000 20800000
80: 6a000000 02380000 2f000001 00000000 ca000000 20800001 00000000 00002001
88: 00000000 00004001 00000000 00006001 00000000 0000a001 00000000 0000d001
80: 6a000000 02380000 2f000001 00000000 ca000000 20800001 00000000 00004001
88: 00000000 00002001 00000000 00006001 00000000 00008001 00000000 0000a001
90: 00000000 5a000000 00000003 00000000 2c000001 00000000 00000031 00000000
98: 00000021 00000000 00000000 00000000 00000000 00000000 00000000 00000000
a0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
a8: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
b0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
b8: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
98: 00000021 00000000 ca000400 02080000 ca000000 00001000 20020000 00050000
a0: 20020000 00050000 20020000 00050000 20020000 00050000 20020000 00050000
a8: 20020000 00050000 20020000 00050000 20020000 00050000 20020000 00050000
b0: 20020000 00050000 20020000 00050000 20020000 00050000 20020000 00050000
b8: 20020000 00050000 20020000 00050000 20020000 02b80000 2f000001 00000000
c0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
c8: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
d0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
d8: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
e0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
e8: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
f0: 21000100 00000001 00000000 00000000 00000000 00000000 00000000 00000000
f0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 00000000
f8: 00000000 00000000 00000000 00000000 00000000 00000000 1b000040 00000000
Loading

0 comments on commit 4cbdac0

Please sign in to comment.