Low Level

Specification

    • Low-level programming

      • understanding of and ability to write low-level code that uses various addressing modes: immediate, direct, indirect, indexed and relative

Low Level Programming

You can find the LMC simulator here: Peter Higginson's LMC

There is sufficient detail on the lesson PowerPoint slides and low level worksheet. The key to understanding this paradigm is, as with the others, practice!

I do want to guide you a little on the use of labels, which can be confusing at first, especially when looking at the pre-release tasks for November '16 and June '17.

<label> <data> is a symbolic addressing feature that many assemblers support.

For example:

LDD num 1

ADD num 2

STO total

END

num1: 7

num2: 6

total:

is the 9608 syllabus mnemonic equivalent of total = num1 + num2 in a high level language.

num1 is a symbolic address for a memory location, and 7 is the data which the assembler would store in that address. The actual address is allocated dynamically. Total did not need a value, as we are only going to store a value to that address, not use it as part of the calculation.

A final note, we use LDD because we're asking for the address, num1's contents to be loaded. Labels do not work like substitution. I.E. when assembled, the contents of num1 are substituted for any occurrence of num1. This would result in an immediate addressing method. It is the label, acting as a substitute for a later allocated memory address, which can be optionally populated with the <data> item you specify.

Finally, apart from their secondary use as labeling instructions (plenty of examples in the low level worksheet), we can use labels as the start of a block of memory, thus acting line an array. When used in this scenario, we almost always use the index register to offset from the start of the memory address.

Indexed addressing is used to implement arrays (a high-level data structure). Use the mnemonics from the 9608 instruction set (LDX and STX). To set the index register use LDR #n.

E.g.

LDR #0

loop: LDX array

OUT

INC IX

JMP loop

pointer: start

array: “A”

“B”

“C”

:

High-level pseudocode:

i = 0

WHILE TRUE

output array[i]

increment i

ENDWHILE

The current instruction set in the 9608 syllabus has no provision to test the value of the index register, so it is not possible to write a FOR loop in any simple way. However, real processors do have this facility.

This fascinating video looks at an EDSAC and modern 68x00 assembler. It covers directives and relative and indirect addressing.

Here is a video showing how a simple C program is converted to machine code.