diff --git a/presets/c64/kitchensink.dasm b/presets/c64/kitchensink.dasm new file mode 100644 index 000000000..ad3666935 --- /dev/null +++ b/presets/c64/kitchensink.dasm @@ -0,0 +1,598 @@ +; =========================================================================== +; kitchensync.dasm - 6502 grammar Kitchen Sink +; =========================================================================== +; 6502 parser and formatter test +; =========================================================================== +; TODO: Uncomment `;;;` lines once DASM is updated + +; ------------------------------------------------------------------- +; PROCESSOR +; ------------------------------------------------------------------- + processor 6502 + PROCESSOR 6502 + .processor 6502 + .PROCESSOR 6502 + +; ------------------------------------------------------------------- +; Segment: uninitialized variables +; ------------------------------------------------------------------- + seg.u variables +;;; .seg.u variables + SEG.U variables +;;; .SEG.U variables + org $80 +var1 ds 1 +var2 ds 2 +var3 ds.w 1 + +; ------------------------------------------------------------------- +; Segments (SEG, SEG.U) +; ------------------------------------------------------------------- + seg code + .seg code + SEG code + .SEG code + + +; =================================================================== +; Runnable entry point +; =================================================================== + org $0810 +start jmp start ; infinite loop so program can run + +; ------------------------------------------------------------------- +; Labels: global, global with colon, local (.name) +; ------------------------------------------------------------------- +GlobalLabel +GlobalColon: + SUBROUTINE +.local +.temp nop + +; ------------------------------------------------------------------- +; Instructions: every 6502 opcode (lowercase) +; ------------------------------------------------------------------- + adc #$01 + and #$FF +;;; asl a + asl + bcc .temp + bcs .temp + beq .temp + bit $44 + bmi .temp + bne .temp + bpl .temp + brk + bvc .temp + bvs .temp + clc + cld + cli + clv + cmp #$00 + cpx #$10 + cpy #$20 + dec $44 + dex + dey + eor #$AA + inc $44 + inx + iny + jmp start + jsr start + lda #$42 + ldx #$00 + ldy #$00 +;;; lsr a + nop + ora #$0F + pha + php + pla + plp +;;; rol a +;;; ror a + rti + rts + sbc #$01 + sec + sed + sei + sta $44 + stx $45 + sty $46 + tax + tay + tsx + txa + txs + tya + +; ------------------------------------------------------------------- +; Instructions: every 6502 opcode (UPPERCASE) +; ------------------------------------------------------------------- + ADC #$02 + AND #$FE +;;; ASL A + BCC .temp + BCS .temp + BEQ .temp + BIT $44 + BMI .temp + BNE .temp + BPL .temp + BRK + BVC .temp + BVS .temp + CLC + CLD + CLI + CLV + CMP #$01 + CPX #$11 + CPY #$21 + DEC $44 + DEX + DEY + EOR #$BB + INC $44 + INX + INY + JMP start + JSR start + LDA #$43 + LDX #$01 + LDY #$01 +;;; LSR A + NOP + ORA #$F0 + PHA + PHP + PLA + PLP +;;; ROL A +;;; ROR A + RTI + RTS + SBC #$02 + SEC + SED + SEI + STA $44 + STX $45 + STY $46 + TAX + TAY + TSX + TXA + TXS + TYA + +; ------------------------------------------------------------------- +; Addressing modes +; ------------------------------------------------------------------- + lda #$FF ; immediate + lda $44 ; zero page + lda $44,x ; zero page,X + ldx $44,y ; zero page,Y + lda $1234 ; absolute + lda $1234,x ; absolute,X + lda $1234,y ; absolute,Y + lda ($44,x) ; indirect,X + lda ($44),y ; indirect,Y + jmp ($FFFE) ; indirect + +; ------------------------------------------------------------------- +; Register operands (all cases) +; ------------------------------------------------------------------- +;;; asl a +;;; asl A + +; ------------------------------------------------------------------- +; Number formats +; ------------------------------------------------------------------- + lda #$FF ; hexadecimal + lda #%10101010 ; binary + lda #255 ; decimal + lda #'A ; character constant + lda #0 ; zero + +; ------------------------------------------------------------------- +; Current address (.) +; ------------------------------------------------------------------- + jmp . ; current address + +; ------------------------------------------------------------------- +; Pseudo-ops: ORG +; ------------------------------------------------------------------- + org $0900 + ORG $0A00 + +; ------------------------------------------------------------------- +; Pseudo-ops: EQU / = assignment +; ------------------------------------------------------------------- +CONST1 equ $10 +CONST2 EQU $20 +CONST3 = $30 +CONST4 = CONST1 + CONST2 + +; ------------------------------------------------------------------- +; Pseudo-ops: SET (reassignable) +; ------------------------------------------------------------------- +COUNTER set 0 +COUNTER set COUNTER + 1 +COUNTER SET COUNTER + 1 + +; ------------------------------------------------------------------- +; Pseudo-ops: EQM (expression macro) +; ------------------------------------------------------------------- +DOUBLE eqm . * 2 +DOUBLE EQM . * 2 + +; ------------------------------------------------------------------- +; Pseudo-ops: SETSTR +; ------------------------------------------------------------------- +;;;NAME setstr "Hello" +;;;NAME SETSTR "World" + +; ------------------------------------------------------------------- +; Data: BYTE / WORD / LONG (all size extensions) +; ------------------------------------------------------------------- + BYTE $EE,$FF + word $ABCD + WORD $1234 + long $12345678 + LONG $DEADBEEF + +; ------------------------------------------------------------------- +; Data: HEX +; ------------------------------------------------------------------- + hex 1A2B3C + hex FF 00 AA BB + HEX DEADBEEF + HEX 01 02 03 04 + +; ------------------------------------------------------------------- +; Data: DC (all size extensions) +; ------------------------------------------------------------------- + dc 1,2,3 + dc.b $AA,$BB + dc.w $1234,$5678 + dc.l $12345678 + dc.s "AB" + DC 4,5,6 + DC.B $CC,$DD + DC.W $9ABC,$DEF0 + DC.L $DEADBEEF + DC.S "CD" + byte 7,8,9 + +; ------------------------------------------------------------------- +; Data: DS (declare space, all size extensions) +; ------------------------------------------------------------------- + ds 4 + ds 4,$FF + ds.b 2,42 + ds.w 2,3,4 + ds.l 1 + ds.s 1 + DS 8,$00 + DS.B 3 + DS.W 3 + DS.L 5,6,7,8 + DS.S 2 + +; ------------------------------------------------------------------- +; Data: DV (declare via EQM, all size extensions) +; ------------------------------------------------------------------- +XFORM eqm .. + 1 + dv XFORM 0,1,2 + dv.b XFORM 3,4 + dv.w XFORM 5,6 + dv.l XFORM 7,8 + dv.s XFORM 7,8 + DV XFORM 9 + DV.B XFORM 10 + DV.W XFORM 11 + DV.L XFORM 12 + DV.S XFORM 12 + +; ------------------------------------------------------------------- +; Strings and characters +; ------------------------------------------------------------------- + dc "Hello, World!" + dc 'A + dc 'Z + +; ------------------------------------------------------------------- +; Include directives +; ------------------------------------------------------------------- + include "kitchensink2.dasm" + INCLUDE "kitchensink2.dasm" + .include "kitchensink2.dasm" + .INCLUDE "kitchensink2.dasm" + + incbin "kitchensink/kitchensink.bin" + INCBIN "kitchensink/kitchensink.bin",2 + .incbin "kitchensink/kitchensink.bin" + .INCBIN "kitchensink/kitchensink.bin",2 + + incdir "kitchensink/" + INCDIR "kitchensink/" + .incdir "kitchensink/" + .INCDIR "kitchensink/" + +; ------------------------------------------------------------------- +; ALIGN +; ------------------------------------------------------------------- + align 256 + ALIGN 256 + align 16,$EA + ALIGN 16,$EA + +; ------------------------------------------------------------------- +; RORG / REND +; ------------------------------------------------------------------- + rorg $C000 + nop + rend + RORG $D000 + nop + REND + + .rorg $C000 + nop + .rend + .RORG $D000 + nop + .REND + +; ------------------------------------------------------------------- +; SUBROUTINE (local label scoping) +; ------------------------------------------------------------------- +MyFunc SUBROUTINE +.loop dex + bne .loop + rts +MyFunc2 subroutine +.loop dey + bne .loop + rts +MyFunc3 .subroutine +.loop rts +MyFunc4 .SUBROUTINE +.loop rts + +; ------------------------------------------------------------------- +; ECHO +; ------------------------------------------------------------------- + echo "Build starting" + .echo "Build starting" + ECHO "Value=",CONST1 + .ECHO "Value=",CONST1 + echo "Sum=",[CONST1+CONST2] + .echo "Sum=",[CONST1+CONST2] + +; ------------------------------------------------------------------- +; LIST +; ------------------------------------------------------------------- + list on + .list on + list off + .list off + LIST ON + .LIST ON + LIST OFF + .LIST OFF + +; ------------------------------------------------------------------- +; Macros: MAC / MACRO / MEXIT / ENDM +; ------------------------------------------------------------------- + mac LoadImm + lda #{1} + mexit + endm + + .mac LoadImm + lda #{1} + .mexit + .endm + + MAC StoreZP + sta {1} + MEXIT + ENDM + + .MAC StoreZP + sta {1} + .MEXIT + .ENDM + +;;; macro LdxImm +;;; ldx #{1} +;;; endm + +;;; MACRO LdyImm +;;; ldy #{1} +;;; ENDM + +; ------------------------------------------------------------------- +; Conditionals: IF / ELSE / ENDIF / EIF +; ------------------------------------------------------------------- + if CONST1 == $10 + nop + else + brk + endif + + IF CONST2 != $10 + nop + ELSE + brk + ENDIF + + .if CONST1 == $10 + nop + .else + brk + .endif + + .IF CONST2 != $10 + nop + .ELSE + brk + .ENDIF + +; ------------------------------------------------------------------- +; Conditionals: IFCONST / IFNCONST +; ------------------------------------------------------------------- + ifconst CONST1 + nop + endif + + IFCONST CONST2 + nop + ENDIF + + .ifnconst UNDEFINED_SYMBOL + nop + .endif + + .IFNCONST UNDEFINED_SYMBOL + nop + .ENDIF + +; ------------------------------------------------------------------- +; REPEAT / REPEND +; ------------------------------------------------------------------- +I SET 0 + REPEAT 4 + dc.b I +I SET I + 1 + REPEND + +I set 0 + repeat 4 + dc.b I +I set I + 1 + repend + +I .SET 0 + .REPEAT 4 + dc.b I +I .SET I + 1 + .REPEND + +I .set 0 + .repeat 4 + dc.b I +I .set I + 1 + .repend + + repeat 2 + nop + repend + + +; ------------------------------------------------------------------- +; Expressions: arithmetic operators +; ------------------------------------------------------------------- +EXPR_ADD = 1 + 2 +EXPR_SUB = 10 - 3 +EXPR_MUL = 4 * 5 +EXPR_DIV = 20 / 4 +EXPR_MOD = 17 % 5 + +; ------------------------------------------------------------------- +; Expressions: bitwise operators +; ------------------------------------------------------------------- +EXPR_AND = $FF & $0F +EXPR_OR = $F0 | $0F +EXPR_XOR = $FF ^ $AA +EXPR_SHL = 1 << 4 +EXPR_SHR = $80 >> 3 + +; ------------------------------------------------------------------- +; Expressions: comparison operators +; ------------------------------------------------------------------- +EXPR_EQ = [1 == 1] +EXPR_NE = [1 != 2] +EXPR_LT = [1 < 2] +EXPR_GT = [2 > 1] +EXPR_LE = [1 <= 1] +EXPR_GE = [2 >= 1] + +; ------------------------------------------------------------------- +; Expressions: logical operators +; ------------------------------------------------------------------- +EXPR_LAND = [1 && 1] +EXPR_LOR = [0 || 1] + +; ------------------------------------------------------------------- +; Expressions: ternary operator +; ------------------------------------------------------------------- +EXPR_TERN = [1 ? 42] + +; ------------------------------------------------------------------- +; Expressions: unary operators +; ------------------------------------------------------------------- +EXPR_NEG = -1 +;;;EXPR_POS = +1 +EXPR_NOT = !0 +EXPR_CPL = ~$FF +EXPR_LO = <$1234 +EXPR_HI = >$1234 + +; ------------------------------------------------------------------- +; Expressions: bracket grouping +; ------------------------------------------------------------------- +EXPR_PARENS = (2 + 3) * 4 +EXPR_BRACK = [2 + 3] * 4 + +; ------------------------------------------------------------------- +; Expressions: complex nested +; ------------------------------------------------------------------- +EXPR_COMPLEX = [[1 + 2] * [3 + 4]] & $FF + +; ------------------------------------------------------------------- +; C-style block comments +; ------------------------------------------------------------------- +;;;/* This is a single-line block comment */ + +;;;/* +;;; * This is a multi-line +;;; * block comment +;;; */ + +;;; nop /* inline block comment */ + +;;; lda /* mid-instruction comment */ #$42 + +; ------------------------------------------------------------------- +; Mixed comment styles +; ------------------------------------------------------------------- + nop ; semicolon comment /* block comment */ +;;; nop /* block comment */ ; then semicolon comment + + +; ------------------------------------------------------------------- +; END +; ------------------------------------------------------------------- + end ; assembly stops here + END ; would've stopped assembly + .end ; would've stopped assembly + .END ; would've stopped assembly + +; ------------------------------------------------------------------- +; ERR +; ------------------------------------------------------------------- + err ; would've aborted assembly + ERR ; would've aborted assembly + .err ; would've aborted assembly + .ERR ; would've aborted assembly + +; =========================================================================== +; End of kitchen sink +; =========================================================================== diff --git a/presets/c64/kitchensink/kitchensink.bin b/presets/c64/kitchensink/kitchensink.bin new file mode 100644 index 000000000..c11b4462c --- /dev/null +++ b/presets/c64/kitchensink/kitchensink.bin @@ -0,0 +1 @@ +; kitchensink/kitchensink.bin diff --git a/presets/c64/kitchensink2.dasm b/presets/c64/kitchensink2.dasm new file mode 100644 index 000000000..37647d22d --- /dev/null +++ b/presets/c64/kitchensink2.dasm @@ -0,0 +1 @@ +; kitchensink2.dasm diff --git a/presets/zx/kitchensink.zmac b/presets/zx/kitchensink.zmac new file mode 100644 index 000000000..dcaafd9cc --- /dev/null +++ b/presets/zx/kitchensink.zmac @@ -0,0 +1,777 @@ +; =========================================================================== +; kitchensink.zmac - Z80 grammar Kitchen Sink +; =========================================================================== +; Z80 parser and formatter test for zmac assembler +; https://48k.ca/zmac.html +; =========================================================================== +; TODO: Uncomment `;;;` lines once ZMAC is updated + +; ------------------------------------------------------------------- +; Code generation mode +; ------------------------------------------------------------------- +;;; .z80 + +; ------------------------------------------------------------------- +; ORG +; ------------------------------------------------------------------- + org $5CCB + .org 0x5CCB + ORG $5CCB + .ORG 0x5CCB + +; ------------------------------------------------------------------- +; Labels: global, global with colon, global with double colon (public) +; ------------------------------------------------------------------- +GlobalLabel +GlobalColon: +GlobalPublic:: + +; =================================================================== +; Runnable entry point +; =================================================================== + org $8000 +start: jp start ; infinite loop so program can run + +; ------------------------------------------------------------------- +; Instructions: 8-bit load group +; ------------------------------------------------------------------- + ld a,b + ld a,c + ld a,d + ld a,e + ld a,h + ld a,l + ld a,(hl) + ld a,a + ld b,42 + ld c,$FF + ld d,10101010b + ld e,0x1A + ld h,0FFh + ld l,0 + +; ------------------------------------------------------------------- +; Instructions: 16-bit load group +; ------------------------------------------------------------------- + ld bc,$1234 + ld de,$5678 + ld hl,$9ABC + ld sp,$DEF0 + ld ix,$1111 + ld iy,$2222 + ld hl,($C000) + ld ($C000),hl + ld bc,($C002) + ld ($C002),bc + ld de,($C004) + ld ($C004),de + ld sp,($C006) + ld ($C006),sp + ld ix,($C008) + ld ($C008),ix + ld iy,($C00A) + ld ($C00A),iy + +; ------------------------------------------------------------------- +; Instructions: stack operations +; ------------------------------------------------------------------- + push af + push bc + push de + push hl + push ix + push iy + pop af + pop bc + pop de + pop hl + pop ix + pop iy + +; ------------------------------------------------------------------- +; Instructions: exchange, block transfer, search +; ------------------------------------------------------------------- + ex de,hl + ex af,af' + exx + ex (sp),hl + ex (sp),ix + ex (sp),iy + ldi + ldir + ldd + lddr + cpi + cpir + cpd + cpdr + +; ------------------------------------------------------------------- +; Instructions: 8-bit arithmetic and logic +; ------------------------------------------------------------------- + add a,b + add a,$10 + add a,(hl) + add a,(ix+5) + add a,(iy-3) + adc a,c + adc a,$20 + sub d + sub $30 + sbc a,e + sbc a,$40 + and h + and $0F + or l + or $F0 + xor a + xor $AA + cp b + cp $55 + inc a + inc b + inc (hl) + inc (ix+2) + dec c + dec (iy+4) + +; ------------------------------------------------------------------- +; Instructions: 16-bit arithmetic +; ------------------------------------------------------------------- + add hl,bc + add hl,de + add hl,hl + add hl,sp + adc hl,bc + sbc hl,de + add ix,bc + add ix,de + add ix,ix + add ix,sp + add iy,bc + add iy,de + add iy,iy + add iy,sp + inc bc + inc de + inc hl + inc sp + inc ix + inc iy + dec bc + dec de + dec hl + dec sp + dec ix + dec iy + +; ------------------------------------------------------------------- +; Instructions: general-purpose AF operations +; ------------------------------------------------------------------- + daa + cpl + neg + ccf + scf + +; ------------------------------------------------------------------- +; Instructions: rotate and shift +; ------------------------------------------------------------------- + rlca + rrca + rla + rra + rlc b + rlc (hl) + rrc c + rrc (ix+1) + rl d + rl (iy+2) + rr e + sla h + sla (hl) + sra l + srl a + srl (ix+3) + rld + rrd + +; ------------------------------------------------------------------- +; Instructions: bit set, reset, test +; ------------------------------------------------------------------- + bit 0,a + bit 7,(hl) + bit 3,(ix+1) + set 0,b + set 5,(hl) + set 2,(iy+4) + res 7,c + res 4,(hl) + res 6,(ix+2) + +; ------------------------------------------------------------------- +; Instructions: jump group +; ------------------------------------------------------------------- + jp $8000 + jp nz,$8000 + jp z,$8000 + jp nc,$8000 + jp c,$8000 + jp po,$8000 + jp pe,$8000 + jp p,$8000 + jp m,$8000 + jp (hl) + jp (ix) + jp (iy) +jr_target: + jr jr_target + jr nz,jr_target + jr z,jr_target + jr nc,jr_target + jr c,jr_target + djnz jr_target + +; ------------------------------------------------------------------- +; Instructions: call and return group +; ------------------------------------------------------------------- + call $8000 + call nz,$8000 + call z,$8000 + call nc,$8000 + call c,$8000 + call po,$8000 + call pe,$8000 + call p,$8000 + call m,$8000 + ret + ret nz + ret z + ret nc + ret c + ret po + ret pe + ret p + ret m + reti + retn + +; ------------------------------------------------------------------- +; Instructions: restart group +; ------------------------------------------------------------------- + rst $00 + rst $08 + rst $10 + rst $18 + rst $20 + rst $28 + rst $30 + rst $38 + +; ------------------------------------------------------------------- +; Instructions: input and output group +; ------------------------------------------------------------------- + in a,($FE) + in b,(c) + in c,(c) + in d,(c) + in e,(c) + in h,(c) + in l,(c) + in a,(c) + ini + inir + ind + indr + out ($FE),a + out (c),b + out (c),c + out (c),d + out (c),e + out (c),h + out (c),l + out (c),a + outi + otir + outd + otdr + +; ------------------------------------------------------------------- +; Instructions: CPU control +; ------------------------------------------------------------------- + nop + halt + di + ei + im 0 + im 1 + im 2 + ld i,a + ld a,i + ld r,a + ld a,r + +; ------------------------------------------------------------------- +; Instructions: memory-referenced loads +; ------------------------------------------------------------------- + ld a,($1234) + ld ($1234),a + ld a,(bc) + ld a,(de) + ld (bc),a + ld (de),a + ld a,(ix+0) + ld a,(iy+127) + ld (ix-128),b + ld (iy+10),c + ld sp,hl + ld sp,ix + ld sp,iy + +; ------------------------------------------------------------------- +; Undocumented instructions +; ------------------------------------------------------------------- + sl1 b ; shift left, set bit 0 + in (c) ; input but discard result + out (c),0 ; output zero + +; ------------------------------------------------------------------- +; Undocumented: IX/IY half registers +; ------------------------------------------------------------------- + ld a,ixh + ld a,ixl + ld a,iyh + ld a,iyl + ld ixh,a + ld ixl,b + ld iyh,c + ld iyl,d + add a,ixh + sub ixl + and iyh + or iyl + cp ixh + inc ixl + dec iyh + +; ------------------------------------------------------------------- +; Number formats +; ------------------------------------------------------------------- + ld a,$FF ; hex with $ prefix + ld a,255 ; decimal + + ld a,0xFF ; hex with 0x prefix + ld a,0XFF ; hex with 0X prefix + ld a,0FFh ; hex with h suffix + ld a,0FFH ; hex with H suffix + ld a,10101010b ; binary with b suffix + ld a,10101010B ; binary with B suffix + ld a,377o ; octal with o suffix + ld a,377O ; octal with O suffix + ld a,377q ; octal with q suffix + ld a,377Q ; octal with Q suffix + ld a,255d ; decimal with d suffix + ld a,255D ; decimal with D suffix + + ld a,'A' ; character constant + +; ------------------------------------------------------------------- +; Current address ($) +; ------------------------------------------------------------------- + jp $ ; current address + +; ------------------------------------------------------------------- +; Pseudo-ops: EQU (fixed constant) +; ------------------------------------------------------------------- +CONST1 equ $10 +CONST2 EQU $20 +CONST3 equ CONST1 + CONST2 + +; ------------------------------------------------------------------- +; Pseudo-ops: DEFL / SET (reassignable) +; ------------------------------------------------------------------- +COUNTER defl 0 +COUNTER DEFL COUNTER + 1 +COUNTER set COUNTER + 1 +COUNTER SET COUNTER + 1 + +; ------------------------------------------------------------------- +; Pseudo-ops: compound assignment operators +; ------------------------------------------------------------------- +COUNTER += 5 +COUNTER -= 2 +COUNTER *= 3 + +; ------------------------------------------------------------------- +; Pseudo-ops: increment/decrement +; ------------------------------------------------------------------- +COUNTER ++ +COUNTER -- + +; ------------------------------------------------------------------- +; Data: DEFB / DB / BYTE / ASCII / TEXT / DEFM / DM +; ------------------------------------------------------------------- + defb $EE,$FF + DEFB $EE,$FF + db 1,2,3 + DB 1,2,3 + byte $AA,$BB + BYTE $AA,$BB + defm "Hello, World!" + DEFM "Hello, World!" +;;; dm "Test" +;;; DM "Test" + ascii "ABC" + ASCII "ABC" + text "xyz" + TEXT "xyz" + +; ------------------------------------------------------------------- +; Data: DEFW / DW / WORD +; ------------------------------------------------------------------- + defw $ABCD + DEFW $ABCD + dw $1234,$5678 + DW $1234,$5678 + word $9ABC + WORD $9ABC + +; ------------------------------------------------------------------- +; Data: DEF3 / D3 (24-bit) +; ------------------------------------------------------------------- +;;; def3 $123456 +;;; DEF3 $123456 +;;; d3 $ABCDEF +;;; D3 $ABCDEF + +; ------------------------------------------------------------------- +; Data: DEFD / DWORD (32-bit) +; ------------------------------------------------------------------- + defd $12345678 + DEFD $12345678 + dword $DEADBEEF + DWORD $DEADBEEF + +; ------------------------------------------------------------------- +; Data: DEFS / DS / BLOCK / RMEM (reserve space) +; ------------------------------------------------------------------- + defs 4 + DEFS 4 + ds 8 + DS 8 + block 16 + BLOCK 16 + rmem 2 + RMEM 2 + +; ------------------------------------------------------------------- +; Data: DC (string with high bit set on last char / repeat fill) +; ------------------------------------------------------------------- + dc 'Hello' + DC 10,$FF + +; ------------------------------------------------------------------- +; Data: INCBIN +; ------------------------------------------------------------------- +;;; incbin "garagesink.bin" +;;; INCBIN "garagesink.bin" + +; ------------------------------------------------------------------- +; Strings and characters +; ------------------------------------------------------------------- + defb 'A' ; single char in single quotes + DEFB 'String too' ; string in single quotes + defb "Hello" ; string in double quotes + defw 1234h ; two-char constant = 'H'*256 + 'L' + DEFW 1234h ; two-char constant = 'H'*256 + 'L' +;;; defw 'LH' ; two-char constant = 'H'*256 + 'L' + +; ------------------------------------------------------------------- +; Include directives +; ------------------------------------------------------------------- + include "kitchensink2.zmac" + INCLUDE "kitchensink2.zmac" + read "kitchensink2.zmac" + READ "kitchensink2.zmac" + + include "kitchensink3.lib" + maclib "kitchensink3.lib" + MACLIB "kitchensink3.lib" + +; ------------------------------------------------------------------- +; PHASE / DEPHASE (relocatable code) +; ------------------------------------------------------------------- + phase $C000 + nop + dephase + + PHASE $C000 + nop + DEPHASE + + .phase $D000 + nop + .dephase + + .PHASE $D000 + nop + .DEPHASE + +; ------------------------------------------------------------------- +; Macros: MACRO / ENDM / EXITM / LOCAL +; ------------------------------------------------------------------- +LoadImm macro val + ld a,val + exitm + endm + +AddPair MACRO r1,r2,?skip + LOCAL dummy + add a,r1 + jr nc,?skip + inc r2 +?skip: + EXITM + ENDM + +WithLocal macro arg + local done + ld a,arg + or a + jr z,done + inc a +done: + endm + + ; Macro invocations + LoadImm 42 + AddPair b,c + WithLocal $FF + +; ------------------------------------------------------------------- +; Conditionals: IF / ELSE / ENDIF +; ------------------------------------------------------------------- + if CONST1 == $10 + nop + else + halt + endif + + IF CONST2 != $10 + nop + ELSE + halt + ENDIF + +; ------------------------------------------------------------------- +; Conditionals: IFDEF / IFNDEF +; ------------------------------------------------------------------- + ifdef CONST1 + nop + endif + + IFDEF CONST1 + ENDIF + + ifndef UNDEFINED_SYMBOL + nop + endif + +; ------------------------------------------------------------------- +; Conditionals: COND / ENDC (synonyms for IF / ENDIF) +; ------------------------------------------------------------------- + cond CONST1 + nop + endc + + COND CONST1 + nop + ENDC + +; ------------------------------------------------------------------- +; Conditionals: IFEQ / IFNE / IFLT / IFGT +; ------------------------------------------------------------------- +;;; ifeq CONST1,$10 +;;; nop +;;; endif + +;;; ifne CONST1,$20 +;;; nop +;;; endif + +;;; iflt CONST1,$20 +;;; nop +;;; endif + +;;; ifgt CONST2,$10 +;;; nop +;;; endif + +; ------------------------------------------------------------------- +; REPT (repeat block) +; ------------------------------------------------------------------- + rept 4 + nop + endm + + REPT 4 + nop + ENDM + +; ------------------------------------------------------------------- +; IRP (iterate with replacement parameter) +; ------------------------------------------------------------------- + irp reg, + inc reg + endm + + IRP reg, + inc reg + ENDM + +; ------------------------------------------------------------------- +; IRPC (iterate characters) +; ------------------------------------------------------------------- + irpc ch,ABC + defb 'ch' + endm + + IRPC ch,ABC + defb 'ch' + ENDM + +; ------------------------------------------------------------------- +; Expressions: arithmetic operators +; ------------------------------------------------------------------- +EXPR_ADD equ 1 + 2 +EXPR_SUB equ 10 - 3 +EXPR_MUL equ 4 * 5 +EXPR_DIV equ 20 / 4 +EXPR_MOD equ 17 % 5 + +; ------------------------------------------------------------------- +; Expressions: bitwise operators +; ------------------------------------------------------------------- +EXPR_AND equ $FF & $0F +EXPR_OR equ $F0 | $0F +EXPR_XOR equ $FF ^ $AA +EXPR_SHL equ 1 << 4 +EXPR_SHR equ $80 >> 3 + +; ------------------------------------------------------------------- +; Expressions: comparison operators +; ------------------------------------------------------------------- +EXPR_EQ equ [1 == 1] +EXPR_NE equ [1 != 2] +EXPR_LT equ [1 < 2] +EXPR_GT equ [2 > 1] +EXPR_LE equ [1 <= 1] +EXPR_GE equ [2 >= 1] + +; ------------------------------------------------------------------- +; Expressions: logical operators +; ------------------------------------------------------------------- +EXPR_LAND equ [1 && 1] +EXPR_LOR equ [0 || 1] + +; ------------------------------------------------------------------- +; Expressions: unary operators +; ------------------------------------------------------------------- +EXPR_NEG equ -1 +EXPR_NOT equ !0 +EXPR_CPL equ ~$FF +EXPR_LO equ low $1234 +EXPR_HI equ high $1234 + +; ------------------------------------------------------------------- +; Expressions: parentheses and bracket grouping +; ------------------------------------------------------------------- +EXPR_PARNS equ (2 + 3) * 4 +EXPR_BRACK equ [2 + 3] * 4 + +; ------------------------------------------------------------------- +; Expressions: complex nested +; ------------------------------------------------------------------- +EXPR_COMPLEX equ [[1 + 2] * [3 + 4]] & $FF + +; ------------------------------------------------------------------- +; Expressions: word synonym operators +; ------------------------------------------------------------------- +EXPR_MOD2 equ 17 mod 5 +EXPR_SHL2 equ 1 shl 4 +EXPR_SHR2 equ $80 shr 3 +EXPR_AND2 equ $FF and $0F +EXPR_OR2 equ $F0 or $0F +EXPR_XOR2 equ $FF xor $AA +EXPR_NOT2 equ not 0 +EXPR_EQ2 equ [1 eq 1] +EXPR_NE2 equ [1 ne 2] +EXPR_LT2 equ [1 lt 2] +EXPR_GT2 equ [2 gt 1] +EXPR_LE2 equ [1 le 1] +EXPR_GE2 equ [2 ge 1] + +; ------------------------------------------------------------------- +; Cycle counting: SETT / T() +; ------------------------------------------------------------------- +cycle_start: + nop + nop + nop +cycle_end: +CYCLES equ t(cycle_end) - t(cycle_start) + +; ------------------------------------------------------------------- +; ASSERT +; ------------------------------------------------------------------- + assert CONST1 == $10 + ASSERT CONST1 == $10 + +; ------------------------------------------------------------------- +; Listing pseudo-ops +; ------------------------------------------------------------------- + list 1 + LIST -1 + title 'Kitchen Sink Test' + TITLE 'Kitchen Sink Test' + +; ------------------------------------------------------------------- +; NAME +; ------------------------------------------------------------------- + name 'kitchensink' + NAME 'kitchensink' + +; ------------------------------------------------------------------- +; JR promotion +; ------------------------------------------------------------------- + jrpromote 1 ; enable JR->JP promotion + JRPROMOTE 1 ; enable JR->JP promotion + +; ------------------------------------------------------------------- +; Segments (for .rel output) +; ------------------------------------------------------------------- + aseg + cseg + dseg + + ASEG + CSEG + DSEG + +; ------------------------------------------------------------------- +; EXTERN / PUBLIC (for .rel output) +; ------------------------------------------------------------------- + extern ExtSym1,ExtSym2 + EXTERN ExtSym1,ExtSym2 + public start + PUBLIC start + +; ------------------------------------------------------------------- +; END +; ------------------------------------------------------------------- + end start ; assembly stops, entry address = start + END start ; assembly stops, entry address = start + +; =========================================================================== +; End of kitchen sink +; =========================================================================== diff --git a/presets/zx/kitchensink2.zmac b/presets/zx/kitchensink2.zmac new file mode 100644 index 000000000..25c1e872c --- /dev/null +++ b/presets/zx/kitchensink2.zmac @@ -0,0 +1 @@ +; kitchensink2.zmac \ No newline at end of file diff --git a/presets/zx/kitchensink3.lib b/presets/zx/kitchensink3.lib new file mode 100644 index 000000000..99d5ca8ba --- /dev/null +++ b/presets/zx/kitchensink3.lib @@ -0,0 +1 @@ +; kitchensink3.lib \ No newline at end of file diff --git a/src/parser/lang-6502.grammar b/src/parser/lang-6502.grammar index 633af01f7..4d87bec93 100644 --- a/src/parser/lang-6502.grammar +++ b/src/parser/lang-6502.grammar @@ -12,40 +12,27 @@ Statement { HexDirective | MacroDef | MacEnd | - ControlOp | - ErrorOp + ControlOp } -Label { Identifier ":" | Identifier } +Label { (Identifier | LocalIdentifier) Colon | Identifier | LocalIdentifier } Instruction { Opcode Operand? } -Register { - @specialize -} +@external specialize {Identifier} registerSpecializer from "../../src/parser/tokens-6502" { Register } +@external specialize {Identifier} onOffSpecializer from "../../src/parser/tokens-6502" { OnOff } +@external specialize {Identifier} hexOpSpecializer from "../../src/parser/tokens-6502" { HexOp } +@external specialize {Identifier} opcodeSpecializer from "../../src/parser/tokens-6502" { Opcode } Directive { - PseudoOp (Expression)* -} - -PseudoOp { - @specialize + PseudoOp (Expression)* | + Equals (Expression)* } -HexOp { @specialize } +@external specialize {Identifier} pseudoOpSpecializer from "../../src/parser/tokens-6502" { PseudoOp } +@external specialize {Identifier} localIdentifierSpecializer from "../../src/parser/tokens-6502" { LocalIdentifier } HexDirective { HexOp HexByte* @@ -53,11 +40,9 @@ HexDirective { @external tokens hexTokenizer from "../../src/parser/tokens-6502" { HexByte } -Mac { @specialize } -MacEnd { @specialize } +@external specialize {Identifier} macSpecializer from "../../src/parser/tokens-6502" { Mac, MacEnd } -ControlOp { @specialize } -ErrorOp { @specialize } +@external specialize {Identifier} controlOpSpecializer from "../../src/parser/tokens-6502" { ControlOp } MacroDef { Mac Identifier @@ -67,25 +52,6 @@ CurrentAddress { @specialize } -Opcode { - @specialize -} - Expression { Expression !logic LogicOp Expression | Expression !bit BitOp Expression | @@ -108,13 +74,15 @@ UnaryGt { gt !un } Value { Number | Identifier | + LocalIdentifier | + OnOff | CurrentAddress | String | Char } Operand { - "#" Expression | + ImmediatePrefix Expression | "(" Expression Comma Register ")" | Expression (Comma Register)? | Register @@ -129,7 +97,7 @@ Operand { $[0-9]+ } - String { '"' (!["\\\n] | "\\" _)* '"' } + String { '"' !["\n]* '"' } Char { "'" ![\n] "'"? } @@ -139,7 +107,8 @@ Operand { eol { $[\n\r]+ } Comma { "," } - "#" + Colon { ":" } + ImmediatePrefix { "#" } "(" ")" ArithOp { "*" | "/" } @@ -153,6 +122,7 @@ Operand { LogicOp { "&&" | "||" } Not { "!" } + Equals { "=" } CompareOp { "==" | "!=" | "<=" | ">=" } lt { "<" } gt { ">" } diff --git a/src/parser/lang-6502.ts b/src/parser/lang-6502.ts index 97d65068e..bb15ed8c4 100644 --- a/src/parser/lang-6502.ts +++ b/src/parser/lang-6502.ts @@ -13,15 +13,27 @@ export const Lezer6502: LRLanguage = LRLanguage.define({ }), styleTags({ Identifier: t.variableName, + LocalIdentifier: t.local(t.variableName), CurrentAddress: t.self, - PseudoOp: t.definition(t.variableName), - Opcode: t.keyword, + // t.constant() + // t.function() + // t.standard() + // t.local() + + // t.literal + // t.modifier + // t.quote + // t.processingInstruction + PseudoOp: t.keyword, + Equals: t.keyword, + Opcode: t.standard(t.keyword), Label: t.labelName, String: t.string, - Char: t.number, + Char: t.character, Number: t.number, - Register: t.typeName, - Comment: t.lineComment, + Register: t.standard(t.modifier), + OnOff: t.bool, + Comment: t.comment, ArithOp: t.arithmeticOperator, Plus: t.arithmeticOperator, Minus: t.arithmeticOperator, @@ -35,14 +47,15 @@ export const Lezer6502: LRLanguage = LRLanguage.define({ BinaryGt: t.compareOperator, UnaryLt: t.arithmeticOperator, UnaryGt: t.arithmeticOperator, - HexOp: t.definition(t.variableName), + HexOp: t.keyword, HexByte: t.number, Mac: t.definitionKeyword, MacEnd: t.definitionKeyword, "MacroDef/Identifier": t.macroName, ControlOp: t.controlKeyword, - ErrorOp: t.keyword, + ImmediatePrefix: t.constant(t.modifier), Comma: t.separator, + Colon: t.separator, "( )": t.paren }) ] diff --git a/src/parser/lang-z80.grammar b/src/parser/lang-z80.grammar index b727186bd..3a2ce60e2 100644 --- a/src/parser/lang-z80.grammar +++ b/src/parser/lang-z80.grammar @@ -8,10 +8,13 @@ Line { Statement { Instruction | - Directive + Directive | + MacroDef | + MacEnd | + ControlOp } -Label { Identifier ":" | Identifier } +Label { Identifier Colon Colon? | Identifier } Instruction { Opcode Operand? @@ -21,66 +24,16 @@ Directive { PseudoOp (Expression)* } -PseudoOp { - @specialize +MacroDef { + Mac Identifier } -Condition { - @specialize -} - -Register { - @specialize -} - -Opcode { - @specialize -} +@external specialize {Identifier} pseudoOpSpecializer from "../../src/parser/tokens-z80" { PseudoOp } +@external specialize {Identifier} macSpecializer from "../../src/parser/tokens-z80" { Mac, MacEnd } +@external specialize {Identifier} controlOpSpecializer from "../../src/parser/tokens-z80" { ControlOp } +@external specialize {Identifier} opcodeSpecializer from "../../src/parser/tokens-z80" { Opcode } +@external specialize {Identifier} registerSpecializer from "../../src/parser/tokens-z80" { Register } +@external specialize {Identifier} conditionSpecializer from "../../src/parser/tokens-z80" { Condition } Expression { Expression !logic LogicOp Expression | @@ -115,18 +68,18 @@ Operand { } @tokens { - Identifier { $[a-zA-Z_] $[a-zA-Z0-9_]* } + Identifier { $[a-zA-Z_.?] $[a-zA-Z0-9_.?]* } - Hex { ("0x" | "$") $[0-9a-fA-F]+ | $[0-9] $[0-9a-fA-F]* "h" } - Bin { "%" $[01]+ | $[01]+ "b" } - Oct { "0o" $[0-7]+ | $[0-7]+ "o" } - Dec { $[0-9]+ } + Hex { ("0x" | "0X" | "$") $[0-9a-fA-F]+ | $[0-9] $[0-9a-fA-F]* $[hH] } + Bin { $[01]+ $[bB] } + Oct { ("0o" | "0O") $[0-7]+ | $[0-7]+ $[oOqQ] } + Dec { $[0-9]+ $[dD]? } Number { Hex | Bin | Oct | Dec } - String { '"' (!["\\\n] | "\\" _)* '"' } + String { '"' !["\n]* '"' } - Char { "'" !['\\\n] "'"? } + Char { "'" !['\n] "'"? } Comment { ";" ![\n]* } @@ -134,7 +87,7 @@ Operand { eol { $[\n\r]+ } Comma { "," } - ":" + Colon { ":" } "#" "(" ")" diff --git a/src/parser/lang-z80.ts b/src/parser/lang-z80.ts index ba1cf47c5..882066517 100644 --- a/src/parser/lang-z80.ts +++ b/src/parser/lang-z80.ts @@ -7,15 +7,15 @@ export const LezerZ80: LRLanguage = LRLanguage.define({ props: [ styleTags({ Identifier: t.variableName, - PseudoOp: t.definition(t.variableName), - Opcode: t.keyword, - Register: t.typeName, - Condition: t.className, + PseudoOp: t.keyword, + Opcode: t.standard(t.keyword), + Register: t.standard(t.modifier), + Condition: t.standard(t.modifier), Label: t.labelName, String: t.string, - Char: t.number, + Char: t.character, Number: t.number, - Comment: t.lineComment, + Comment: t.comment, ArithOp: t.arithmeticOperator, Plus: t.arithmeticOperator, Minus: t.arithmeticOperator, @@ -29,7 +29,12 @@ export const LezerZ80: LRLanguage = LRLanguage.define({ BinaryGt: t.compareOperator, UnaryLt: t.arithmeticOperator, UnaryGt: t.arithmeticOperator, + Mac: t.definitionKeyword, + MacEnd: t.definitionKeyword, + "MacroDef/Identifier": t.macroName, + ControlOp: t.controlKeyword, Comma: t.separator, + Colon: t.separator, "( )": t.paren }) ] diff --git a/src/parser/tokens-6502.ts b/src/parser/tokens-6502.ts index c5b51aeb2..7e55e697f 100644 --- a/src/parser/tokens-6502.ts +++ b/src/parser/tokens-6502.ts @@ -1,5 +1,5 @@ import { ExternalTokenizer } from "@lezer/lr" -import { HexByte } from "../../gen/parser/lang-6502.grammar.terms" +import { HexByte, PseudoOp, Mac, MacEnd, ControlOp, LocalIdentifier, Opcode, Register, OnOff, HexOp } from "../../gen/parser/lang-6502.grammar.terms" function isHexDigit(ch: number) { return (ch >= 48 && ch <= 57) || // 0-9 @@ -7,6 +7,81 @@ function isHexDigit(ch: number) { (ch >= 97 && ch <= 102) // a-f } +const pseudoOps = new Set([ + "org", "rorg", "rend", + "equ", "eqm", + "end", + "seg", "seg.u", + "align", + "dc", "dc.b", "dc.w", "dc.l", "dc.s", + "ds", "ds.b", "ds.w", "ds.l", "ds.s", + "dv", "dv.b", "dv.w", "dv.l", "dv.s", + "byte", "word", "long", + "subroutine", "processor", + "include", "incbin", "incdir", + "echo", "repeat", "repend", "set", + "list", + "err", +]) + +const macKeywords: Record = { + "mac": Mac, "macro": Mac, + "endm": MacEnd, "mexit": MacEnd, +} + +const controlOps = new Set([ + "if", "else", "endif", "ifconst", "ifnconst", +]) + +const opcodes = new Set([ + "adc", "and", "asl", "bcc", "bcs", "beq", "bit", "bmi", + "bne", "bpl", "brk", "bvc", "bvs", "clc", "cld", "cli", + "clv", "cmp", "cpx", "cpy", "dec", "dex", "dey", "eor", + "inc", "inx", "iny", "jmp", "jsr", "lda", "ldx", "ldy", + "lsr", "nop", "ora", "pha", "php", "pla", "plp", "rol", + "ror", "rti", "rts", "sbc", "sec", "sed", "sei", "sta", + "stx", "sty", "tax", "tay", "tsx", "txa", "txs", "tya", +]) + +const registers = new Set(["a", "x", "y"]) + +const onOffValues = new Set(["on", "off"]) + +export function pseudoOpSpecializer(value: string) { + let normalized = value.startsWith(".") ? value.slice(1) : value + return pseudoOps.has(normalized.toLowerCase()) ? PseudoOp : -1 +} + +export function macSpecializer(value: string) { + let normalized = value.startsWith(".") ? value.slice(1) : value + return macKeywords[normalized.toLowerCase()] ?? -1 +} + +export function controlOpSpecializer(value: string) { + let normalized = value.startsWith(".") ? value.slice(1) : value + return controlOps.has(normalized.toLowerCase()) ? ControlOp : -1 +} + +export function localIdentifierSpecializer(value: string) { + return value.startsWith(".") && value.length > 1 ? LocalIdentifier : -1 +} + +export function opcodeSpecializer(value: string) { + return opcodes.has(value.toLowerCase()) ? Opcode : -1 +} + +export function registerSpecializer(value: string) { + return registers.has(value.toLowerCase()) ? Register : -1 +} + +export function onOffSpecializer(value: string) { + return onOffValues.has(value.toLowerCase()) ? OnOff : -1 +} + +export function hexOpSpecializer(value: string) { + return value.toLowerCase() === "hex" ? HexOp : -1 +} + export const hexTokenizer = new ExternalTokenizer((input) => { if (!isHexDigit(input.peek(0)) || !isHexDigit(input.peek(1))) return let len = 2 diff --git a/src/parser/tokens-z80.ts b/src/parser/tokens-z80.ts new file mode 100644 index 000000000..e75477910 --- /dev/null +++ b/src/parser/tokens-z80.ts @@ -0,0 +1,90 @@ +import { PseudoOp, Mac, MacEnd, ControlOp, Opcode, Register, Condition } from "../../gen/parser/lang-z80.grammar.terms" + +const pseudoOps = new Set([ + "org", "equ", "defl", "end", + "phase", "dephase", + "defb", "db", "byte", "ascii", "text", "defm", "dm", + "defw", "dw", "word", + "defd", "dword", "def3", "d3", + "defs", "ds", "block", "rmem", + "dc", "incbin", "include", "read", "maclib", "import", + "public", "global", "entry", "extern", "ext", "extrn", + "assert", "list", "nolist", "title", "name", "eject", "space", + "jrpromote", "jperror", + "rept", "irp", "irpc", "local", + "sett", "tstate", "setocf", + "rsym", "wsym", + "aseg", "cseg", "dseg", "common", + "comment", "pragma", "subttl", + "z80", "8080", "z180", + "min", "max", +]) + +const macKeywords: Record = { + "macro": Mac, + "endm": MacEnd, "exitm": MacEnd, +} + +const controlOps = new Set([ + "if", "else", "endif", + "ifdef", "ifndef", + "cond", "endc", + "ifeq", "ifne", "iflt", "ifgt", +]) + +const opcodes = new Set([ + // Z80 instructions + "ld", "push", "pop", "inc", "dec", "add", "adc", "sub", "sbc", "and", "or", "xor", + "cp", "ret", "jp", "jr", "call", "rst", "nop", "halt", "di", "ei", + "im", "ex", "exx", "neg", "cpl", "ccf", "scf", "rlca", "rla", "rrca", "rra", + "rlc", "rl", "rrc", "rr", "sla", "sra", "srl", "sl1", "bit", "set", "res", + "out", "in", "djnz", "rld", "rrd", "ldi", "ldir", "ldd", "lddr", "cpi", "cpir", "cpd", "cpdr", + "ini", "inir", "ind", "indr", "outi", "otir", "outd", "otdr", + "daa", "reti", "retn", "pfix", "pfiy", + // 8080 instructions + "mov", "mvi", "lxi", "lda", "sta", "lhld", "shld", "ldax", "stax", + "adi", "aci", "sui", "sbi", "sbb", "ana", "ani", "xra", "xri", "ora", "ori", "cmp", + "inr", "dcr", "inx", "dcx", "dad", + "cma", "stc", "cmc", "ral", "rar", + "jmp", "jnz", "jz", "jnc", "jc", "jpo", "jpe", "jm", + "cnz", "cz", "cnc", "cc", "cpo", "cpe", "cm", + "rnz", "rz", "rnc", "rc", "rpo", "rpe", "rp", "rm", + "pchl", "sphl", "xthl", "xchg", "hlt", +]) + +const registers = new Set([ + "a", "b", "c", "d", "e", "h", "l", "i", "r", + "af", "bc", "de", "hl", "ix", "iy", "sp", "pc", "psw", + "ixh", "ixl", "iyh", "iyl", "xh", "xl", "yh", "yl", "hx", "lx", "hy", "ly", +]) + +const conditions = new Set([ + "nz", "z", "nc", "c", "po", "pe", "p", "m", +]) + +export function pseudoOpSpecializer(value: string) { + let normalized = value.startsWith(".") ? value.slice(1) : value + return pseudoOps.has(normalized.toLowerCase()) ? PseudoOp : -1 +} + +export function macSpecializer(value: string) { + let normalized = value.startsWith(".") ? value.slice(1) : value + return macKeywords[normalized.toLowerCase()] ?? -1 +} + +export function controlOpSpecializer(value: string) { + let normalized = value.startsWith(".") ? value.slice(1) : value + return controlOps.has(normalized.toLowerCase()) ? ControlOp : -1 +} + +export function opcodeSpecializer(value: string) { + return opcodes.has(value.toLowerCase()) ? Opcode : -1 +} + +export function registerSpecializer(value: string) { + return registers.has(value.toLowerCase()) ? Register : -1 +} + +export function conditionSpecializer(value: string) { + return conditions.has(value.toLowerCase()) ? Condition : -1 +} diff --git a/src/platform/c64.ts b/src/platform/c64.ts index d72ceefe8..0e5146b6b 100644 --- a/src/platform/c64.ts +++ b/src/platform/c64.ts @@ -42,6 +42,7 @@ const C64_PRESETS : Preset[] = [ {id:'hello.dasm', name:'Hello World (DASM)', category:'Assembly Language'}, {id:'hello.acme', name:'Hello World (ACME)'}, {id:'hello.wiz', name:'Hello Wiz (Wiz)'}, + // {id:'kitchensink.dasm', name:'Kitchensink (DASM)'}, ]; const C64_MEMORY_MAP = { main:[ @@ -72,7 +73,7 @@ class C64WASMPlatform extends Base6502MachinePlatform implement readAddress(a) { return this.machine.readConst(a); } getMemoryMap() { return C64_MEMORY_MAP; } showHelp() { return "https://8bitworkshop.com/docs/platforms/c64/" } - getROMExtension(rom:Uint8Array) { + getROMExtension(rom:Uint8Array) { /* if (rom && rom[0] == 0x00 && rom[1] == 0x80 && rom[2+4] == 0xc3 && rom[2+5] == 0xc2) return ".crt"; */ diff --git a/src/platform/zx.ts b/src/platform/zx.ts index 10b703602..7fd37339d 100644 --- a/src/platform/zx.ts +++ b/src/platform/zx.ts @@ -7,6 +7,7 @@ const ZX_PRESETS = [ {id:'hello.asm', name:'Hello World (ASM)'}, {id:'bios.c', name:'BIOS Routines (C)'}, {id:'cosmic.c', name:'Cosmic Impalas (C)'}, + // {id:'kitchensink.zmac', name:'Kitchensink (ZMAC)'}, ]; const ZX_MEMORY_MAP = { main:[ diff --git a/src/themes/mbo.ts b/src/themes/mbo.ts index 1df863da6..48a1e401f 100644 --- a/src/themes/mbo.ts +++ b/src/themes/mbo.ts @@ -46,17 +46,19 @@ export const mboTheme = EditorView.theme({ }, { dark: true }); export const mboHighlightStyle = HighlightStyle.define([ - { tag: t.keyword, color: "#ffb928" }, + { tag: t.standard(t.keyword), color: "#ffb928" }, { tag: [t.name, t.standard(t.name)], color: "#ffffec" }, { tag: t.variableName, color: "#9ddfe9" }, - { tag: [t.deleted, t.macroName], color: "#00a8c6" }, // maps to cm-variable-2 - { tag: [t.processingInstruction, t.string, t.inserted], color: "#b4fdb7" }, // Updated string color - { tag: t.number, color: "#33aadd" }, // Updated number color + { tag: t.local(t.variableName), color: "#7eb8c4" }, + { tag: [t.deleted, t.macroName], color: "#00a8c6" }, + { tag: [t.processingInstruction, t.keyword, t.controlKeyword], color: "#c792ea" }, + { tag: [t.string, t.inserted], color: "#b4fdb7" }, + { tag: [t.number, t.modifier], color: "#33aadd" }, { tag: [t.atom, t.bool, t.special(t.variableName)], color: "#00a8c6" }, { tag: t.definition(t.variableName), color: "#ffb928" }, - { tag: [t.propertyName, t.attributeName, t.tagName], color: "#9ddfe9" }, - { tag: t.definition(t.name), color: "#88eeff" }, // maps to cm-def - { tag: t.typeName, color: "#ffb928" }, // maps to cm-variable-3 + { tag: [t.propertyName, t.attributeName, t.tagName, t.self], color: "#9ddfe9" }, + { tag: t.definition(t.name), color: "#88eeff" }, + { tag: t.typeName, color: "#ffb928" }, { tag: t.bracket, color: "#fffffc", fontWeight: "bold" }, { tag: t.comment, color: "#95958a" }, { tag: t.link, color: "#f54b07" },