U.H. NOD1 - System Architecture

The nod1, pronounced "node one" is a low-cost experimental computer architecture, being developed for use in undergraduate projects involving computer architecture.  The architecture is entirely eight bit in that all registers are eight bits in length.  The following are the registers visible to an assembly language programmer.

The PC and CC registers are special purpose, the program counter refers to the next instruction to execute and the condition code register contains status flags that reflect the results of recent instructions.  The CC flags, in order (N,Z,V,C) are in the least significant bit positions, with C being the least significant.

Addressing Modes

The nod1 architecture supports the six addressing modes summarized in the following table.  The symbol MN refers to the instruction mnemonic.  In considering each addressing mode, the effective address or EA is the address where data is, or will be stored.  'REG' is the name of a register and 'offset', 'data', and 'address' are constant values.

NOD1 - ADDRESSING MODES
     
NameInstruction FormatDescription
Implied MN No operand, details implied
Immediate MN data Operand is the data
Direct MN [address] Operand is the EA
Register-Offset     MN [REG+offset]     Register plus offset is EA
Pre-DecrementMN [--REG] Register is decremented, forming EA
Post-IncrementMN [REG++] Value before incrementing, is the EA

An instruction uses a so called effective address or EA to address data in memory.  Each addressing mode produces the effective address in a different way. The implied addressing mode is an exception as it does not perform memory addressing, hence no effective address is produced.  An example instruction that uses implied addressing is the clra instruction which clears the A register by assigning it the value zero.  In the figure below, A is the address of an implied mode instruction.


Implied addressing

Immediate addressing places data immediately after the opcode.  Such an instruction at address A has data stored at address A+1, hence EA = A+1. 


Immediate addressing

Direct addressing places the effective address value after the opcode itself. 


Direct addressing

The register-offset addressing mode calculates the effective address by adding the value in either the X or S register, to the offset value stored after the opcode.


Register-offset addressing

The pre-decrement addressing mode first decrements either the X or S register to form the effective address.  The post-increment addressing mode uses the value in either the X or S register as the effective address, and then increments.

Pre-decrement addressing Post-increment addressing

These few addressing modes can be used together to simulate other addressing modes.  To simulate indirect addressing, first use an instruction with direct addressing to load the effective address into the X register. Next, use an instruction with register-offset addressing.

Assembly Language Format

In writing assembly code we will be concerned with so-called labels.  A programmer should not be burdened with memorizing addresses in a program.  A label is a symbolic name for an address.  The assembler is responsible for determining the actual address assigned to each label, and properly using the label.  The nod1 assembly language file format broken into lines.  A line contains at most one instruction.  A comment can be inserted into a line or an entire line cab be a comment.  An instruction line is organized into four possible fields.  A comment line starts with a semicolon ';'.  The following code outlines the format.
; Here is a comment line
Symbol:  Directive   Data     ; A comment
Label:   Instruction Operand  ; Another comment

The following are some useful directives:

ORG Address
Sets the point of assembly to 'Address' for the following code.
 
FCB   val1, val2, ...
Reserve a byte in memory for each value listed.  The address of the first byte may be assigned to a label.
 
RMB   n
Reserve n bytes but donb't assign any specific values to them.  The address of the first byte may be assigned to a label.

The following is a first example program.  The dollar sign '$' prefix is used to indicate hexadecimal.

; ex1.asm - An example program
       ORG    $100
Ax:    FCB    $12   ; A value
Bx:    FCB    $36   ; another
Sx:    RMB    1     ; sum goes here

       ORG    $10
Start: lds    $FF   ; initialize stack
       lda    [Ax]  ; get a value
       adda   [Bx]  ; add to it
       sta    [Sx]  ; save the sum
Done:  jmp    Done  ; done for now

To hand assemble the code, perform the first pass by writing the outline of a list file, like the following.  The abbreviations Addx and Cont stand for base address and memory contents, respectviely.  The base address and memory content values are expressed in hexadecimal. Write a blank for each referenced address.  The nod1 instruction list contains a listing of all the instructions. 

Addx Cont   ; ex1.asm - An example program
                   ORG    $100
  00 12     Ax:    FCB    $12   ; A value
  01 36     Bx:    FCB    $36   ; another
  02 ??     Sx:    RMB    1     ; sum goes here

                   ORG    $10
  10 02 FF  Start: lds    $FF   ; initialize stack
  12 40            lda    [Ax]  ; get a value
  14 44            adda   [Bx]  ; add to it
  16 68            sta    [Sx]  ; save the sum
  18 E0     Done:  jmp    Done  ; done for now

To perform the second pass, list the labels, go back and fill in the blanks and then write the hexadecimal file.  In examining the file above, the following symbol table is produced.

Ax   = $00
Bx   = $01
Sx   = $02
Done = $18

Here is the final list file.

Addx Cont   ; ex1.asm - An example program
                   ORG    $100
  00 12     Ax:    FCB    $12   ; A value
  01 36     Bx:    FCB    $36   ; another
  02 ??     Sx:    RMB    1     ; sum goes here

                   ORG    $10
  10 02 FF  Start: lds    $FF   ; initialize stack
  12 40 00         lda    [Ax]  ; get a value
  14 44 01         adda   [Bx]  ; add to it
  16 68 02         sta    [Sx]  ; save the sum
  18 E0 18  Done:  jmp    Done  ; done for now

A hexadecimal file is organized into records, each record is composed of bytes that are space separated. 

To form the checksum byte, add up all the preceeding bytes in the record and form the ones complement of the lower 8 bits in the sum (just invert the lower 8 bits).  In this way, in adding all the bytes in the record, the lower 8 bits of the sum should equal $FF.  Having any other value appear indicates a transmission error.

The end of the file is marked by a zero-length record.  In the case of this record, the address is considered to be the program start address.  Here is the hexadecimal file for the above example.

00 02 12 36 B5
10 0A 02 FF 40 00 44 01 68 02 E0 18 41
10 00 EF


Written by Jonathan Hill for EE335 - The Digital Computer Organization course at the University of Hartford, USA
Revision Date: Sun Nov 3 22:38:13 2002