SCMP 391 – Lab 1

Programming a simple machine
Doe Feb

Goal:

The goal of this lab is to figure out the operation of a simple computer, and then to program it. You are to do this lab during lab period. You are encouraged to interact with other students, helping each other as you figure things out. But you must in the end do your own works, and submit you own lab report.

Assignment

You will need to create a lab report with screen shots, the programs you write, and answers to all the questions.

Step one

Consider the simple machine here: Simple 8-bit Assembler Simulator

Instructions here: Simple Computer Instructions

Read through the instructions and play around a bit.

Step two

Write the following programs:

  1. Sum the numbers from 1 to 5. Put the result in a memory location
  2. Convert an integer value into a string, and output to console.
  3. Turn #2 into a function you can call, and put together with #1 to output the sum to the console
  4. Create a list of 10 numbers in memory. Write a program to find and print the sum and the average.
  5. Create a list of 10 numbers in memory. Write a program to sort the numbers.

Step four

Answer the following questions

  1. What is the number of bits, and the numeric range, of numbers in this computer.
  2. What is the meaning of a register in brackets, e.g. [A]?
  3. What are the op codes for PUSH, ADD, JNZ
  4. What is the instruction format for the ADD instruction?
  5. What is the purpose of the SP register?
  6. How does the RET instruction return to the instruction after the CALL?
  7. How do the conditional jump instructions know whether to branch or not?
  8. What do you think of this lab? Did it help you understand the concept of machine level programming?
Scroll to Top