mark@unisec.usi.com (Mark Rinfret) (05/11/87)
The following files are a minimal set of tests for the C-Power (tm) compatible assembler posted earlier. ---------- cut here ---------- #! /bin/sh # This is a shell archive, meaning: # 1. Remove everything above the #! /bin/sh line. # 2. Save the resulting text in a file. # 3. Execute the file with /bin/sh (not csh) to create the files: # assmtest.a # atest.a # atest1.a # atest2.a # chrtest.a # chrtest1.a # chrtest2.a # condtest.a # This archive created: Mon May 11 14:05:25 1987 export PATH; PATH=/bin:$PATH if test -f 'assmtest.a' then echo shar: will not over-write existing file "'assmtest.a'" else cat << \SHAR_EOF > 'assmtest.a' ;****************************************** ; Test file for the 6502 assembler - C-ASSM ; assemble as ; assm -niv assmtest.a ; and compare output with assmtest.l ;****************************************** ;; comment treatment ;****************************************** aa = $10; ';' immediately after the '0' B = $20 space to comment subfield C = $30 tab to comment subfield DEFGHIjkl = $FFEE D =DEFGHIjkl ;****************************************** ; Number formats ;****************************************** .byte %0101 ; binary number .byte 022,@22 ; octal numbers - two forms .byte 22 ; decimal number .byte $22,$ff,$FF ; hex - upper/lower case .byte 'a,'b ; single ASCII characters ;****************************************** ;; ASCII character string ;****************************************** .byte "abcd\n\f",0 ; new line, form feed ;****************************************** ; Operation checks ;****************************************** .word aa+B ; addition .word aa-B ; subtraction .word aa*B ; multiplication .word B/aa ; division .word C%B ; modulo .word B^C ; exclusive OR .word ~C ; one's complement .word B&C ; logical AND .word aa|B ; logical OR .word <D ; low byte .word >D ; high byte .word * ; current location .word aa,B,C .word B*[aa+C] ; one level of parenthesis .dbyt D ; high byte-low byte word .word D/256,D%256 ;****************************************** ; Addressing Mode Check ;****************************************** lda =aa ; immediate addressing lda #aa ; immediate addressing, alternate lda D ; direct addessing LDA aa ; page zero addressing, aa < 256 a1 = 512 ;absolute expressions a2 = 500 lda a1-a2 ; also page zero asl A ; accumulator addressing AsL a ; accumulator addressing also brk ; implied addressing lda (aa,X) ; indirect,X addressing lda (aa),Y ; indirect,Y addressing lda aa,X ; zero page,X addressing lda D,X ; absolute,X addressing lda D,Y ; absolute,Y addressing bcc *-$10 ; relative addressing jmp (D) ; indirect addressing ldx aa,Y ; zero page,Y addressing ldx aa,y ; alternate index name .nlst ;****************************************** ; opcode check ;****************************************** adc =01 and =01 asl A bcc *+2 bcs *+2 beq *+2 bit $01 bmi *+2 bne *+2 bpl *+2 brk bvc *+2 bvs *+2 clc cld cli clv cmp =01 cpx =01 cpy =01 dec $01 dex dey eor =01 inc $01 inx iny jmp *+3 jsr *+3 lda =01 ldx =01 ldy =01 lsr A nop ora =01 pha php pla plp rol A ror A rti rts sbc =01 sec sed sei sta $01 stx $01 sty $01 tax tay tsx txa txs tya SHAR_EOF fi # end of overwriting check if test -f 'atest.a' then echo shar: will not over-write existing file "'atest.a'" else cat << \SHAR_EOF > 'atest.a' SHAR_EOF fi # end of overwriting check if test -f 'atest1.a' then echo shar: will not over-write existing file "'atest1.a'" else cat << \SHAR_EOF > 'atest1.a' ; test program for C/ASSM assembler ; checks < and > operators, offsets on ; external identifiers, and .dseg ; .ref prline .ref xmsg,xmsg2,msglen lda msg ;msg length sta msglen ldy #>msg+1 ;msg address ldx #<msg+1 jsr prline ; same for externally defined msg lda xmsg sta msglen ldy #>xmsg+1 ldx #<xmsg+1 jsr prline lda xmsg2-1 ;xmsg2 points to the text sta msglen ldy #>xmsg2 ldx #<xmsg2 jsr prline rts msg .byte msgend-1-*,"Hello, world!\n" msgend = * SHAR_EOF fi # end of overwriting check if test -f 'atest2.a' then echo shar: will not over-write existing file "'atest2.a'" else cat << \SHAR_EOF > 'atest2.a' .def prline .def xmsg,xmsg2 CHROUT = $ffd2 tmp = $fb prline ;print a one line message sty tmp+1 stx tmp ldx msglen ldy #0 loop lda (tmp),y jsr CHROUT iny dex bne loop rts ; the following is a separately relocatable ; data segment. At run time, it may be ; located anywhere in memory, but ; (hopefully) all references will be ; properly resolved by the linker. (It ; will not be located in the middle of ; this program!) msglen .dseg 1 ;a silly size for a dseg! ; back to in-line code: xmsg .byte xmend-*-1 .byte "This is an external message\n" xmend = * .ifgt $ffff,0 ;values are unsigned ;this gets assembled .byte xm2end-xmsg2 xmsg2 .byte "Goodbye!\n" xm2end=* .else sec ;this does not get assembled .fi SHAR_EOF fi # end of overwriting check if test -f 'chrtest.a' then echo shar: will not over-write existing file "'chrtest.a'" else cat << \SHAR_EOF > 'chrtest.a' SHAR_EOF fi # end of overwriting check if test -f 'chrtest1.a' then echo shar: will not over-write existing file "'chrtest1.a'" else cat << \SHAR_EOF > 'chrtest1.a' ;Short, 2-part test program to exercise ;the C/ASSM assembler. .def exit,xstring .ref test2 #include <kernal.equ> jmp test1 xstring .byte "abcdefghijklmnopqrstuvwxyz\n",0 test1 jsr CLRCHN jmp test2 ;call external routine exit rts SHAR_EOF fi # end of overwriting check if test -f 'chrtest2.a' then echo shar: will not over-write existing file "'chrtest2.a'" else cat << \SHAR_EOF > 'chrtest2.a' ; Part 2 of C/ASSM assembler test ; .def test2 .ref xstring,exit #include "kernal.equ" zptr = 251 ;zero page pointer cell test2 jsr CLRCHN lda #<xstring ;get string address sta zptr lda #>xstring sta zptr+1 ldy #0 loop lda (zptr),y beq done jsr CHROUT iny bne loop done jmp exit SHAR_EOF fi # end of overwriting check if test -f 'condtest.a' then echo shar: will not over-write existing file "'condtest.a'" else cat << \SHAR_EOF > 'condtest.a' z = $100 .ifgt z,10 lda z ;this gets assembled .ifgt z,1000 ldx z ;this does not .else ldy z ;assembles .fi asl z ;assembles .ifeq z,40 lsr z ;does not .fi lda #1 ;assembles .else lda #2 ;does not assemble .ifgt z,0 tax ;still no .fi tay ;still no .ifgt x,z ;x is undefined--no problem tya ;no assembly .fi sec ;still not .fi clc ;assembles SHAR_EOF fi # end of overwriting check # End of shell archive exit 0 -- | Mark R. Rinfret, SofTech, Inc. mark@unisec.usi.com | | Guest of UniSecure Systems, Inc., Newport, RI | | UUCP: {gatech|mirror|cbosgd|uiucdcs|ihnp4}!rayssd!unisec!mark | | work: (401)-849-4174 home: (401)-846-7639 |