Skip to content
pr1usf0xPublic

About

MIPT DREC Huawei cource task 5

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

 

History

69 Commits

Folders and files

Repository files navigation

Processor (DREC TASK)

Work Example

til

This is virtual processor with his own assembler included for running programms

Installation

git clone https://github.com/priusf0x/Assembly
cd Assembly
make build

Now you have 3 different options

./compiler.out <path-to-file(default_name = input_file.asm> <path-to-compiled-file(default_name = compiled.obj)>
./disassembler.out <path-to-file(default_name = compiled.obj> <path-to-dissassemvled-file(default_name = disassembled.asm)>
./processor.out <path-to-file(default_name = compiled.obj>

General commands

Stack usage

Command name Description
push Pushes integer into stack
push <register_name> (add. +/- <int_value>) Pushes integer from register
push [register_name (add. +/- <int_value>)] Pushes integer from memory cell with number which is written in register
pop <register_name> (add. +/- <int_value>) Pops integer to register
pop [register_name (add. +/- <int_value>)] Pops integer to memory cell with number which is written in register

Ariphmetic operations

til

Command name Description
add adds E to F
sub substracts E from F
mul multiplies E on E
div divides F on E
sqrt finds square root from E

User Interactions

Command name Description
draw draws screen using integer size of 1 pixel
drawb draws screen using 1 byte in integer type for 1 pixel
in reads user's input from cmd to stack

Jumps/Call function

Command name Description
jmp <instrucrion_number/<label_name:> Default jump
ja <instrucrion_number/<label_name:> Jump If F is Above than E
jae <instrucrion_number/<label_name:> Jump If F is Above than or Equal to E
jb <instrucrion_number/<label_name:> Jump If F is Below than E
jbe <instrucrion_number/<label_name:> Jump If F is Below than or Equal to E
je <instrucrion_number/<label_name:> Jump If F is Equal to E
jne <instrucrion_number/<label_name:> Jump If F is Not Equal F
call <label_name:> Jump with pushing current adress into stack
ret <label_name:> returns to adress which is written in stack

Was created with

c logo

Code Example

push 1
pop RAX
printsquares:
    call calculate_square
    push RAX #adding 1 to value
    push 1
    add
    pop RAX
    push RAX
    push 10

jbe printsquares:
hlt

#functions

calculate_square:
    push RAX
    push RAX
    mul
    out
ret
hlt

About

MIPT DREC Huawei cource task 5

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages