; Lib Project ; Copyright (C) 2008-2009 Cryzbl ; ; File "macros.inc" ; Common macro definitions ; ; This program is free software: you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation, either version 3 of the License, or ; (at your option) any later version. ; ; This program is distributed in the hope that it will be useful, ; but WITHOUT ANY WARRANTY; without even the implied warranty of ; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ; GNU General Public License for more details. ; ; You should have received a copy of the GNU General Public License ; along with this program. If not, see <http://www.gnu.org/licenses/>. #ifndef _MACROS_INC #define _MACROS_INC ; Assembler specific stuff #ifdef BRASS ; ---- BRASS ---- ; Module handling #define END_MODULE() .endmodule ; Macro handling #define INLINE() .macro #define INLINE_PRE() \ #define INLINE_END() .endmacro #endif #ifdef TASM ; ---- TASM ---- ; Module handling #define END_MODULE() .module ; Macro handling #define INLINE() #define #define INLINE_PRE() #defcont #define INLINE_END() \ #endif ; Value handling #define HIBYTE(val) (val>>8)&255 #define LOBYTE(val) val&255 ; Dereference hl #define DEREF_HL() ld a, (hl)\ inc hl\ ld h, (hl)\ ld l, a ; Push/pop common regs #define PUSH_COMMON() push af\ push bc\ push de\ push hl #define POP_COMMON() pop hl\ pop de\ pop bc\ pop af ; Composite instructions #define MOV_HL_DE() ld h, d\ ld l, e #define MOV_HL_BC() ld h, b\ ld l, c #define MOV_DE_HL() ld d, h\ ld e, l #define MOV_DE_BC() ld d, b\ ld e, c #define MOV_BC_HL() ld b, h\ ld c, l #define MOV_BC_DE() ld b, d\ ld c, e #define MOV_IHL_DE() ld (hl), e\ inc hl\ ld (hl), d #define MOV_IHL_BC() ld (hl), c\ inc hl\ ld (hl), b #define MOV_DE_IHL() ld e, (hl)\ inc hl\ ld d, (hl) #define MOV_BC_IHL() ld c, (hl)\ inc hl\ ld b, (hl) #define OR_HL() ld a, h\ or l #define OR_DE() ld a, d\ or e #define OR_BC() ld a, b\ or c #define AND_HL() ld a, h\ and l #define AND_DE() ld a, d\ and e #define AND_BC() ld a, b\ and c #define XOR_HL() ld a, h\ xor l #define XOR_DE() ld a, d\ xor e #define XOR_BC() ld a, b\ xor c #define ADD_HL_A() add a, l\ ld l, a\ adc a, h\ sub l\ ld h, a #define ADD_DE_A() add a, e\ ld e, a\ adc a, d\ sub e\ ld d, a #define ADD_HL_A() add a, c\ ld c, a\ adc a, b\ sub c\ ld b, a #define NEG_HL() ld a, h\ cpl\ ld h, a\ ld a, l\ cpl\ ld l, a\ inc hl #define NEG_DE() ld a, d\ cpl\ ld d, a\ ld a, e\ cpl\ ld e, a\ inc de #define NEG_BC() ld a, b\ cpl\ ld b, a\ ld a, c\ cpl\ ld c, a\ inc bc #define SHR_BC() srl b\ rr c #define SHR_DE() srl d\ rr e #define SHR_HL() srl h\ rr l #define SHL_BC() sla c\ rl b #define SHL_DE() sla e\ rl d #define SHL_HL() sla l\ rl h ; 2 byte counter loops #define LOOPBC_INIT() dec bc\ ld a, c\ ld c, b\ ld b, a\ inc b\ inc c #define LOOPBC_INIT(val) ld bc, (LOBYTE(val-1)+1)*256+HIBYTE(val-1)+1 #define LOOPBC(lbl) djnz lbl \ dec c\ jr nz, lbl ; Misc #define REPORT(file, sz) .echo "- ", file, " is ", sz, " bytes large.\n" #endif ;==================== ; End of file ;====================