tools: use BASIC's new while loop

Also, increase STDIO_BUFSIZE to 0x40 so that those while loops work.
This commit is contained in:
Virgil Dupras 2019-12-12 12:04:56 -05:00
parent 3db38b0d89
commit 5b155a5c15
15 changed files with 27 additions and 41 deletions

View File

@ -27,7 +27,7 @@
; *** Consts *** ; *** Consts ***
; Size of the readline buffer. If a typed line reaches this size, the line is ; Size of the readline buffer. If a typed line reaches this size, the line is
; flushed immediately (same as pressing return). ; flushed immediately (same as pressing return).
.equ STDIO_BUFSIZE 0x20 .equ STDIO_BUFSIZE 0x40
; *** Variables *** ; *** Variables ***
; Line buffer. We read types chars into this buffer until return is pressed ; Line buffer. We read types chars into this buffer until return is pressed

View File

@ -40,7 +40,7 @@ jp aciaInt
; *** BASIC *** ; *** BASIC ***
; RAM space used in different routines for short term processing. ; RAM space used in different routines for short term processing.
.equ SCRATCHPAD_SIZE 0x20 .equ SCRATCHPAD_SIZE STDIO_BUFSIZE
.equ SCRATCHPAD AT28W_RAMEND .equ SCRATCHPAD AT28W_RAMEND
.inc "lib/util.asm" .inc "lib/util.asm"
.inc "lib/ari.asm" .inc "lib/ari.asm"

View File

@ -25,7 +25,7 @@ jp aciaInt
; *** BASIC *** ; *** BASIC ***
; RAM space used in different routines for short term processing. ; RAM space used in different routines for short term processing.
.equ SCRATCHPAD_SIZE 0x20 .equ SCRATCHPAD_SIZE STDIO_BUFSIZE
.equ SCRATCHPAD STDIO_RAMEND .equ SCRATCHPAD STDIO_RAMEND
.inc "lib/util.asm" .inc "lib/util.asm"
.inc "lib/ari.asm" .inc "lib/ari.asm"

View File

@ -24,7 +24,7 @@ jp init
; *** BASIC *** ; *** BASIC ***
; RAM space used in different routines for short term processing. ; RAM space used in different routines for short term processing.
.equ SCRATCHPAD_SIZE 0x20 .equ SCRATCHPAD_SIZE STDIO_BUFSIZE
.equ SCRATCHPAD STDIO_RAMEND .equ SCRATCHPAD STDIO_RAMEND
.inc "lib/util.asm" .inc "lib/util.asm"
.inc "lib/ari.asm" .inc "lib/ari.asm"

View File

@ -48,7 +48,7 @@ jp aciaInt
; *** BASIC *** ; *** BASIC ***
; RAM space used in different routines for short term processing. ; RAM space used in different routines for short term processing.
.equ SCRATCHPAD_SIZE 0x20 .equ SCRATCHPAD_SIZE STDIO_BUFSIZE
.equ SCRATCHPAD FS_RAMEND .equ SCRATCHPAD FS_RAMEND
.inc "lib/util.asm" .inc "lib/util.asm"
.inc "lib/ari.asm" .inc "lib/ari.asm"

View File

@ -1,10 +1,10 @@
; classic RC2014 setup (8K ROM + 32K RAM) and a stock Serial I/O module ; classic RC2014 setup (8K ROM + 32K RAM) and a stock Serial I/O module
; The RAM module is selected on A15, so it has the range 0x8000-0xffff ; The RAM module is selected on A15, so it has the range 0x8000-0xffff
.equ RAMSTART 0x8000 .equ RAMSTART 0x8000
; Kernel RAMEND last check: 0x98f3 ; Kernel RAMEND last check: 0x9933
; We allocate at least 0x100 bytes for the stack, which is why we have this ; We allocate at least 0x100 bytes for the stack, which is why we have this
; threshold. ; threshold.
.equ RAMEND 0x9a00 .equ RAMEND 0x9b00
.equ USER_CODE RAMEND ; in sync with user.h .equ USER_CODE RAMEND ; in sync with user.h
.equ ACIA_CTL 0x80 ; Control and status. RS off. .equ ACIA_CTL 0x80 ; Control and status. RS off.
.equ ACIA_IO 0x81 ; Transmit. RS on. .equ ACIA_IO 0x81 ; Transmit. RS on.
@ -67,7 +67,7 @@ jp aciaInt
; *** BASIC *** ; *** BASIC ***
; RAM space used in different routines for short term processing. ; RAM space used in different routines for short term processing.
.equ SCRATCHPAD_SIZE 0x20 .equ SCRATCHPAD_SIZE STDIO_BUFSIZE
.equ SCRATCHPAD FS_RAMEND .equ SCRATCHPAD FS_RAMEND
.inc "lib/util.asm" .inc "lib/util.asm"
.inc "lib/ari.asm" .inc "lib/ari.asm"

View File

@ -1,4 +1,4 @@
.org 0x9a00 .org 0x9b00
; *** JUMP TABLE *** ; *** JUMP TABLE ***
.equ strncmp 0x03 .equ strncmp 0x03

View File

@ -27,7 +27,7 @@
; *** BASIC *** ; *** BASIC ***
; RAM space used in different routines for short term processing. ; RAM space used in different routines for short term processing.
.equ SCRATCHPAD_SIZE 0x20 .equ SCRATCHPAD_SIZE STDIO_BUFSIZE
.equ SCRATCHPAD STDIO_RAMEND .equ SCRATCHPAD STDIO_RAMEND
.inc "lib/util.asm" .inc "lib/util.asm"
.inc "lib/ari.asm" .inc "lib/ari.asm"

View File

@ -29,7 +29,7 @@
; *** BASIC *** ; *** BASIC ***
; RAM space used in different routines for short term processing. ; RAM space used in different routines for short term processing.
.equ SCRATCHPAD_SIZE 0x20 .equ SCRATCHPAD_SIZE STDIO_BUFSIZE
.equ SCRATCHPAD STDIO_RAMEND .equ SCRATCHPAD STDIO_RAMEND
.inc "lib/util.asm" .inc "lib/util.asm"
.inc "lib/ari.asm" .inc "lib/ari.asm"

View File

@ -77,7 +77,7 @@
; *** BASIC *** ; *** BASIC ***
; RAM space used in different routines for short term processing. ; RAM space used in different routines for short term processing.
.equ SCRATCHPAD_SIZE 0x20 .equ SCRATCHPAD_SIZE STDIO_BUFSIZE
.equ SCRATCHPAD FS_RAMEND .equ SCRATCHPAD FS_RAMEND
.inc "lib/util.asm" .inc "lib/util.asm"
.inc "lib/ari.asm" .inc "lib/ari.asm"

View File

@ -40,7 +40,7 @@
; *** BASIC *** ; *** BASIC ***
; RAM space used in different routines for short term processing. ; RAM space used in different routines for short term processing.
.equ SCRATCHPAD_SIZE 0x20 .equ SCRATCHPAD_SIZE STDIO_BUFSIZE
.equ SCRATCHPAD STDIO_RAMEND .equ SCRATCHPAD STDIO_RAMEND
.inc "lib/util.asm" .inc "lib/util.asm"
.inc "lib/ari.asm" .inc "lib/ari.asm"

View File

@ -21,17 +21,18 @@ int main(int argc, char **argv)
} }
int fd = open(argv[1], O_RDWR|O_NOCTTY); int fd = open(argv[1], O_RDWR|O_NOCTTY);
char s[3]; char s[0x30];
sendcmdp(fd, "i=0");
sprintf(s, "while i<0x%04x getb:puth a:i=i+1", bytecount);
sendcmd(fd, s);
for (int i=0; i<bytecount; i++) { for (int i=0; i<bytecount; i++) {
sendcmd(fd, "getb");
read(fd, s, 2); // read prompt
sendcmd(fd, "puth a");
read(fd, s, 2); // read hex pair read(fd, s, 2); // read hex pair
s[2] = 0; // null terminate s[2] = 0; // null terminate
unsigned char c = strtol(s, NULL, 16); unsigned char c = strtol(s, NULL, 16);
putchar(c); putchar(c);
read(fd, s, 2); // read prompt
} }
read(fd, s, 2); // read prompt
return 0; return 0;
} }

View File

@ -61,7 +61,6 @@
.equ STDIO_RAMSTART BLOCKDEV_RAMEND .equ STDIO_RAMSTART BLOCKDEV_RAMEND
.equ STDIO_GETC emulGetC .equ STDIO_GETC emulGetC
.equ STDIO_PUTC emulPutC .equ STDIO_PUTC emulPutC
.equ STDIO_BUFSIZE 0x40 ; override
.inc "stdio.asm" .inc "stdio.asm"
.equ FS_RAMSTART STDIO_RAMEND .equ FS_RAMSTART STDIO_RAMEND

View File

@ -28,22 +28,18 @@ int main(int argc, char **argv)
} }
int fd = open(argv[1], O_RDWR|O_NOCTTY); int fd = open(argv[1], O_RDWR|O_NOCTTY);
char s[0x20]; char s[0x30];
sprintf(s, "m=0x%04x", memptr); sprintf(s, "m=0x%04x", memptr);
sendcmdp(fd, s);
sprintf(s, "while m<0x%04x peek m:puth a:m=m+1", memptr+bytecount);
sendcmd(fd, s); sendcmd(fd, s);
read(fd, s, 2); // read prompt
for (int i=0; i<bytecount; i++) { for (int i=0; i<bytecount; i++) {
sendcmd(fd, "peek m");
read(fd, s, 2); // read prompt
sendcmd(fd, "puth a");
read(fd, s, 2); // read hex pair read(fd, s, 2); // read hex pair
s[2] = 0; // null terminate s[2] = 0; // null terminate
unsigned char c = strtol(s, NULL, 16); unsigned char c = strtol(s, NULL, 16);
putchar(c); putchar(c);
read(fd, s, 2); // read prompt
sendcmd(fd, "m=m+1");
read(fd, s, 2); // read prompt
} }
read(fd, s, 2); // read prompt
return 0; return 0;
} }

View File

@ -5,10 +5,8 @@
#include "common.h" #include "common.h"
/* Push specified file to specified device **running the BASIC shell** and verify /* Push specified file to specified device running the BASIC shell and verify
* that the sent contents is correct. * that the sent contents is correct.
*
* Note: running this will clear the current BASIC listing on the other side.
*/ */
int main(int argc, char **argv) int main(int argc, char **argv)
@ -38,20 +36,12 @@ int main(int argc, char **argv)
} }
rewind(fp); rewind(fp);
int fd = open(argv[1], O_RDWR|O_NOCTTY); int fd = open(argv[1], O_RDWR|O_NOCTTY);
char s[0x20]; char s[0x40];
sprintf(s, "m=0x%04x", memptr); sprintf(s, "m=0x%04x", memptr);
sendcmdp(fd, s); sendcmdp(fd, s);
sprintf(s, "while m<0x%04x getc:puth a:poke m a:m=m+1", memptr+bytecount);
sendcmd(fd, s);
// Send program
sendcmdp(fd, "clear");
sendcmdp(fd, "1 getc");
sendcmdp(fd, "2 puth a");
sendcmdp(fd, "3 poke m a");
sendcmdp(fd, "4 m=m+1");
sprintf(s, "5 if m<0x%04x goto 1", memptr+bytecount);
sendcmdp(fd, s);
sendcmd(fd, "run");
int returncode = 0; int returncode = 0;
while (fread(s, 1, 1, fp)) { while (fread(s, 1, 1, fp)) {
putchar('.'); putchar('.');