From 77e8708934c5c792b1435fa11dfe3c0a6f636a8c Mon Sep 17 00:00:00 2001 From: Ian C Date: Mon, 7 Mar 2016 15:00:21 +0000 Subject: Updated README and copied latest version in. --- src/test/1 | 75 ++++++++++ src/test/2 | 68 +++++++++ src/test/3 | 20 +++ src/test/6502.1 | 272 ++++++++++++++++++++++++++++++++++ src/test/inc | 6 + src/test/z80.1 | 447 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 888 insertions(+) create mode 100644 src/test/1 create mode 100644 src/test/2 create mode 100644 src/test/3 create mode 100644 src/test/6502.1 create mode 100644 src/test/inc create mode 100644 src/test/z80.1 (limited to 'src/test') diff --git a/src/test/1 b/src/test/1 new file mode 100644 index 0000000..304e4b8 --- /dev/null +++ b/src/test/1 @@ -0,0 +1,75 @@ +; +; Basic parsing and label handling +; +; Comments +; + list on + list labels,on + + alias fred,equ + +label0: ; First label - should default to zero + +label1 org $8000 +.local_1 org 8001h +.local_2 org 8002 + +label2: equ 11110101b +.local2_1 +.local_dup + + org 0x8100 +pc_test1: equ $ +pc_test_minus_100: equ $ - $100 + +label3: +.local3_1 +.local_dup + +forward: equ bin1 + bin2 + hex1 + +expr1_7 equ 1 + 2 * 3 +expr2_9 equ {1 + 2} * 3 + +bin1: equ 11110101b +bin2: equ 11110010b +hex1: equ $1234 +hex2 equ 1234h +hex3: equ 0x1234 +oct: equ 0177 +.dec equ 65535 +.dec2: equ 123456 + +align_test: org $9001 + + align $10 +should_end_10h: + + align $100 +should_end_100h: + + cpu z80 + option list + + cpu 6502 + option list + + option zp,true + option zp,on + option zp,yes + option zp,false + option zp,off + option zp,no + + option +zp + option -zp + +one equ 1 +two fred ONE * 2 + +true1 equ one == 1 +false1 equ one != 1 + +endaddr:end + +this is ignored diff --git a/src/test/2 b/src/test/2 new file mode 100644 index 0000000..53f272d --- /dev/null +++ b/src/test/2 @@ -0,0 +1,68 @@ + option +list + option list-macros,all + org $8000 + +macro1: macro + .byte "Hello World" + .text 0, $ff + endm + +hello: macro +.start + macro1 + dw start,end +.end + endm + + option charset, ascii +ascii: hello "ASC",$80 +.should_be_local_to_ascii + + option charset, zx81 +zx81: + hello "'81",$81 +.should_be_local_to_zx81 + + option charset, spectrum +speccy: hello "48K",$82 + + option charset, cbm +cbm: hello "CBM",$83 + + org $8100 + + ds 512,$ + .ds 512 + ds 512,$ff + +macro2: macro + db \1,0xe5,\2 + endm + +macro3: macro + macro2 \1,\2 + endm + +macro4: macro a + macro3 $ff,@a + endm + +macrotest: + macro4 "0x01" + macro4 "0x02" + macro4 "0x03" + MACRO4 "0x04" + macro4 "0x05" + macro4 "0x06" + + option macro-arg-char,& + +macro5: macro a + defb &a + endm + + macro5 "Hello" + macro5 "World" + +end: equ $ +end2: diff --git a/src/test/3 b/src/test/3 new file mode 100644 index 0000000..a3f68f1 --- /dev/null +++ b/src/test/3 @@ -0,0 +1,20 @@ + org $8000 + +start: + dw start, end +end: + +wmac: macro +.start + dw start,end +.end + endm + + align 8 + wmac + align 8 + wmac + align 8 + wmac + + text "EOL" diff --git a/src/test/6502.1 b/src/test/6502.1 new file mode 100644 index 0000000..f94bcc8 --- /dev/null +++ b/src/test/6502.1 @@ -0,0 +1,272 @@ + ;option list-file,list.txt + option +list + option +list-hex + option +list-pc + option list-labels,all + option list-macros,all + + ; + ; Test basically created by pasting in opcodes from 6502.org + ; + cpu 6502 + + org $8000 + +zero: equ 0 + + option zero-page,off + +adc_test + ADC #$44 + option +zero-page + ADC $44 + adc $44,x + option -zero-page + adc $4400 + adc $4400,x + adc $4400,y + ADC ($44,X) + ADC ($44),Y + +zp_test + option zero-page,auto + adc $80 ; Always ZP + adc $8080 ; Always !ZP + adc fwd_80 ; Always ZP - sure after 2nd pass onwards + adc fwd_101 ; Initially ZP - sure !ZP after 2nd pass onwards + option -zero-page + + +addr_mode_tests: ; Uncomment to test + option +zero-page + ; adc $4400 ; Outside of ZP + option -zero-page + ; adc $4400,z ; Unknown index reg + ; adc ($44,y) ; Wrong indirect reg + ; adc ($44),x ; Wrong indirect reg + +and_test + and #$44 + and $44 + and $44,x + and $4400 + and $4400,x + and $4400,y + and ($44,x) + and ($44),y + +asl_test + ASL A + ASL $44 + ASL $44,X + ASL $4400 + ASL $4400,X + +bit_test + BIT $44 + BIT $4400 + +branch_test + BPL branch_test + BMI branch_test + BVC branch_test + BVS branch_test + BCC branch_test + BCS branch_test + BNE branch_test + BEQ branch_test + + BPL brk_test + BMI brk_test + BVC brk_test + BVS brk_test + BCC brk_test + BCS brk_test + BNE brk_test + BEQ brk_test + + ; BEQ zero ; Would generate an error/warning + ; BEQ $f000 ; Would generate an error/warning + +brk_test + BRK + +cmp_test +.acc + CMP #$44 + CMP $44 + CMP $44,X + CMP $4400 + CMP $4400,X + CMP $4400,Y + CMP ($44,X) + CMP ($44),Y + +.xreg + CPX #$44 + CPX $44 + CPX $4400 + + +.yreg + CPY #$44 + CPY $44 + CPY $4400 + +dec_test + DEC $44 + DEC $44,X + DEC $4400 + DEC $4400,X + + + +eor_test + EOR #$44 + EOR $44 + EOR $44,X + EOR $4400 + EOR $4400,X + EOR $4400,Y + EOR ($44,X) + EOR ($44),Y + +flag_test + CLC + SEC + CLI + SEI + CLV + CLD + SED + +inc_test + INC $44 + INC $44,X + INC $4400 + INC $4400,X + + +jmp_test + JMP $5597 + JMP ($5597) + +jsr_test + JSR $5597 + +ld_test +.acc + LDA #$44 + LDA $44 + LDA $44,X + LDA $4400 + LDA $4400,X + LDA $4400,Y + LDA ($44,X) + LDA ($44),Y + +.xreg + LDX #$44 + LDX $44 + LDX $44,Y + LDX $4400 + LDX $4400,Y + +.yreg + LDY #$44 + LDY $44 + LDY $44,X + LDY $4400 + LDY $4400,X + +lst_test + + LSR A + LSR $44 + LSR $44,X + LSR $4400 + LSR $4400,X + +nop_test + + NOP + +ora_test + ORA #$44 + ORA $44 + ORA $44,X + ORA $4400 + ORA $4400,X + ORA $4400,Y + ORA ($44,X) + ORA ($44),Y + +xfer_test + TAX + TXA + DEX + INX + TAY + TYA + DEY + INY + + +rol_test + ROL A + ROL $44 + ROL $44,X + ROL $4400 + ROL $4400,X + +rot_test + ROR A + ROR $44 + ROR $44,X + ROR $4400 + ROR $4400,X + +ret_test + RTI + rts + +sbc_test + SBC #$44 + SBC $44 + SBC $44,X + SBC $4400 + SBC $4400,X + SBC $4400,Y + SBC ($44,X) + SBC ($44),Y + +store_test +.acc + STA $44 + STA $44,X + STA $4400 + STA $4400,X + STA $4400,Y + STA ($44,X) + STA ($44),Y + +.xreg + STX $44 + STX $44,Y + STX $4400 + +.yreg + STY $44 + STY $44,X + STY $4400 + +stack_test + TXS + TSX + PHA + PLA + PHP + PLP + +fwd_80: equ $80 +fwd_101 equ $101 diff --git a/src/test/inc b/src/test/inc new file mode 100644 index 0000000..4856cb3 --- /dev/null +++ b/src/test/inc @@ -0,0 +1,6 @@ + include test/1 +binstart: + incbin test/1 +binend: + + ;include test/inc diff --git a/src/test/z80.1 b/src/test/z80.1 new file mode 100644 index 0000000..d41828e --- /dev/null +++ b/src/test/z80.1 @@ -0,0 +1,447 @@ + option -list + option +list-hex + option +list-pc + option list-macros,off + option list-labels,off + + ;output file,a.tap + ;output format,spectrum + + cpu z80 + + org $8000 + + ; + ; Simple comments + ; + +ld8test:macro reg + LD @reg,A ; Comment? + LD @reg,B + LD @reg,C + LD @reg,D + LD @reg,E + LD @reg,H + LD @reg,L +.test + LD @reg,(HL) + LD @reg,(IX+127) + LD @reg,(IY-128) + LD (hl),@reg + LD (IX+127),@reg + LD (IY-128),@reg + ld @reg,$e5 + ld @reg,ixh + ld @reg,ixl + ld @reg,iyh + ld @reg,iyl + endm + +ld8test_undoc:macro + LD \1,A ; Comment? + LD \1,B + LD \1,C + LD \1,D + LD \1,E + LD \1,\1 + LD \1,\1 + ld \1,$e5 + endm + +ld_tests: +.value + ld (hl),$e5 + ld (ix+127),$e5 + ld (iy-128),$e5 +.a + ld8test a + LD a,(BC) + LD a,(DE) + LD a,(word) + ld a,i + ld a,r + ld r,a + ld i,a + +.b + ld8test b +.c + ld8test c +.d + ld8test d +.e + ld8test e +.h + ld8test h +.l + ld8test l +.ixl + ld8test_undoc ixl +.ixh + ld8test_undoc ixh +.iyl + ld8test_undoc iyl +.iyh + ld8test_undoc iyh + +.bit16 + ld bc,word + ld de,word + ld hl,word + ld sp,word + ld ix,word + ld iy,word + + ld bc,(word) + ld de,(word) + ld hl,(word) + ld sp,(word) + ld ix,(word) + ld iy,(word) + +alu: macro + \1 a,a + \1 a + \1 a,b + \1 b + \1 a,c + \1 a,d + \1 a,e + \1 a,h + \1 a,l + \1 a,ixh + \1 a,ixl + \1 a,iyh + \1 a,iyl + \1 a,(hl) + \1 a,(ix+100) + \1 a,(iy-100) + endm + +alutest: + alu add + alu adc + alu sub + alu sbc + alu and + alu or + alu xor + alu eor + alu cp + + inc a + inc b + inc c + inc d + inc e + inc h + inc l + inc ixh + inc ixl + inc iyh + inc iyl + inc (hl) + inc (ix-64) + inc (iy+64) + inc bc + inc de + inc hl + inc sp + inc ix + inc iy + + dec a + dec b + dec c + dec d + dec e + dec h + dec l + dec ixh + dec ixl + dec iyh + dec iyl + dec (hl) + dec (ix-64) + dec (iy+64) + dec bc + dec de + dec hl + dec sp + dec ix + dec iy + + im 0 + im 1 + im 2 + +alu16: + add hl,bc + add hl,de + add hl,hl + add hl,sp + + add ix,bc + add ix,de + add ix,ix + add ix,sp + + add iy,bc + add iy,de + add iy,iy + add iy,sp + + adc hl,bc + adc hl,de + adc hl,hl + adc hl,sp + + sbc hl,bc + sbc hl,de + sbc hl,hl + sbc hl,sp + +stack: + push af + push bc + push de + push hl + push ix + push iy + pop af + pop bc + pop de + pop hl + pop ix + pop iy + +exchange: + ex de,hl + ex af,af' + ex (sp),hl + ex (sp),ix + ex (sp),iy + ldi + ldir + ldd + lddr + cpi + cpir + cpdr + +bitm: macro + \1 a + \1 b + \1 c + \1 d + \1 e + \1 h + \1 l + \1 (hl) + \1 (ix+1) + \1 (iy-1) + \1 (ix+1),a + \1 (iy-1),a + \1 (ix+1),b + \1 (iy-1),b + \1 (ix+1),c + \1 (iy-1),c + \1 (ix+1),d + \1 (iy-1),d + \1 (ix+1),e + \1 (iy-1),e + \1 (ix+1),h + \1 (iy-1),h + \1 (ix+1),l + \1 (iy-1),l + endm + +set_res:macro + \1 0,a + \1 1,b + \1 2,c + \1 3,d + \1 4,e + \1 5,h + \1 6,l + \1 7, (hl) + \1 0, (ix+1) + \1 0, (iy-1) + \1 1, (ix+1),a + \1 1, (iy-1),a + \1 2, (ix+1),b + \1 2, (iy-1),b + \1 3, (ix+1),c + \1 3, (iy-1),c + \1 4, (ix+1),d + \1 4, (iy-1),d + \1 5, (ix+1),e + \1 5, (iy-1),e + \1 6, (ix+1),h + \1 6, (iy-1),h + \1 7, (ix+1),l + \1 7, (iy-1),l + endm + +bits: + RLCA + RRCA + RLA + RRA + + bitm rlc + bitm rl + bitm rrc + bitm rr + bitm sla + bitm SRA + bitm srl + bitm sll + + set_res set + set_res res + + bit 0,a + bit 1,b + bit 2,c + bit 3,d + bit 4,e + bit 5,h + bit 6,l + bit 7, (hl) + bit 0, (ix+1) + bit 0, (iy-1) + +jtest: macro + \1 endjmp + \1 nz,endjmp + \1 z,endjmp + \1 nc,endjmp + \1 c,endjmp + \1 po,endjmp + \1 pe,endjmp + \1 p,endjmp + \1 m,endjmp +.endjmp + endm + +jump: + jtest jp + jtest call + + jp (hl) + jp (ix) + jp (iy) + +.jrjump1 + jr jrjump1 + jr nz,jrjump1 + jr z,jrjump1 + jr nc,jrjump1 + jr c,jrjump1 + djnz jrjump1 + + jr jrjump2 + jr nz,jrjump2 + jr z,jrjump2 + jr nc,jrjump2 + jr c,jrjump2 + djnz jrjump2 +.jrjump2 + call 0 + + ret + ret nz + ret z + ret nc + ret c + ret po + ret pe + ret p + ret m + reti + retn + + rst 0 + rst 0h + rst 8 + rst 8h + rst 10 + rst 10h + rst 18 + rst 18h + rst 20 + rst 20h + rst 28 + rst 28h + rst 30 + rst 30h + rst 38 + rst 38h + + +io: + in (c) + in a,(255) + in a,(c) + in b,(c) + in c,(c) + in d,(c) + in e,(c) + in h,(c) + in l,(c) + in f,(c) + ini + inir + ind + indr + + out (c),0 + out (255),a + out (c),a + out (c),b + out (c),c + out (c),d + out (c),e + out (c),h + out (c),l + out (c),f + out (c),255 + out (c),123456789 + outi + otir + outd + otdr + +implied: + NOP + DI + EI + HALT + HLT + EXX + DAA + CPL + SCF + CCF + NEG + CPI + CPIR + CPD + CPDR + INI + INIR + IND + INDR + OUTI + OTIR + OUTD + OTDR + LDI + LDIR + LDD + LDDR + +word: defs 2 + +string: db "Hello World",0 -- cgit v1.2.3