;; ;; 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 library ;; name: mainlib.inc ;; purpose: global equates & macro's for c16 library ;; revision: 1.0 ;; date: 2019/03/18 ; avoid multiple inclusions .ifndef _mainlib_inc_ _mainlib_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 error codes ; include inc/error.inc ; some useful codes ; tab .equ 09h ctlp .equ 10h lf .equ 0ah cr .equ 0dh esc .equ 1bh ; 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 ;--------------------------------------------------------------------------- ; 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 ; c8c switch accumulator/memory & index register's size to 8 bit ; and set cf & vf ; c8cv: .macro sep #pmflag.or.pxflag.or.pcflag.or.pvflag .longa off .longi off .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 ; _mainlib_inc_ ;----------------------------------------------------------------------------- ; end of file ;-----------------------------------------------------------------------------