Skip to content

Ch1n-ch1nless/Processor

Repository files navigation

Hi there, I'm Oleg

I am the author of project:

Processor

Description

My realization of working soft processing unit. What this project can do?
  1) Assembler: assembles human-readable assembly code to binary
  2) SPU: execute machine code
  3) DisAssembler: disassembles machine code to human-readable assembly code

About basic functions in "assembler":
  1)
 PUSH < RAM | REG | NUM >  -- add argument with type specified in parentheses

  2)
 IN                        -- read from input the number  and add it to stack

  3)
 POP < RAM | REG >         -- retrieves an element from the stack adds it to register or RAM

  4)
 ADD                       -- pops 2 numbers from stack and add their sum to stack

  6)
 SUB                       -- pops 2 numbers from stack and add their difference to stack

  7)
 MUL                       -- pops 2 numbers from stack and add their product to stack

  8)
 DIV                       -- pops 2 numbers from stack and add their quotient to stack

  9)
 SQRT                      -- pop number from stack and add square root of it

  10)
 SIN                      -- pop number from stack and add sin(number)

  11)
 COS                      -- pop number from stack and add cos(number)

  12)
 OUT                      -- pop number from stack and print it

  13)
 HLT                      -- exit from program

  14)
 JMP < LBL >              -- go to line

  15)
 JA < LBL >               -- pop 2 numbers from stack, if first "<" second, then go to line

  16)
 JAE < LBL >              -- pop 2 numbers from stack, if first "<=" second, then go to line

  17)
 JB < LBL >               -- pop 2 numbers from stack, if first "> second, then go to line

  18)
 JBE < LBL >              -- pop 2 numbers from stack, if first ">=" second, then go to line

  19)
 JE < LBL >               -- pop 2 numbers from stack, if first "==" second, then go to line

  20)
 JNE < LBL >              -- pop 2 numbers from stack, if first "!=" second, then go to line

  22)
 CALL < LBL >             -- go to label, and add the last line to call stack

  23)
 RET                      -- pop label from stack and go to it

  24)
 PUTC                     -- pop number from stack and print it such as symbol

  25)
 SET_PIXEL                -- dyes pixel(rbx, rax) color = RAM[rcx]

  26)
 CREATE_WINDOW            -- create window 256 by 256


The project supports DSL. You can add new commands!!! What you need to do:
  1) Open in folder "DSL" file "commands.dsl"
  2) Write in the end of file: DEF_CMD((a), (b), (c), (d), (e))
    2.1) In brackets you need write:
      (a) name of command
      (b) number of command
      (c) type of arguments
      (d) number of arguments (now better to write 0 or 1, if you write more, can be errors in program)
      (e) action, what program needs to do
    2.2) About syntax DSL you can read: [link to manual will be here later]

How to launch and use program?

  1) write in terminal: git clone https://github.com/Ch1n-ch1nless/Preprocessor.git
  2) go to folder:       cd Preprocessor
  3) write in terminal: make compile

  The command to run the program, you can find in the section 'Programs'

Programs

Examples of programs that are written in "assembly" you can find in folder "Programs"
What programs you can find?

Factorial

Brief:   This program on input takes number and returns it factorial

Command: write in terminal: make factorial

Example of working:


Fibonacci

Brief:   This program on input takes the index of fibonacci number and returns the fibonacci number with this index

Command: write in terminal: make fibonacci

Example of working:


Moon

Brief:   This program draws beatiful moon

Command: write in terminal: make moon

Example of working:


Square equation

Brief:   This program on input takes 3 coefficients of the square equation and returns the number of roots and their valueы
  About return:
    1) if first number is 0, that means equation hasn't roots.
    2) if first number is 8, that means equation has infinite quantite of roots.
    3) if first number is 1, that means equation hasn 1 root. Second number is value of root
    4) if first number is 2, that means equation hasn 2 roots. Next 2 numbers are values of roots

Command: write in terminal: make square_equation

Example of working:

Thank you for reading!

If you have any questions, write on Telegram

About

My realization of working the computer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published