2018-08-07 02:14:36 +00:00
|
|
|
#include "common.h"
|
|
|
|
|
2018-08-14 01:18:13 +00:00
|
|
|
#ifndef __MACROS_H
|
|
|
|
#define __MACROS_H
|
2018-08-07 02:14:36 +00:00
|
|
|
|
2018-08-21 13:14:16 +00:00
|
|
|
; common registers
|
2018-08-07 02:14:36 +00:00
|
|
|
#define R0 0
|
|
|
|
#define R1 1
|
|
|
|
#define R2 2
|
|
|
|
#define R3 3
|
|
|
|
#define R4 4
|
|
|
|
#define R5 5
|
|
|
|
#define R6 6
|
|
|
|
#define R7 7
|
|
|
|
#define R8 8
|
|
|
|
#define R9 9
|
|
|
|
|
|
|
|
; system functions
|
|
|
|
#define S0 0
|
|
|
|
#define S1 1
|
|
|
|
#define S2 2
|
|
|
|
#define S3 3
|
|
|
|
#define S4 4
|
|
|
|
#define S5 5
|
|
|
|
#define S6 6
|
|
|
|
#define S7 7
|
|
|
|
#define S8 8
|
|
|
|
#define S9 9
|
|
|
|
|
|
|
|
; user functions
|
|
|
|
#define U0 15
|
|
|
|
#define U1 14
|
|
|
|
#define U2 13
|
|
|
|
#define U3 12
|
|
|
|
#define U4 11
|
|
|
|
#define U5 10
|
|
|
|
#define U6 9
|
|
|
|
#define U7 8
|
|
|
|
#define U8 7
|
|
|
|
#define U9 6
|
|
|
|
|
2019-01-31 23:59:01 +00:00
|
|
|
; shorthand
|
|
|
|
#define _OFF_M(o) ((o) - * - 3)
|
2019-02-05 16:32:40 +00:00
|
|
|
#define _BRX_M(o) <_OFF_M(o), >_OFF_M(o)
|
2019-03-02 23:59:18 +00:00
|
|
|
#define _MRG_M(p, q) ((p) * 16 + (q))
|
2019-01-31 23:59:01 +00:00
|
|
|
|
2018-08-07 02:14:36 +00:00
|
|
|
; macros
|
|
|
|
#define ESC .BYTE _ESC_C
|
|
|
|
#define RTN .BYTE _RTN_C
|
2019-01-31 23:59:01 +00:00
|
|
|
#define BRS(o) .BYTE _BRS_C, _BRX_M(o)
|
|
|
|
#define BRA(o) .BYTE _BRA_C, _BRX_M(o)
|
|
|
|
#define BRE(o) .BYTE _BRE_C, _BRX_M(o)
|
|
|
|
#define BRG(o) .BYTE _BRG_C, _BRX_M(o)
|
|
|
|
#define BRL(o) .BYTE _BRL_C, _BRX_M(o)
|
|
|
|
#define BRZ(o) .BYTE _BRZ_C, _BRX_M(o)
|
|
|
|
#define BRP(o) .BYTE _BRP_C, _BRX_M(o)
|
|
|
|
#define BRN(o) .BYTE _BRN_C, _BRX_M(o)
|
|
|
|
#define BRO(o) .BYTE _BRO_C, _BRX_M(o)
|
|
|
|
#define BRU(o) .BYTE _BRU_C, _BRX_M(o)
|
|
|
|
#define CPR(p, q) .BYTE _CPR_C, _MRG_M(p, q)
|
|
|
|
#define LDI(p, q) .BYTE _LDI_C, _MRG_M(p, q)
|
|
|
|
#define SVI(p, q) .BYTE _SVI_C, _MRG_M(p, q)
|
|
|
|
#define CMR(p, q) .BYTE _CMR_C, _MRG_M(p, q)
|
2018-09-08 15:00:19 +00:00
|
|
|
#define SET(r, v) .BYTE _SET_C + (r), _SET_V(#v)
|
|
|
|
#define LDD(r, a) .BYTE _LDD_C + (r), <(a), >(a)
|
|
|
|
#define SVD(r, a) .BYTE _SVD_C + (r), <(a), >(a)
|
|
|
|
#define PSH(r) .BYTE _PSH_C + (r)
|
|
|
|
#define POP(r) .BYTE _POP_C + (r)
|
|
|
|
#define EXC(r) .BYTE _EXC_C + (r)
|
|
|
|
#define INR(r) .BYTE _INR_C + (r)
|
|
|
|
#define DCR(r) .BYTE _DCR_C + (r)
|
|
|
|
#define TST(r) .BYTE _TST_C + (r)
|
2019-01-31 23:59:01 +00:00
|
|
|
#define ADD(r, p, q) .BYTE _ADD_C + (r), _MRG_M(p, q)
|
|
|
|
#define SUB(r, p, q) .BYTE _SUB_C + (r), _MRG_M(p, q)
|
|
|
|
#define MUL(r, p, q) .BYTE _MUL_C + (r), _MRG_M(p, q)
|
|
|
|
#define DIV(r, p, q) .BYTE _DIV_C + (r), _MRG_M(p, q)
|
|
|
|
#define MOD(r, p, q) .BYTE _MOD_C + (r), _MRG_M(p, q)
|
2018-09-08 15:00:19 +00:00
|
|
|
#define EXT(f) .BYTE _EXT_C + (f)
|
2018-08-07 02:14:36 +00:00
|
|
|
|
2019-04-30 01:32:06 +00:00
|
|
|
; header for fixed code or data
|
2021-07-08 01:19:07 +00:00
|
|
|
#define FIX(l) .BYTE _SM_FXD : .WORD l, _END_##l - l : * = * - 5 : l .(
|
2019-04-30 01:32:06 +00:00
|
|
|
|
2019-04-30 21:21:49 +00:00
|
|
|
; header for relocatable code: l(abel) => starting offset, length of code
|
2021-07-08 01:19:07 +00:00
|
|
|
#define RCD(l) .BYTE _RLC_CD : .WORD _rcd - l, _END_##l - l : * = * - 5 : l .( : &_rcd
|
2019-04-30 01:32:06 +00:00
|
|
|
|
2019-04-30 21:21:49 +00:00
|
|
|
; header for relocatable data: l(abel) => length of zeroed data, length of preset data
|
2021-07-08 01:19:07 +00:00
|
|
|
#define RDT(l) .BYTE _RLC_DT : .WORD _END_##l - _zer, _zer - l : * = * - 5 : l .( : &_rdt
|
2019-04-30 01:32:06 +00:00
|
|
|
|
2019-07-07 17:25:47 +00:00
|
|
|
; define l(abel), v(alue)
|
2021-07-08 01:19:07 +00:00
|
|
|
#define DEF(l, v) &l .BYTE _SET_V(#v)
|
2019-04-30 01:32:06 +00:00
|
|
|
|
2021-07-08 01:19:07 +00:00
|
|
|
; reserve c(ount) & provide an alias for _zer
|
|
|
|
#define RES(c) &ZER : &_zer : * = * + (c) * 4
|
2019-04-30 01:32:06 +00:00
|
|
|
|
|
|
|
; common begin and end
|
2021-07-08 01:19:07 +00:00
|
|
|
#define BGN(l) l .(
|
2019-07-07 17:25:47 +00:00
|
|
|
#define END(l) .) : _END_##l
|
2018-08-07 02:14:36 +00:00
|
|
|
|
2018-08-14 01:23:05 +00:00
|
|
|
#endif /* __MACROS_H */
|