Chase Lighting (Elf Membership Card test program)

How to build/assemble the chase lighting program

This is a very simple chase lighting program for the Elf Membership Card. It is mainly used for testing my RaspiElf tools. I use the A18 cross assembler (see below how to get and build the assembler):

pi@cosmac:~/elf/RaspiElf/chase $ a18 chase.asm -Lb1 chase.lst -o chase.hex
1802/1805A Cross-Assembler (Portable) Ver 2.5
Copyright (c) 1985 William C. Colley, III
Copyright (c) 2017 Mark W. Sherman

No Errors

The cross assembler generates two output files: the object file (Intel hex file chase.hex) and the listing file (chase.lst). You can load the program into the Elf Membership Card the traditional way by setting the switches. Or upload it with the RaspiElf bin2elf tool. But for this we need a binary file first. A handy tool is Jacques Pelletier's Hex2bin (see below how to get and install Hex2bin).

pi@cosmac:~/elf/RaspiElf/chase $ hex2bin chase.hex
hex2bin v2.5, Copyright (C) 2017 Jacques Pelletier & contributors

Lowest address:   00000000
Highest address:  0000002C
Starting address: 00000000
Max Length:       45

Binary file start = 00000000
Records start     = 00000000
Highest address   = 0000002C
Pad Byte          = FF

How to build the A18 assembler for the Raspberry Pi

Get the source from the GIT repository:

pi@cosmac:~/elf $ git clone
Cloning into 'A18'...
remote: Counting objects: 81, done.
remote: Total 81 (delta 0), reused 0 (delta 0), pack-reused 81
Unpacking objects: 100% (81/81), done.
Checking connectivity... done.
pi@cosmac:~/elf $ 
If you have not installed GIT yet, then install it with sudo apt-get install git

Install the cross assmbler into /usr/local/bin

pi@cosmac:~/elf/A18 $ sudo install -m 557 a18 /usr/local/bin
pi@cosmac:~/elf/A18 $ 

How to build Hex2bin for the Raspberry Pi

Hex2bin is a Intel Hex or Motorola Hex file converter. You can download the tarball from Sourceforge

Unpack the tarball:

pi@cosmac:~/elf $ tar xvjf ~/Downloads/Hex2bin-2.5.tar.bz2

Build (compile):

pi@cosmac:~/elf $ cd Hex2bin-2.5/
pi@cosmac:~/elf/Hex2bin-2.5 $ make
gcc -c -std=c99 -O2 -Wall -pedantic hex2bin.c -o hex2bin.o
gcc -c -std=c99 -O2 -Wall -pedantic common.c -o common.o
gcc -c -std=c99 -O2 -Wall -pedantic libcrc.c -o libcrc.o
gcc -c -std=c99 -O2 -Wall -pedantic binary.c -o binary.o
gcc -O2 -Wall -o hex2bin hex2bin.o common.o libcrc.o binary.o
gcc -c -std=c99 -O2 -Wall -pedantic mot2bin.c -o mot2bin.o
gcc -O2 -Wall -o mot2bin mot2bin.o common.o libcrc.o binary.o


pi@cosmac:~/elf/Hex2bin-2.5 $ sudo make install
strip hex2bin
strip mot2bin
cp hex2bin mot2bin /usr/local/bin
cp hex2bin.1 /usr/local/man/man1
pi@cosmac:~/elf/Hex2bin-2.5 $

1802 Assembler Listing (chase.lst)

                ORG     0H
   0000   c0:11000000           LBR     MOVE
   0001   00:00000000
   0002   03:00000011
   0003   e3:11100011           SEX     R3              ; index register R3 for bit pattern point to 30H
   0004   90:10010000           GHI     R0              ; PC high byte is 0
   0005   b3:10110011           PHI     R3
   0006   f8:11111000           LDI     30H
   0007   30:00110000
   0008   a3:10100011           PLO     R3
   0009   f8:11111000           LDI     00000001B       ; bit pattern to move in (0030H)
   000a   01:00000001
   000b   53:01010011           STR     R3
   000c   64:01100100           OUT     P4              ; Rx = 0030H, INC Rx
   000d   6c:01101100           INP     P4              ; get switches Rx =0031H
   000e   23:00100011           DEC     R3              ; Rx = 0030H
   000f   fa:11111010           ANI     11111110B
   0010   fe:11111110
   0011   3a:00111010           BNZ     LEFT
   0012   1a:00011010
   0013   f0:11110000           LDX                     ; get pattern
   0014   f6:11110110           SHR
   0015   c7:11000111           LSNF
   0016   f8:11111000           LDI     10000000B   
   0017   80:10000000
   0018   30:00110000           BR      STORE
   0019   1f:00011111
   001a   f0:11110000           LDX                     ; get pattern
   001b   fe:11111110           SHL
   001c   c7:11000111           LSNF
   001d   f8:11111000           LDI     00000001B
   001e   01:00000001
   001f   53:01010011           STR     R3
   0020   f8:11111000           LDI     20
   0021   14:00010100
   0022   b2:10110010           PHI     R2              ; R2 wait counter
   0023   22:00100010           DEC     R2              ; wait loop about 0.5 s
   0024   92:10010010           GHI     R2
   0025   3a:00111010           BNZ     WAIT
   0026   23:00100011
   0027   c5:11000101           LSNQ                    ; toggle Q
   0028   7a:01111010           REQ
   0029   38:00111000           NBR     7bH             ; SEQ 
   002a   7b:01111011
   002b   30:00110000           BR      LOOP
   002c   0c:00001100

-- Peter Schmid - 2017-11-18


Topic attachments
I Attachment History Action Size Date Who Comment
Unknown file formatasm chase.asm r1 manage 1.0 K 2017-12-17 - 15:48 PeterSchmid  
Unknown file formatbin chase.bin r1 manage 0.1 K 2017-12-17 - 15:48 PeterSchmid  
Unknown file formathex chase.hex r1 manage 0.1 K 2017-12-17 - 15:48 PeterSchmid  
Unknown file formatlst chase.lst r1 manage 3.2 K 2017-12-17 - 15:48 PeterSchmid  
Edit | Attach | Watch | Print version | History: r7 < r6 < r5 < r4 < r3 | Backlinks | Raw View | Raw edit | More topic actions
Topic revision: r7 - 2017-12-25 - PeterSchmid
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback