Skip to content

A CLI software to emulate the working of 8085 microprocessor.

License

Notifications You must be signed in to change notification settings

akbloodadarsh/8085-Emulator

Repository files navigation

8085-Emulator

How to use (For Linux)

  1. git clone https://github.com/akbloodadarsh/8085-Emulator
  2. cd 8085-Emulator
  3. sudo apt install g++
  4. sudo apt install build-essential
  5. g++ main.cpp

Arithmetic

  • Arithmetic.cpp:This file contains all the arithmetic operations:

  • ADD :During the addition, we will check from which register we are performing the addition & after that, we will pass the accumulator and the register as a reference to flag_on_off_8bit_ADD and perform the addition,& set the flags depending on the results of the operations & return the resultant value.

  • ADI: During the ADI we will extract the hexadecimal number and convert it to decimal & pass the accumulator & the hexadecimal value & pass it to flag_on_off_8bit_ADD & it will return the result & set the flags & return the result and store the results in the accumulator.

  • SUI:During the SUI we will extract the hexadecimal number and convert it to decimal & pass the accumulator & the hexadecimal value & pass it to flag_on_off_8bit_SUB & it will return the result & set the flags & return the result and store the result in accumulator.

  • SUB: During the subtraction, we will check from which register we are performing the subtraction & after that we will pass the accumulator and the register as a reference to flag_on_off_8bit_SUB and perform the subtraction,& set the flags depending on the results of the operations & return the resultant value.

  • DCR: We will check which from which register we have to perform DCR and after that, we will decrease the value of the register with 1 by using flag_on_off_8bit_SUB & passing the register and value 1 to decrease the content of the register.

  • INR: We will check which from which register we have to perform INR and after that, we will increase the value of the register with 1 by using flag_on_off_8bit_ADD & passing the register and value 1 to increase the content of the register.

  • INX: We will check which register pair value we have to increase & because we are storing the value in 2 registers we have to combine them to create the actual number & after that we simply increment the number by 1 & again break the number and update the values of the registers by the incremented number.

  • DCX: We will check which register pair value we have to decrease & because we are storing the value in 2 registers we have to combine them to create the actual number & after that we simply decrement the number by 1 & again break the number and update the values of the registers by the incremented number.

  • DAD: We have to combine the values stored in HL register pair to create the actual number & after that we have to check from which register pair we have to perform addition operation then, we have to combine the content of the registers pairs to create the actual number and perform addition and then we have to update the content of HL register pair with the resultant value.

LOGICAL

  • Logical.cpp: This file contains all the logical operations:
  • CMA: One's compliment the content of accumulator.
  • CMP: Check from which register we have to compare the content of the accumulator & output the difference of the given register and accumulator.

BRANCHING

  • Branching.cpp: This file contains all the branching operations:
  • JMP: It will covert the hexadecimal address to decimal and check if the address is free or not if no then return true which signifies that there is an error else return false which means no error occurred during this operation.
  • JC: Before calling this function we will check if carry is set or not, if yes then only we will call this function, rest is same as JMP.
  • JNC: Before calling this function we will check if carry is set or not, if not then only we will call this function, rest is same as JMP
  • JZ: Before calling this function we will check if Zero Flag is set or not, if yes then only we will call this function, rest is same as JMP.
  • JNZ: Before calling this function we will check if Zero Flag is set or not, if not then only we will call this function, rest is same as JMP.

LOAD AND STORE

  • Load_and_Store.cpp: This file contains all the load and store operations:
  • MOV: We will check from which register we have to move the content, then we will store the content in a temporary variable and then we will check in which register we have to overwrite the content and update the content with the temporary variable value.
  • MVI: We will convert the hexadecimal content to decimal content and store the content in a temporary variable and then we will check in which register we have to overwrite the content and update the content with the temporary variable value.
  • LDA: We will convert the hexadecimal address to decimal address and use adress_data to check if there is some value stored at the address, if yes then store that value in the accumulator.
  • STA: We will convert the hexadecimal address to decimal address and use adress_data to store the data of the accumulator to that address.
  • SHLD: Store the content of register L in the given address and store the content of register H in the incremented address.
  • LHLD: Store the content of given address in register L and the content of incremented address in register H.
  • XCHG: Swap the content of register pair HL & DE.
  • LXI: Store the address in the register pair after breaking the address into two & converting it to its decimal form.
  • STAX: Extract the address from the given register pair & combine it to form the actual address and use that address to store the content of the accumulator at that address.

DEBUGGER INSTRUCTIONS

  • SET: We will convert the hexadecimal address to decimal address & convert the hexadecimal data to decimal data and use adress_data to store the data to that address. Ex:- SET 2500H, 05H
  • break or b: It will stop the execution of the pragram when it reaches the specified address. Ex:- break 2500H or b 2500H
  • step or s: It will run program one instruction at a time and ask if you want to use debugger, if yes you enter debugger mode else it will run the next instruction.Ex:- step or s
  • print or p: It prints the value of register or value present at memory location. Ex:- print A or p B or print 2500H or p 5000H
  • quit or q: quits the debugger. Ex:- quit or q
  • help: will show commands of the debugger. Ex:- help

EXTRA FEATURES

  • If you accidentally input some invalid starting address Ex:- 01,425544646. It will tell you to input a valid starting address.
  • You can give input from a file. After asking Do you want to take input from a file press 'y' & give the location of the file. If the input file is in the same folder which contains the program just input the file name with extension Ex:- file_name.txt, if the file is not found you will be asked to input a valid file location.
  • If the user input a partial correct instruction he will be given a correct suggestion Ex:- I/P ADD BLABLA O/P Did you mean ADD B? or I/P ADD O/P Did you mean ADD valid_register_name

EXTRA FILES DESCRIPTION

  1. mnemonics:- It contains opcodes as key & theirID's & their size as values.
  2. instruction_size:- It contains opcode id as key & instruction size & instruction example as value.
  3. char_to_int:- It has hexadecimal digit as key & its decimal equivalent as value.
  4. int_to_char:- It has decimal number as key & its hexadecimal equivalent as value.
  1. hex_to_dec:- It takes (string)hexadecmal number as input & return its decimal equivalent which is integer type.
  2. dec_to_hex:- It takes (integer)decimal number as input & return its hexadecimal equivalent which is string type.
  3. dec_to_hex16:- It takes (integer)decimal number as input & return its 16bit hexadecimal equivalent which is string type.

CONTRIBUTE

Read the contribution guidelines if you want to contribute.

  • any other suggestions then leave an issue.
  • Leave a star if you like the project :)

About

A CLI software to emulate the working of 8085 microprocessor.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages