I see there is another assembler for the µKenbak here, but frankly I never did like the original mnemonics. So I decided to
write my own patterned after the 6800, although I used shr/shl instead of asr and asl. And I used variations of call for Jump
and Mark instead of the 6800 jsr, since the conditional jumps and subroutine calls would have the same names. Here's the
listing output for my test program for the assembler, just to show the syntax, it doesn't do anything useful:
004: 001 # Test program for uKenbak-1 assembler version 1.3 or later (6/15/19).
004: 002 # Program doesm't do anything useful, just testing syntax.
004: 003 # By default, PC will start at 4.
004: 004 # arithmetic, load/store and logical ops and addressing modes
004: 003 010 005 lbl adda #8 immediate value in decimal
006: 103 010 006 addb #010 same thing in octal
010: 024 001 007 lda b memory reference (using predefined reg b for reg transfer)
012: 235 220 008 stx (ptr) indirect reference
014: 306 204 009 ora data,x indexed
016: 337 220 010 lnega (ptr),x indirect/indexed
020: 011 # jumps and calls
020: 344 004 012 jmp lbl unconditional jump
022: 043 030 013 jane lbl2-2 jump if a not equal 0, , using arithmetic with label
024: 257 221 014 jxgt (ptr+one) jump indirect if x gt 0, using arithmetic inside ()
026: 364 041 015 call sub call to subroutine
030: 174 220 016 cbeq (ptr) call indirect to subroutine if b equal 0
032: 017 # set and skips
032: 018 lbl2
032: 122 204 019 set1 fox,2 set bit 2 of data to 1
034: 272 205 020 skp0 data+1,7 skip if bit 7 of data is 0
036: 021 # shifts and rotates
036: 001 022 shra 1+SHIFT shift a right 4 places
037: 361 023 rolb 2 rotate b left 2 places
040: 000 024 hlt halt
041: 000 025 sub db 0 leave room for return address
042: 200 026 nop no op
043: 023 222 027 lda #0222
045: 123 144 028 ldb #100
047: 360 029 sys system call (uKenbak-1 extension)
050: 023 222 030 sysp 0222,100 system call using parameters
052: 123 144
054: 360
055: 354 041 031 jmp (sub) return
057: 032
204: 033 fox org 0204 placing data after overflow/carry regs
204: 123 034 data db 0123 data in octal
205: 067 035 db 55 data in decimal
206: 124 145 040 036 ds "Te st" string with embedded space
211: 163 164
213: 124 145 042 037 ds 'Te"st' string with embedded apostrophe
216: 163 164
001: 038 one equ 1
003: 039 SHIFT equ 3
220: 000 040 ptr db 0 placehold for indirect
221: 000 041 db 0
Input can be in upper or lower case, case ignored. Syntax is: label opcode operands comment # global comment All fields delimited by one or more spaces or tabs. All fields optional except opcode, although a completely blank line is okay,
and a label by itself is okay. Global comments (no opcode) must begin with # in column 1. A label on a line by itself cannot
have a comment (since the first word would be taken as an opcode). Opcodes in table below. All should be obvious. Variations of "call" used for jump and mark.
adda,addb,addx,suba,subb,subx,lda,ldb,ldx,sta,stb,stx,ora,anda,lnega,
jmp,jane,jaeq,jalt,jage,jagt,jbne,jbeq,jblt,jbge,jbgt,jxne,jxeq,jxlt,jxge,jxgt,
call,cane,caeq,calt,cage,cagt,cbne,cbeq,cblt,cbge,cbgt,cxne,cxeq,cxlt,cxge,cxgt,
set0,set1,skp0,skp1
shra,rora,shla,rola,shrb,rorb,shlb,rolb,
hlt,nop
Pseudo-ops (discussed below):
sys,sysp,org,db,ds,equ
Immediate addressing uses # prefix, indirect addressing denoted using (), indexing by ,x and bit fields for set/skip by ,n
where n=0-7. Only decimal and octal supported; octal constants denoted by leading 0, e.g. 077 (not Python syntax of 0o).
Simple arithmetic in operands e.g. data+2 or lbl-lb2 is now allowed. See examples above, such as lbl-2, (ptr+one), 1+SHIFT
etc. Operands (except strings) cannot have embedded spaces.
Strings (ds pseudo-op) can be delimited by quotes "test" or apostrophes 'test'. Spaces okay.
Default origin is 4, changeable using org opcode. Data can be defined using db opcode (data byte).
In addition to the sys pseudo-op, which generates an octal 360 opcode, there is also a sysp macro that takes one or two
parameters (separated by a comma). The first parameter is loaded into the A accumulator before the call, and the second
(if present) into the B accumulator. Immediate addressing is implied (don't use #'s). Equated symbols can be used however.
So:
SYS_DELAY equ 0222
sysp SYS_DELAY,100 delay for 100 ms
is the same as:
lda #0222
ldb #100
sys delay for 100 ms
Predefined registers/locations are a, b, c, x, pc, out, in, oca, ocb, ocx, in where the latter three are the overflow/carry registers.
Tabs are converted to blanks in the output listing file. Default tab width is 8, but this can be changed with the tab pseudo-op:
e.g. tab 4 Setting tab 0 turns off the tab expansion.
Run on command line using: kenbak_asm filename.asm (standalone) or: python kenbak_asm.py filename.asm (from Python source) Listing output will go to standard out. Save it using >filename.lst is desired. Octal output will go to filename.out. Errors denoted
using asterisks in the listing file instead of numbers in the address, opcode and operand fields.
The Python 3 script, the test program above, as well as a stand-alone executable for those that don't have Python installed, are
available from one of my websites:
http://www.softwest.com/kenbak_asm/kenbak_asm.exe
http://www.softwest.com/kenbak_asm/kenbak_asm.py
http://www.softwest.com/kenbak_asm/test.asm
Run the test source file using the standalone exe simply by typing: kenbak_asm test.asm in a Command Prompt.
I'm releasing all of this into the public domain, so feel free to distribute if you wish.
I see there is another aseembler for the µKenbak here, but frankly I never did like the original mnemonics. So I decided to write my own patterned after the 6800, although I used shr/shl instead of asr and asl. And I used variations of call for Jump and Mark instead of the 6800 jsr, since the conditional jumps and subroutine calls would have the same names. Here's the listing output for my test program for the assembler, just to show the syntax, it doesn't do anything useful:
004: # test program for µKenbak-1 assembler. By default, will start at 4 004: # arithmetic, load/store and logical ops and addressing modes 004: 003 010 lbl adda #8 immediate value in decimal 006: 103 010 addb #010 same thing in octal 010: 024 001 lda b memory reference (using predefined reg b for reg transfer) 012: 235 206 stx (ptr) indirect reference 014: 306 204 ora data,x indexed 016: 337 206 lnega (ptr),x indirect/indexed 020: #jumps and calls 020: 344 004 jmp lbl unconditional jump 022: 043 032 jane lbl2 jump if a not equal 0 024: 257 206 jxgt (ptr) jump indirect if x gt 0 026: 364 041 call sub call to subroutine 030: 174 206 cbeq (ptr) call indirect to subroutine if b equal 0 032: # set and skips 032: lbl2 032: 122 204 set1 data,2 set bit 2 of data to 1 034: 272 204 skp0 data,7 skip if bit 7 of data is 0 036: # shifts and rotates 036: 001 shra 4 shift a right 4 places 037: 361 rolb 2 rotate b left 2 places 040: 000 hlt halt 041: 000 sub db 0 leave room for return address 042: 200 nop no op 043: 360 sys system call (µKenbak-1 extension) 044: 354 041 jmp (sub) return 046: 204: org 0204 placing data after overflow/carry regs 204: 123 data db 0123 data in octal 205: 067 db 55 data in decimal 206: 000 ptr db 0 placehold for indirect
Input can be in upper or lower case, case ignored. Syntax is: label opcode operands comment # global comment All fields delimited by one or more spaces or tabs. All fields optional except opcode, although a completely blank line is okay, and a label by itself is okay. Global comments (no opcode) must begin with # in column 1. A label on a line by itself cannot have a comment (since the first word would be taken as an opcode). Opcodes in table below. All should be obvious. Variations of "call" used for jump and mark.
adda,addb,addx,suba,subb,subx,
lda,ldb,,ldx,,sta,stb,stx,
ora,anda,lnega,
jmp,
jane,jaeq,jalt,jage,jagt,
jbne,jbeq,jblt,jbge,jbgt,
jxne,jxeq,jxlt,jxge,jxgt,
call,
cane,caeq,calt,cage,cagt,
cbne,cbeq,cblt,cbge,cbgt,
cxne,cxeq,cxlt,cxge,cxgt,
set0,set1,skp0,skp1
shra,rora,shla,rola,
shrb,rorb,shlb,rolb,
hlt,nop,sys,
org,db
Immediate addressing uses # prefix, indirect addressing denoted using (), indexing by ,x and bit fields for set/skip by ,n where n=0-7. Only decimal and octal supported; octal constants denoted by leading 0, e.g. 077 (not Python syntax of 0o). Arithmetic in operands e.g. data+2 is not allowed. Default origin is 4, changeable using org opcode. Data can be defined using db opcode (data byte). Predefined registers/locations are a, b, c, x, pc, out, in, oca, ocb, ocx, in where the latter three are the overflow/carry registers. Run on command line using: kenbak_asm filename.asm (standalone) or: python kenbak_asm.py filename.asm (from Python source) Listing output will go to standard out. Save it using >filename.lst is desired. Octal output will go to filename.out. Errors denoted using asterisks in the listing file instead of numbers in the address, opcode and operand fields.
The Python 3 script, the test program above, as well as a stand-alone executable for those that don't have Python installed, are available from one my website:
Run the standalone simply by typing: kenbak_asm test.asm in a Command Prompt.
I'm releasing all of this into the public domain, so feel free to distribute if you wish. Let me know if you find any bugs or have suggestions or other comments, at tcro...@softwest.com
Arithmetic in operands e.g. data+2 is not allowed.
Does this support compile-time expressions in the operand field, (e.g.: sta lbl+1)?
--
You received this message because you are subscribed to the Google Groups "Altair-Duino" group.
To unsubscribe from this group and stop receiving emails from it, send an email to altair-duino...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/altair-duino/53193abf-02ed-4d5a-8d10-a56f44c675bc%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
I see there is another aseembler for the µKenbak here, but frankly I never did like the original mnemonics. So I decided to write my own patterned after the 6800, although I used shr/shl instead of asr and asl. And I used variations of call for Jump and Mark instead of the 6800 jsr, since the conditional jumps and subroutine calls would have the same names. Here's the listing output for my test program for the assembler, just to show the syntax, it doesn't do anything useful:
004: # test program for µKenbak-1 assembler. By default, will start at 4 004: # arithmetic, load/store and logical ops and addressing modes 004: 003 010 lbl adda #8 immediate value in decimal 006: 103 010 addb #010 same thing in octal 010: 024 001 lda b memory reference (using predefined reg b for reg transfer) 012: 235 206 stx (ptr) indirect reference 014: 306 204 ora data,x indexed 016: 337 206 lnega (ptr),x indirect/indexed 020: #jumps and calls 020: 344 004 jmp lbl unconditional jump 022: 043 032 jane lbl2 jump if a not equal 0 024: 257 206 jxgt (ptr) jump indirect if x gt 0 026: 364 041 call sub call to subroutine 030: 174 206 cbeq (ptr) call indirect to subroutine if b equal 0 032: # set and skips 032: lbl2 032: 122 204 set1 data,2 set bit 2 of data to 1 034: 272 204 skp0 data,7 skip if bit 7 of data is 0 036: # shifts and rotates 036: 001 shra 4 shift a right 4 places 037: 361 rolb 2 rotate b left 2 places 040: 000 hlt halt 041: 000 sub db 0 leave room for return address 042: 200 nop no op 043: 360 sys system call (µKenbak-1 extension) 044: 354 041 jmp (sub) return 046: 204: org 0204 placing data after overflow/carry regs 204: 123 data db 0123 data in octal 205: 067 db 55 data in decimal 206: 000 ptr db 0 placehold for indirect
Input can be in upper or lower case, case ignored. Syntax is: label opcode operands comment # global comment All fields delimited by one or more spaces or tabs. All fields optional except opcode, although a completely blank line is okay, and a label by itself is okay. Global comments (no opcode) must begin with # in column 1. A label on a line by itself cannot have a comment (since the first word would be taken as an opcode). Opcodes in table below. All should be obvious. Variations of "call" used for jump and mark.
adda,addb,addx,suba,subb,subx,
lda,ldb,,ldx,,sta,stb,stx,
ora,anda,lnega,
jmp,
jane,jaeq,jalt,jage,jagt,
jbne,jbeq,jblt,jbge,jbgt,
jxne,jxeq,jxlt,jxge,jxgt,
call,
cane,caeq,calt,cage,cagt,
cbne,cbeq,cblt,cbge,cbgt,
cxne,cxeq,cxlt,cxge,cxgt,
set0,set1,skp0,skp1
shra,rora,shla,rola,
shrb,rorb,shlb,rolb,
hlt,nop,sys,
org,db
Immediate addressing uses # prefix, indirect addressing denoted using (), indexing by ,x and bit fields for set/skip by ,n where n=0-7. Only decimal and octal supported; octal constants denoted by leading 0, e.g. 077 (not Python syntax of 0o). Arithmetic in operands e.g. data+2 is not allowed. Default origin is 4, changeable using org opcode. Data can be defined using db opcode (data byte). Predefined registers/locations are a, b, c, x, pc, out, in, oca, ocb, ocx, in where the latter three are the overflow/carry registers. Run on command line using: kenbak_asm filename.asm (standalone) or: python kenbak_asm.py filename.asm (from Python source) Listing output will go to standard out. Save it using >filename.lst is desired. Octal output will go to filename.out. Errors denoted using asterisks in the listing file instead of numbers in the address, opcode and operand fields.
The Python 3 script, the test program above, as well as a stand-alone executable for those that don't have Python installed, are available from one my website:
004: 003 010 lbl adda #8 immediate value in decimal
you would set the address to 004, and then start keying in values, 003, 010 etc from the listing.
Lastly, might I suggest you output 3-digit octal numbers (like Dave's assembler) instead of 4-digits because a file with 3-digits can be sent to the uKenbak-1 at 9600 baud without loss, while 4-digits causes problems.