writing a test program in assembly

The computer is now at a stage where it is capable of storing and executing programs! Now would be a good point to write a program to test that the computer is working correctly.

You can learn to write programs in 6502 assembly, you can take my learn 6502 assembly course.

the plan

I will write this program in assembly language, then I will use an assembler to assemble the program into machine code that the CPU can understand. I will then program the EEPROM with this code. The assembler that I use is VASM. You can use any assembler, as long as it works with the 6502 instruction set. This is because assembly language is specific to the processor that it is running on! Therefore, I will be writing in 6502 assembly. What I will do is connect two LEDs to the peripheral ports of the VIA and write a program that will turn them on and off. The steps that will look like:

set all lines of PORT B to output
set the pins LOW
set the pins HIGH
repeat indefinitely
  .org $8000

  lda #$ff
  sta $6002

  lda #$50
  sta $6000

  sta $6000

  jmp loop

  .org $fffc
  .word reset
  .word $0000

There are different options which you can use with VASM to assemble a program but these are the ones that I will be using for this program:

vasm6502_oldstyle -dotdir -Fbin -o led.out led.s

Using the oldstyle module allows further options to be called. The one that I have used here is –dotdir. –dotdir allows directives to be preceded by a dot.

The –Fbin option calls in the binary output module. This is needed because the program needs to be in binary, as this is what an EEPROM needs.

old 8-bit style syntax

gives a raw binary output

we need a binary file

-Fbin selects the simple binary output module

spaces or tab or assembler will give an error

.org origin directive. tells assemble where the following codes goes in memory

need to tell assembler want to use directives with .

At this stage I can say that this is now a programmable computer, which can be programmed in machine code and assembly (via a suitable assembler).