Skip to content

DariaClem/Reverse-Polish-notation

Repository files navigation

Computer system architecture 💻

Reverse Polish notation

The language used is Assembly x86 AT&T syntax.

Assignment:

  1. A hex string is given as input. It is required to display the corresponding assembly instruction to be executed in the standard output. Example:

Input

A78801C00A7890EC04

Output

x 1 let x -14 div
  1. An instruction in the assembly language of the specified arithmetic processor is given as input. It is required to display the evaluation of the instruction in the standard output. (Note: There are no variables in the instruction, only integers and operations. All operations are guaranteed to be unsigned.)

Example:

Input

2 10 mul 5 div 7 6 sub add

Output

5
  1. An instruction in the assembly language of the specified arithmetic processor is given as input. It is required to display the evaluation of the instruction in the standard output. (Note: Unlike the instruction in exercise 2, this instruction contains variables introduced by let. All operations are guaranteed to be unsigned.)

Example:

Input

x 1 let 2 x add y 3 let x y add mul

Output

12
  1. A matrix is given as input. It is required to display the matrix after the specified operations have been applied in the standard output. (Note: All operations are guaranteed to be signed.)

The following operations can be used:

  • add: all elements in the matrix are added with the value of the operand
  • sub: all elements in the matrix are subtracted by the value of the operand
  • mul: all elements in the matrix are multiplied by the value of the operand
  • div: all elements in the matrix are divided by the value of the operand
  • rot90d: The matrix is rotated 90 degrees to the right.

Example:

Input

x 2 3 1 2 3 4 5 6 let x -2 add

Output

2 3 -1 0 1 2 3 4

Input

x 2 3 -1 0 1 2 3 4 let x rot90d

Output

3 2 2 -1 3 0 4 1