Merge pull request #63 from Russell-S-Harper/development

Simplifying code section
This commit is contained in:
Russell-S-Harper 2021-07-07 21:19:57 -04:00 committed by GitHub
commit 542af5f598
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 18 deletions

View File

@ -4,9 +4,8 @@
* = $300 ; any address outside of page zero is okay because all code is relocatable * = $300 ; any address outside of page zero is okay because all code is relocatable
CODE(DEMO) RCD(DEMO)
START
CMN CMN
SET(R0, 9.4662) SET(R0, 9.4662)
SET(R1, SQRT2) SET(R1, SQRT2)
@ -17,14 +16,15 @@ START
POP(R4) POP(R4)
SET(R5, E) SET(R5, E)
LDI(R6, R5) LDI(R6, R5)
SET(R1, ZERO) SET(R1, ZER)
INR(R1) INR(R1)
SVI(R1, R6) SVI(R1, R6)
LDI(R0, R1) LDI(R0, R1)
ESC ESC
BRK BRK
BEGIN(FACTORIAL) BGN(FACTORIAL)
POP(R1) POP(R1)
SET(R2, 1) SET(R2, 1)
MOD(R3, R1, R2) MOD(R3, R1, R2)
@ -36,18 +36,19 @@ _1 TST(R1)
BRA(_1) BRA(_1)
_2 PSH(R2) _2 PSH(R2)
RTN RTN
END(FACTORIAL) END(FACTORIAL)
END(DEMO) END(DEMO)
DATA(_) RDT(_)
; preset constants ; preset constants
DEFINE(PI, 3.14159) DEF(PI, 3.14159)
DEFINE(E, 2.71828) DEF(E, 2.71828)
DEFINE(SQRT2, 1.41421) DEF(SQRT2, 1.41421)
; working space ; working space
RESERVE(2) RES(2)
END(_) END(_)

View File

@ -78,23 +78,22 @@
#define EXT(f) .BYTE _EXT_C + (f) #define EXT(f) .BYTE _EXT_C + (f)
; header for fixed code or data ; header for fixed code or data
#define FIXED(l) .BYTE _SM_FXD : .WORD l, _END_##l - l : * = * - 5 : l .( #define FIX(l) .BYTE _SM_FXD : .WORD l, _END_##l - l : * = * - 5 : l .(
; header for relocatable code: l(abel) => starting offset, length of code ; header for relocatable code: l(abel) => starting offset, length of code
#define CODE(l) .BYTE _RLC_CD : .WORD _start - l, _END_##l - l : * = * - 5 : l .( #define RCD(l) .BYTE _RLC_CD : .WORD _rcd - l, _END_##l - l : * = * - 5 : l .( : &_rcd
#define START &_start
; header for relocatable data: l(abel) => length of zeroed data, length of preset data ; header for relocatable data: l(abel) => length of zeroed data, length of preset data
#define DATA(l) .BYTE _RLC_DT : .WORD _END_##l - _zero, _zero - l : * = * - 5 : l .( : &_data #define RDT(l) .BYTE _RLC_DT : .WORD _END_##l - _zer, _zer - l : * = * - 5 : l .( : &_rdt
; define l(abel), v(alue) ; define l(abel), v(alue)
#define DEFINE(l, v) &l .BYTE _SET_V(#v) #define DEF(l, v) &l .BYTE _SET_V(#v)
; reserve c(ount) & provide an alias for _zero ; reserve c(ount) & provide an alias for _zer
#define RESERVE(c) &ZERO : &_zero : * = * + (c) * 4 #define RES(c) &ZER : &_zer : * = * + (c) * 4
; common begin and end ; common begin and end
#define BEGIN(l) l .( #define BGN(l) l .(
#define END(l) .) : _END_##l #define END(l) .) : _END_##l
#endif /* __MACROS_H */ #endif /* __MACROS_H */

View File

@ -39,7 +39,7 @@ int main(int argc, char **argv)
q = strrchr(tokens[i].text, '"'); q = strrchr(tokens[i].text, '"');
j = (int)(q - p); j = (int)(q - p);
/* Output in .BYTE format - this code is actually dependent on EXP_FRAC */ /* Output in .BYTE format - this code is actually dependent on EXP_FRAC */
printf("0, <(%.*s - _data), >(%.*s - _data), 0", j, p, j, p); printf("0, <(%.*s - _rdt), >(%.*s - _rdt), 0", j, p, j, p);
break; break;
/* Process each _SET_V("<expression>") command */ /* Process each _SET_V("<expression>") command */
case TT_EXPRESSION: case TT_EXPRESSION: