Skip to content

Reptile: Example Programs

REPTILE: EXAMPLE PROGRAMS

Reptile has a minimum instruction set which is capable of solving quite complicated problems.. In the coming lectures we will continue to add a few more instructions like PUSH, POP, CALL and RET but it is quite sufficient even without these instructions.. Below we will give examples of the sort of problems which are solvable by reptile

Note that these programs can be written in many different ways..

Summing all integers from 1 to N

  • The program has two variables, N and SUM. N is considered unsigned.
  • The program will sum all the integers between 1 and N
  • The program will write its result to the variable SUM.

In the following program, N is arbitrarily chosen as 60.

Summing an alternating series

Same with the above, but this time evaluates 1-2+3-4+5-6+7-8+…. up to N.

Multiplying unsigned integers A and B

Computing nth fibonacci number

Multiplying signed numbers

Computing n^x

Factorial

IEEE 754

Bubble sort

Quick sort

Towers of hanoi

Questions

Your email address will not be published. Required fields are marked *