Code Monkey home page Code Monkey logo

isp_hw_4's Introduction

ISP_DZ4 (Processor)

Simple processor realisation with assembler and disassembler. Under construction

Build

On linux, you can build using CMake

cmake -S ./ -B out && cmake --build out

Run

Run CPU, filename is path to code in pseudo-asm

out/cpu <filename>

or

out/executable e <filename>

Run assembler, input is path to file with code in pseudo-asm, output - path to file where bytecodes will be written

out/asm <input> <output>

or

out/executable a <input> <output>

Run disassembler, input is path to file with bytecode, output - path to file where code in pseudo-asm will be written

out/disasm <input> <output>

or

out/executable d <input> <output> 

There are example files in assets folder

#Available commands

Mnemonic Op code (hex) Description
add 00 Pops two last values from stack and pushes their sum
sub 01 Pops two last values from stack and pushes their subtraction result (first popped - subtrahend, second - minuend)
mul 02 Pops two last values from stack and pushes their multiplication result
div 03 Pops two last values from stack and pushes their division result (first popped - divisor, second - dividend)
sqrt 04 Pops last value from stack and pushes it's square root
in 05 Reads double value from console and pushes to stack
out 06 Pops last value from stack and writes to console
pop 07 Pops last value from stack
push 08 Pushes double value to stack
pop 09 Pops last value from stack and writes to given register (ax, bx, cx or dx)
push 0a Pushes value of given register (ax, bx, cx or dx) to stack
jmp 0b Unconditionally jumps to the label
ifl 0c Pops two last values from stack and jumps to given label if second popped value is less then the first one
ifle 0d Pops two last values from stack and jumps to given label if second popped value is less then or equal to the first one
ifg 0e Pops two last values from stack and jumps to given label if second popped value is greater then the first one
ifge 0f Pops two last values from stack and jumps to given label if second popped value is greater then or equal to the first one
ife 10 Pops two last values from stack and jumps to given label if second popped value is equal to the first one
ifne 11 Pops two last values from stack and jumps to given label if second popped value is not equal to the first one
call 12 Saves current position in call stack and jumps to given label
ret 13 Returns to the last saved position in call stack, just after the last executed call command
hlt 14 Stops the execution

#Other Show help

out/executable -h

Run unit tests

out/tests

Documentation

You can find documentation at https://arti1208.github.io/ISP_DZ4/html/

isp_hw_4's People

Contributors

arti1208 avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.