;; ;; Copyright (c) 2019 Marco Granati ;; ;; Permission to use, copy, modify, and distribute this software for any ;; purpose with or without fee is hereby granted, provided that the above ;; copyright notice and this permission notice appear in all copies. ;; ;; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES ;; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF ;; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ;; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ;; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ;; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF ;; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ;; ;; project: c16 firmware ;; name: main.inc ;; purpose: global equates & macro's ;; revision: 1.0 ;; date: 2019/04/01 ; avoid multiple inclusions .ifndef _GLOBAL_INC_ _GLOBAL_INC_ .defl 1 ; global setup for 65C816 ; .chip 65816 .radix 10 .symbols .linklist .debug asm .options dc2 .linear on .spaces on .longa off .longi off include inc/error.inc ; direct page equates ; ;dp08 .equ $0800 ; some useful codes ; tab .equ 09h ctlp .equ 10h lf .equ 0ah cr .equ 0dh esc .equ 1bh shcr .equ 8dh ; input/output text devices ; std_in .equ 0 ; keyboard: input only std_sp .equ 1 ; serial port std_out .equ 3 ; screen std_aux .equ 4 ; aux. device on slave usb std_null .equ 5 ; null input/output device stmrcnt .equ 4 ; system timer's count ; scn_* constant for print control char's ; scn_up .equ $01 scn_left .equ $02 scn_right .equ $03 scn_down .equ $04 scn_rvson .equ $05 scn_rvsoff .equ $06 scn_blinkon .equ $07 scn_blinkoff .equ $08 scn_ulon .equ $0b scn_uloff .equ $0c scn_clrattr .equ $0e scn_shtab .equ $0f scn_clr .equ $11 ; clear screen scn_home .equ $12 ; home ; status register bits ; pnflag .equ 10000000B ; negative flag pvflag .equ 01000000B ; overflow flag pmflag .equ 00100000B ; acc/mem 8 bit flag pxflag .equ 00010000B ; index 8 bit flag pdflag .equ 00001000B ; decimal flag piflag .equ 00000100B ; interrupt disable flag pzflag .equ 00000010B ; zero flag pcflag .equ 00000001B ; carry flag ; fdc controller error's ; fdc_bad .equ $01 ; bad controller fdc_sndtmo .equ $02 ; sendto routine timeout fdc_restmo .equ $03 ; fdc controller result phase timeout fdc_inttmo .equ $04 ; fdc controller interrupt timeout fdc_badres .equ $05 ; too many bytes in result phase fdc_fault .equ $06 ; restore/recalibrate error fdc_seek .equ $07 ; seek error fdc_dloss .equ $08 ; data loss fdc_datacrc .equ $09 ; data crc error fdc_noid .equ $0a ; id not found fdc_wp .equ $0b ; write protect fdc_mark .equ $0c ; mark address not found fdc_notready .equ $0d ; disk not ready fdc_change .equ $0e ; disk changed ; error codes ; einval .equ $01 ; 'invalid function' enoent .equ $02 ; 'no such file or directory' enopath .equ $03 ; 'path not found' elong .equ $04 ; 'too long' eperm .equ $20 ; 'operation not permitted' ; equates for access stack data (offset relative to the sp register) ; for use in system functions (called with jsl instruction) ; offset below are 3 more for take count of 3 bytes pushed by jsl ; stkcnt .set $04 stky .set $09 stkx .set $0b stka .set $0d stkp .set $0f stkpc .set $10 stkpbr .set $12 stkprm .set $13 ; start of parameter's ; ram equates ; inpbuf .equ $014000 inpbufsiz .equ 256 ;--------------------------------------------------------------------------- ; macro's ;--------------------------------------------------------------------------- ; useful macro's for switch register's size ; ; am16 switch accumulator/memory size to 16 bit ; am16: .macro rep #pmflag .longa on .endm ; xy16 switch index register's size to 16 bit ; xy16: .macro rep #pxflag .longi on .endm ; c16 switch accumulator/memory & index register's size to 16 bit ; c16: .macro rep #pmflag.or.pxflag .longa on .longi on .endm ; am8 switch accumulator/memory size to 8 bit ; am8: .macro sep #pmflag .longa off .endm ; xy8 switch index register's size to 8 bit ; xy8: .macro sep #pxflag .longi off .endm ; c8 switch accumulator/memory & index register's size to 8 bit ; c8: .macro sep #pmflag.or.pxflag .longa off .longi off .endm ; am16c switch accumulator/memory size to 16 bit and reset carry ; am16c: .macro rep #pmflag.or.pcflag .longa on .endm ; xy16c switch index register's size to 16 bit and reset carry ; xy16c: .macro rep #pxflag.or.pcflag .longi on .endm ; c16c switch accumulator/memory & index register's size to 16 bit ; and reset carry ; c16c: .macro rep #pmflag.or.pxflag.or.pcflag .longa on .longi on .endm ; am8c switch accumulator/memory size to 8 bit and set carry ; am8c: .macro sep #pmflag.or.pcflag .longa off .endm ; am8cv switch accumulator/memory size to 8 bit and set cf & vf ; am8cv: .macro sep #pmflag.or.pcflag.or.pvflag .longa off .endm ; xy8c switch index register's size to 8 bit and set carry ; xy8c: .macro sep #pxflag.or.pcflag .longi off .endm ; c8c switch accumulator/memory & index register's size to 8 bit ; and set carry ; c8c: .macro sep #pmflag.or.pxflag.or.pcflag .longa off .longi off .endm ; sect $bank define a code section in a bank ; sect .macro name bank|name| .section .ends .endm ; struct name start a struct definition with page 0 attribute ; struct .macro name _|name| .section page0,common,ref_only,offset 0 ;name Struct .endm ; lstruct name start a struct definition ; lstruct .macro name _|name| .section common,ref_only,offset 0 ;name Struct .endm ; estruct mark the end of a struct/lstruct ; define a 'name_size' label for struct size ; estruct .macro name |name|_size .ds 0 .ends .endm ; lp define a long pointer (24 bits) ; lp .macro .ds 3 .endm ; dd define a 32 bits integer ; dd .macro .lword .endm .endif ; _GLOBAL_INC_