Following Geoff's hand code is the code required for the KENBAK-1 AS assembler.
Quote:
Originally Posted by Geoff Harrison
Code:
Addr Value
---- ---------
; Display Cylon lights on the Kenbak-1 front panel
; Version 2
003 004 ; initialize PC
004 223 000 START LOAD X, #0 ; X = 0
006 026 033 LOOP LOAD INDEX A, TABLE ; set A = next byte from table
010 044 004 JPD A=0, START ; restart if at end of tale
012 034 200 STORE A, 0200 ; display A on LEDs
014 367 022 JMD WAIT ; pause
016 203 001 ADD X, #1 ; decrement X
020 347 006 JPD LOOP ; loop to get next pattern
;
022 000 WAIT .equ 0 ; return address will be stored here
023 123 020 LOAD B, #020 ; delay for a count of 020
025 113 001 WAIT1 SUB B, #1 ; decrement B
027 143 025 JPD B!=0, WAIT1 ; if B != 0 jump to label WAIT1
031 357 022 JPI WAIT ; return
;
033 201 TABLE .equ 10000001
034 102 .equ 01000010
035 044 .equ 00100100
036 030 .equ 00011000
037 044 .equ 00100100
040 102 .equ 01000010
041 201 .equ 10000001
042 000 .equ 00000000
|
Code:
; Display Cylon lights on the Kenbak-1 front panel
; Version 2
; By Geoff Harrison
; Syntax and AS conversion by Grant Stockly
cpu KENBAK ; Assemble for the KENBAK
include kenbak.inc ; Kenbak include file
relaxed on ; Allow non-intel constant formats
;
ORG 003o ; Location of PC Register
DB 004o ; Example on how to "setup" PC Register
;
ORG 004o ; First non-special address
;
START: LDC X, 0 ; Load constant 0 to X
LOOP: LDX A, TABLE ; set A = next byte from table
JDZ A, START ; restart if at end of table
STM A, Lamps ; display A on LEDs
JMMD WAIT ; pause
ADC X, 1 ; increment X
JMP LOOP ; loop to get next pattern
;
WAIT: DB 0 ; return address will be stored here
LDC B, 020o ; delay for a count of 020
WAIT1: SBC B, 1 ; decrement B
JDNZ B, WAIT1 ; if B != 0 jump to label WAIT1
JMI WAIT ; return
;
TABLE: DB 0b10000001 ;
DB 0b01000010 ;
DB 0b00100100 ;
DB 0b00011000 ;
DB 0b00100100 ;
DB 0b01000010 ;
DB 0b10000001 ;
DB 0b00000000 ;
;
;END
I'm not too happy with the listing output. I will have to figure out what to do. Do you guys think the listing is OK with all of the (MACRO) lines? I guess it is helpful to know what your code expands to...
You may notice some differences between the assembled code and Geoff's hand code. John used the condition "Zero" when "Unconditional" was specified. Geoff used "Positive Non-Zero", but this difference should not affect the operation of the code. My kenbak is still in pieces from scanning the motherboard. Geoff, can you key in this version of the cylon program and see if it works?
I'll try to have the online assembler going soon...
Here is the assembled code:
Code:
AS V1.42 Beta [Bld 55] - source file cylon2.asm - page 1 - 10/13/2007 14:14:28
1/ 0 : ; Display Cylon lights on the Kenbak-1 front panel
2/ 0 : ; Version 2
3/ 0 : ; By Geoff Harrison
4/ 0 : ; Syntax and AS conversion by Grant Stockly
5/ 000 : cpu KENBAK ; Assemble for the KENBAK
6/ 000 : ;macexp off ; Turn off macro expansion
7/ 000 : include kenbak.inc ; Kenbak include file
(1) 439/ 000 : listing on
8/ 000 : relaxed on ; Allow non-intel constant formats
9/ 000 : ;
10/ 003 : ORG 003o ; Location of PC Register
11/ 004 : 004 DB 004o ; Example on how to "setup" PC Register
12/ 004 : ;
13/ 004 : ORG 004o ; First non-special address
14/ 004 : ;
15/ 004 : (MACRO) START: LDC X, 0 ; Load constant 0 to X
15/ 006 : 223 000 LOAD Immediate, X, 0
16/ 006 : (MACRO) LOOP: LDX A, TABLE ; set A = next byte from table
16/ 010 : 026 033 LOAD Indexed, A, TABLE
17/ 010 : (MACRO) JDZ A, START ; restart if at end of table
17/ 012 : 044 004 JMPD A, Zero, START
18/ 012 : (MACRO) STM A, Lamps ; display A on LEDs
18/ 014 : 034 200 STORE Memory, A, LAMPS
19/ 014 : (MACRO) JMMD WAIT ; pause
19/ 016 : 364 022 JMPMD Unconditional, Zero, WAIT
20/ 016 : (MACRO) ADC X, 1 ; increment X
20/ 020 : 203 001 ADD Immediate, X, 1
21/ 020 : (MACRO) JMP LOOP ; loop to get next pattern
21/ 022 : 344 006 JMPD Unconditional, Zero, LOOP
22/ 022 : ;
23/ 023 : 000 WAIT: DB 0 ; return address will be stored here
24/ 023 : (MACRO) LDC B, 020o ; delay for a count of 020
24/ 025 : 123 020 LOAD Immediate, B, 020O
25/ 025 : (MACRO) WAIT1: SBC B, 1 ; decrement B
25/ 027 : 113 001 SUB Immediate, B, 1
26/ 027 : (MACRO) JDNZ B, WAIT1 ; if B != 0 jump to label WAIT1
26/ 031 : 143 025 JMPD B, Non_Zero, WAIT1
27/ 031 : (MACRO) JMI WAIT ; return
27/ 033 : 354 022 JMPI Unconditional, Zero, WAIT
28/ 033 : ;
29/ 034 : 201 TABLE: DB 0b10000001
30/ 035 : 102 DB 0b01000010
31/ 036 : 044 DB 0b00100100
32/ 037 : 030 DB 0b00011000
33/ 040 : 044 DB 0b00100100
34/ 041 : 102 DB 0b01000010
35/ 042 : 201 DB 0b10000001
36/ 043 : 000 DB 0b00000000
37/ 043 :
38/ 043 : ;END
symbol table (* = unused):
------------------------
A : 0 - | *ARCHITECTURE : i386-unknown-win32 - |
B : 1 - | *BIGENDIAN : 0 - |
*BRANCHEXT : 0 - | *CASESENSITIVE : 0 - |
*CONSTANT : 3 - | *CONSTPI : 3.141592653589793 - |
*DATE : 10/13/2007 - | *DEF : 5 - |
*DEFERRED : 5 - | *FALSE : 0 - |
*FOUR : 4 - | *FOUR_PLACES : 4 - |
*FULLPMMU : 1 - | *HAS64 : 1 - |
*HASDSP : 0 - | *HASFPU : 0 - |
*HASPMMU : 0 - | *IMM : 3 - |
IMMEDIATE : 3 - | *IND : 5 - |
INDEXED : 6 - | *INDIND : 7 - |
*INDIRECT : 5 - | *INEXTMODE : 0 - |
*INIX : 7 - | *INLWORDMODE : 0 - |
*INMAXMODE : 0 - | *INPUT : FF - |
*INSRCMODE : 0 - | *INSUPMODE : 0 - |
*INX : 6 - | *L : 2 - |
LAMPS : 80 - | *LEFT : 2 - |
*LISTON : 1 - | LOOP : 6 C |
*MACEXP : 1 - | *MEM : 4 - |
MEMORY : 4 - | *MOMCPU : EBA - |
*MOMCPUNAME : KENBAK - | *NEG : 5 - |
*NEGATIVE : 5 - | *NESTMAX : 100 - |
NON_ZERO : 3 - | *NZR : 3 - |
*ONE : 1 - | *ONE_PLACE : 1 - |
*OUTPUT : 80 - | *PACKING : 0 - |
*PADDING : 1 - | *PC : 3 - |
*PNZ : 7 - | *POSITIVE_NON_ZERO : 7 - |
*POSITIVE_OR_ZERO : 6 - | *POZ : 6 - |
*R : 0 - | *REGA : 0 - |
*REGB : 1 - | *REGISTERA : 0 - |
*REGISTERB : 1 - | *REGISTERPC : 3 - |
*REGISTERX : 2 - | *REGPC : 3 - |
*REGX : 2 - | *RELAXED : 1 - |
*RIGHT : 0 - | *SA : 81 - |
*SB : 82 - | *STAA : 81 - |
*STAB : 82 - | START : 4 C |
*STATUSA : 81 - | *STATUSB : 82 - |
*STATUSX : 83 - | *STAX : 83 - |
*SWITCHES : FF - | *SX : 83 - |
TABLE : 1B C | *THREE : 3 - |
*THREE_PLACES : 3 - | *TIME : 14:14:28 - |
*TRUE : 1 - | *TWO : 2 - |
*TWO_PLACES : 2 - | *UNCND : 3 - |
UNCONDITIONAL : 3 - | *VERSION : 142F - |
WAIT : 12 C | WAIT1 : 15 C |
X : 2 - | ZERO : 4 - |
*ZRO : 4 - |
95 symbols
80 unused symbols
defined macros:
---------------
ADC | ADI
ADIX | ADM
ADX | ANC
ANI | ANIX
ANM | ANX
CBR | CLR
DEC | HLT
INC | JDN
JDNZ | JDP
JDPZ | JDZ
JIN | JINZ
JIP | JIPZ
JIZ | JMI
JMMD | JMMI
JMP | JUMP
LDC | LDI
LDIX | LDM
LDX | LNC
LNI | LNIX
LNM | LNX
LSL | LSR
MDN | MDNZ
MDP | MDPZ
MDZ | MIN
MINZ | MIP
MIPZ | MIZ
NOP | ORC
ORI | ORIX
ORM | ORX
ROL | ROR
SBC | SBI
SBIX | SBM
SBR | SBRC
SBRS | SBX
SER | STC
STI | STIX
STM | STX
74 macros
codepages:
----------
STANDARD (0 changed characters)
0.03 seconds assembly time
477 lines source file
488 lines incl. macro expansions
2 passes
0 errors
0 warnings