From 72e142b32380cb1c59ea9846b4f5994487e88132 Mon Sep 17 00:00:00 2001 From: Naren Ratan Date: Sun, 1 Dec 2019 22:47:27 +0000 Subject: Add counter register --- jonesforth.S | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/jonesforth.S b/jonesforth.S index c585eff..99733ce 100644 --- a/jonesforth.S +++ b/jonesforth.S @@ -26,6 +26,8 @@ #define E x17 // End pointer #define OUTB x11 // Output buffer pointer +#define n x10 // Count register + // Stack macros .macro push s,x; str \x,[\s,-8]!; .endm // e.g. push D,x0 pushes x0 to data stack .macro push2 s,x,y; stp \y,\x,[\s,-16]!; .endm // One instruction, two pushes! @@ -109,6 +111,10 @@ def "D0"; push D,D0; NEXT def "R0"; push D,R0; NEXT def DOCOL; push D,PDOC; NEXT +def "n"; push D,n; NEXT; def "n!"; pop D,n; NEXT +def "n+"; add n,n,1; NEXT; def "n-"; sub n,n,1; NEXT +def "n0"; mov n,0; NEXT + def KEY; bl key; push D,x0; NEXT; key: cmp K,E; b.ge fill; ldrb w0,[K],1; ret // Fill buffer if exhausted and read next character @@ -238,6 +244,7 @@ _start: mov D,sp // Initialize Data stack pointer adr B,b; mov K,B; mov E,B // Initialize Buffer, Key, End pointers adr OUTB,outb // Initialize output buffer pointer mov D0,D; mov R0,R // Initialize stack top pointers + mov n,0; // Initialize count register adr PLIT,LIT; adr PDOC,docol // Initialize LIT and DOCOL pointers movi VC0A.16b,10; movi VC0F.16b,0x0F // Initialize constant vector registers movi VC20.16b,32; movi VC30.16b,'0' -- cgit 1.4.1-2-gfad0