Added code for LDD. Removed some hard coded constants.

This commit is contained in:
Russell-S-Harper 2018-09-08 11:00:19 -04:00
parent 495eb811c8
commit 13c375b242
5 changed files with 64 additions and 38 deletions

View File

@ -43,4 +43,4 @@ To build and run:
make all make all
make run make run
The makefiles use `re2c`, `flex`, `bison`, `gcc`, `cpp`, and `xa`. Will eventually provide a `./configure`. The makefiles use `re2c`, `flex`, `bison`, `gcc`, `cpp`, `xa`, `grep`, and `sed`. Will eventually provide a `./configure`.

View File

@ -6,9 +6,12 @@ system.obj: common.obj page6.obj
common.obj: rom.h common.h common.asm common.obj: rom.h common.h common.asm
xa -C -M common.asm -l common.lbl -o common.obj xa -C -M common.asm -l common.lbl -o common.obj
page6.obj: rom.h macros.h page6.src page6.obj: rom.h macros.h globals.h page6.src
cpp -P page6.src | $(XAPP) > page6.asm cpp -P page6.src | $(XAPP) > page6.asm
xa -C -M page6.asm -l page6.lbl -o page6.obj xa -C -M page6.asm -l page6.lbl -o page6.obj
globals.h: common.obj
grep -E -v '^(_|CMN_CD|CMN_DT|FN_FX)' common.lbl | sed -e 's/, 0, 0x0000//' -e 's/, / = /' -e 's/ 0x/ \x24/' > globals.h
clean: clean:
rm -f page6.asm common.obj page6.obj common.lbl page6.lbl system.obj rm -f globals.h page6.asm common.obj page6.obj common.lbl page6.lbl system.obj

View File

@ -117,7 +117,31 @@ _1 RTS ; done
.) .)
_LDD .( ; LDD r xxyy 2r yy xx Rr <- (xxyy) - load register directly from address _LDD .( ; LDD r xxyy 2r yy xx Rr <- (xxyy) - load register directly from address
RTS LDY #0 ; set up address in I0
LDA (_PC),Y
STA _I0
INY
LDA (_PC),Y
STA _I0+1
DEY ; transfer four bytes over
LDA (_I0),Y
STA _R0,X
INY
LDA (_I0),Y
STA _R0+1,X
INY
LDA (_I0),Y
STA _R0+2,X
INY
LDA (_I0),Y
STA _R0+3,X
LDA #2 ; update program counter
CLC
ADC _PCL
STA _PCL
BCC _1
INC _PCH
_1 RTS ; done
.) .)
_SVD .( ; SVD r xxyy 3r yy xx (xxyy) <- Rr - save register directly to address _SVD .( ; SVD r xxyy 3r yy xx (xxyy) <- Rr - save register directly to address

View File

@ -42,35 +42,35 @@
; macros ; macros
#define ESC .BYTE _ESC_C #define ESC .BYTE _ESC_C
#define RTN .BYTE _RTN_C #define RTN .BYTE _RTN_C
#define BRS(o) .BYTE _BRS_C, <(o - * - 3), >(o - * - 3) #define BRS(o) .BYTE _BRS_C, <((o) - * - 3), >((o) - * - 3)
#define BRA(o) .BYTE _BRA_C, <(o - * - 3), >(o - * - 3) #define BRA(o) .BYTE _BRA_C, <((o) - * - 3), >((o) - * - 3)
#define BRE(o) .BYTE _BRE_C, <(o - * - 3), >(o - * - 3) #define BRE(o) .BYTE _BRE_C, <((o) - * - 3), >((o) - * - 3)
#define BRG(o) .BYTE _BRG_C, <(o - * - 3), >(o - * - 3) #define BRG(o) .BYTE _BRG_C, <((o) - * - 3), >((o) - * - 3)
#define BRL(o) .BYTE _BRL_C, <(o - * - 3), >(o - * - 3) #define BRL(o) .BYTE _BRL_C, <((o) - * - 3), >((o) - * - 3)
#define BRZ(o) .BYTE _BRZ_C, <(o - * - 3), >(o - * - 3) #define BRZ(o) .BYTE _BRZ_C, <((o) - * - 3), >((o) - * - 3)
#define BRP(o) .BYTE _BRP_C, <(o - * - 3), >(o - * - 3) #define BRP(o) .BYTE _BRP_C, <((o) - * - 3), >((o) - * - 3)
#define BRN(o) .BYTE _BRN_C, <(o - * - 3), >(o - * - 3) #define BRN(o) .BYTE _BRN_C, <((o) - * - 3), >((o) - * - 3)
#define BRO(o) .BYTE _BRO_C, <(o - * - 3), >(o - * - 3) #define BRO(o) .BYTE _BRO_C, <((o) - * - 3), >((o) - * - 3)
#define BRU(o) .BYTE _BRU_C, <(o - * - 3), >(o - * - 3) #define BRU(o) .BYTE _BRU_C, <((o) - * - 3), >((o) - * - 3)
#define CPR(p, q) .BYTE _CPR_C, p * 16 + q #define CPR(p, q) .BYTE _CPR_C, (p) * 16 + (q)
#define LDI(p, q) .BYTE _LDI_C, p * 16 + q #define LDI(p, q) .BYTE _LDI_C, (p) * 16 + (q)
#define SVI(p, q) .BYTE _SVI_C, p * 16 + q #define SVI(p, q) .BYTE _SVI_C, (p) * 16 + (q)
#define CMR(p, q) .BYTE _CMR_C, p * 16 + q #define CMR(p, q) .BYTE _CMR_C, (p) * 16 + (q)
#define SET(r, v) .BYTE _SET_C + r, _SET_V(#v) #define SET(r, v) .BYTE _SET_C + (r), _SET_V(#v)
#define LDD(r, a) .BYTE _LDD_C + r, <(a), >(a) #define LDD(r, a) .BYTE _LDD_C + (r), <(a), >(a)
#define SVD(r, a) .BYTE _SVD_C + r, <(a), >(a) #define SVD(r, a) .BYTE _SVD_C + (r), <(a), >(a)
#define PSH(r) .BYTE _PSH_C + r #define PSH(r) .BYTE _PSH_C + (r)
#define POP(r) .BYTE _POP_C + r #define POP(r) .BYTE _POP_C + (r)
#define EXC(r) .BYTE _EXC_C + r #define EXC(r) .BYTE _EXC_C + (r)
#define INR(r) .BYTE _INR_C + r #define INR(r) .BYTE _INR_C + (r)
#define DCR(r) .BYTE _DCR_C + r #define DCR(r) .BYTE _DCR_C + (r)
#define TST(r) .BYTE _TST_C + r #define TST(r) .BYTE _TST_C + (r)
#define ADD(r, p, q) .BYTE _ADD_C + r, p * 16 + q #define ADD(r, p, q) .BYTE _ADD_C + (r), (p) * 16 + (q)
#define SUB(r, p, q) .BYTE _SUB_C + r, p * 16 + q #define SUB(r, p, q) .BYTE _SUB_C + (r), (p) * 16 + (q)
#define MUL(r, p, q) .BYTE _MUL_C + r, p * 16 + q #define MUL(r, p, q) .BYTE _MUL_C + (r), (p) * 16 + (q)
#define DIV(r, p, q) .BYTE _DIV_C + r, p * 16 + q #define DIV(r, p, q) .BYTE _DIV_C + (r), (p) * 16 + (q)
#define MOD(r, p, q) .BYTE _MOD_C + r, p * 16 + q #define MOD(r, p, q) .BYTE _MOD_C + (r), (p) * 16 + (q)
#define EXT(f) .BYTE _EXT_C + f #define EXT(f) .BYTE _EXT_C + (f)
; header, begin and end of blocks ; header, begin and end of blocks
#define HDR(a) .WORD a, _END_##a - a:* = * - 4:a .( #define HDR(a) .WORD a, _END_##a - a:* = * - 4:a .(

View File

@ -1,15 +1,14 @@
#include "rom.h" #include "rom.h"
#include "macros.h" #include "macros.h"
#include "globals.h"
* = $600 * = $600
HDR(DEMO) HDR(DEMO)
CMN CMN
SET(R0, $b8 + 28) LDD(R0, PLS_1)
SET(R2, -999999.999) LDD(R1, MNS_1)
SET(R7, 1048575.999) ADD(R2, R0, R1)
LDI(R1, R0)
SVI(R0, R2)
ESC ESC
BRK BRK