This is a recursion based calculator written in MIPS assembly using the MARS mips simulator.
| Operator | Syntax | Description |
|---|---|---|
+ |
+ a b |
returns the result of a summed with b |
- |
- a b |
returns the result of b subtracted from a |
* |
* a b |
returns the result of a multiplied by b |
/ |
/ a b |
returns the result of a divided by b truncating the result to an integer |
% |
% a b |
returns the remainder of a divided by b |
&& |
&& a b |
returns 1 if both a and b are non-zero, 0 otherwise |
|| |
|| a b |
returns 0 if both a and b are zero, 1 otherwise |
! |
! a |
returns 1 if a is zero, 0 otherwise |
& |
& a b |
returns the result of a ANDed with b bitwise |
| |
| a b |
returns the result of a ORed with b bitwise |
~ |
~ a |
returns a with all the bits inverted |
^ |
^ a b |
returns the result of a XORed with b bitwise |
>> |
>> a b |
returns the result of shifting all the bits in a to the right b times with signed padding |
<< |
<< a b |
returns the result of shifting all the bits in a to the left b times |
== |
== a b |
returns 1 if a equals b, 0 otherwise |
!= |
!= a b |
returns 1 if a does not equal b, 0 otherwise |
< |
< a b |
returns 1 if a is less than b, 0 otherwise |
<= |
<= a b< |
returns 1 if a is less than or equal to b, 0 otherwise |
> |
> a b |
returns 1 if a is greater than b, 0 otherwise |
>= |
>= a b |
returns 1 if a is greater than or equal to b, 0 otherwise |
= |
= A b |
assigns b to A, then returns A |
+= |
+= A b |
increments A by b, then returns A |
-= |
-= A b |
decrements A by b, then returns A |
*= |
*= A b |
multiplies A by b, then returns A |
/= |
/= A b |
divides A by b, truncating to an integer, then returns A |
%= |
%= A b |
assigns A to the remainder of A divided by b, then returns A |
&= |
&= A b |
bitwise ANDs A with b, then returns A |
|= |
|= A b |
bitwise ORs A with b, then returns A |
^= |
^= A b |
bitwise XORs A with b, then returns A |
++ |
++ A |
increments A, then returns A |
-- |
-- A |
decrements A, then returns A |
. |
. a b |
returns b |
Variables are case sensitive and are single letters ([a-zA-Z])
+ 1 2: adds 1 and 2, returning 3
. = a 4 + a 8: assigns 4 to a, then adds a and 8, returning 12