Tutorials - SIC/XE assembly basics

Tutorials - SIC/XE assembly basics

You should store the source code of all the programs you write in your repository. For this purpose create a new project. You will submit all your programs for the first homework assignment. 

Using the SIC/XE simulator

Download and install SicTools toolchain and try the simulator. You can use the following example:

primer  START  0
. What does this program do?
first LDA #42
ADD x
STA x
. What is the purpose of the following command?
halt J halt
. data
x WORD 22
END first
  • Try start/stop/step.
  • Have a good look at the disassembly of the program.
  • Change the register contents during the execution.
  • Observe the memory and try to change it properly.
  • Which memory location is used to store the value of x?

Basic arithmetics

Write a program to add/subtract/multiply/divide/give reminder of two numbers (integers). The numbers should be stored at locations labeled x in y, while the results should be stored at locations labeled sum, diff, prod, quot, mod. Finally, the program should go into infinite loop.

a) Use arithmetic instructions with simple addressing.

b) Use arithmetic instruction with register addressing. Here, you should read x and y only once, and, similarly, write to sum, diff, prod, quot, mod also only once.

Evaluate a polynomial

Write a program which evaluates the value of the following polynomial: \( x^4 + 2x^3 + 3x^2 + 4x + 5 \) at some point, for example \( x = 2 \).

a) Evaluate the polynomial by definition (calculate every term separately).

b) Evaluate the polynomial using Horner's algorithm.

Compare both programs. Which one is shorter and which faster?

Using subroutines

Write a program from the previous exercise, where the evaluation of polynomial is performed in a subroutine. Use one parameter: a point x. How can you transfer the parameters from the main program to the subroutine? And how can you transfer the result back? Take care also that the subroutine preserves the register in the original state.

a) Evaluate the polynomial in several points, e.g., \( x = 0, 5, 42 \).

b) Store the points (for the evaluation) in a table. Moreover, store also the results of evaluation in a table. Use a loop to process the table.

Last modified: Tuesday, 23 October 2018, 9:55 PM