changeset 97:5aeff8abca9c

add echo control on sbc09
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 27 Dec 2018 01:17:31 +0900
parents 6ff8754c9749
children ba0af2b8836b
files os9/level2/cmds/Makefile os9/level2/cmds/cat.asm os9/level2/cmds/fixbasic.pl os9/level2/cmds/sbc09.asm
diffstat 4 files changed, 209 insertions(+), 21 deletions(-) [+]
line wrap: on
line diff
--- a/os9/level2/cmds/Makefile	Wed Dec 26 07:57:02 2018 +0900
+++ b/os9/level2/cmds/Makefile	Thu Dec 27 01:17:31 2018 +0900
@@ -5,7 +5,7 @@
 
 OBJ1 = asm attr calldbg cmp config copy cputype date debug del deldir devs dir dir_cb dirsort  dump  echo edit \
     error free help ident irqs link list load login makdir pxd pwd procs prompt shellplus sleep tee touch tsmon unlink \
-    game09 sbc09 kernel09.s basic.s
+    game09 sbc09 cat kernel09.s basic.s
 
 
 all : $(OBJ2) $(OBJ1)
@@ -18,7 +18,9 @@
 game09 :
 	$(A09) -l $@.lst  -o $@ ../../../game09/$@.asm
 
-sbc09 :
+sbc09 : sbc09.asm
+	$(A09) -l $@.lst  -o $@ $@.asm
+cat :   cat.asm
 	$(A09) -l $@.lst  -o $@ $@.asm
 
 #   sbc09 cmds/kernel09.s
@@ -26,10 +28,10 @@
 	cp ../../../examples_forth/kernel09 kernel09.s
 
 #   sbc09 cmds/basic.s
-basic.asm : ../../../basic/basic.asm
+basic.asm : ../../../basic/basic.asm fixbasic.pl
 	perl fixbasic.pl  ../../../basic/basic.asm >  basic.asm
 
-basic.s : basic.asm
+basic.s : basic.asm 
 	$(A09) -l $@.lst  -s $@ basic.asm
 
 mdir :
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/os9/level2/cmds/cat.asm	Thu Dec 27 01:17:31 2018 +0900
@@ -0,0 +1,151 @@
+*******************************************************************2
+* sbc09 emulator * * $Id$ * * Edt/Rev YYYY/MM/DD Modified by
+* Comment 
+* ------------------------------------------------------------------ 
+* 1 2018/08/20 S. Kono * on os9 lv2 
+
+         nam   Cat
+         ttl   echo test
+
+         ifp1
+         use   defsfile
+         endc
+
+* Module header definitions
+tylg     set   Prgrm+Objct   
+atrv     set   ReEnt+rev
+rev      set   $00
+edition  set   1
+
+         mod   eom,name,tylg,atrv,start,size
+
+         org   0
+ioentry  rmb   $80
+filepath rmb   2
+parmptr  rmb   2
+stdin    rmb   1
+chksum   rmb   1
+bcount   rmb   1
+adr      rmb   2
+work     rmb   2
+readbuff rmb   $100
+         org   $400
+size     equ   .
+
+name    fcs   /Cat/
+        fcb   edition
+
+start   clr         <stdin
+        stx         <parmptr         save parameter pointer
+        stu         <work            save parameter pointer
+        bsr         catloop
+        lbsr         noecho
+        bsr         catloop
+        lbsr         setecho
+        bsr         catloop
+        ldb         #10
+        ldx         <work
+        leax        readbuff
+        bsr         getline
+        clrb
+        os9         F$Exit
+
+catloop bsr         getchar
+        bsr         putchar
+        cmpb        #C$CR
+        bne         catloop
+        bra         putcr
+
+putchar                        * Output one character in B register.
+        PSHS        X,Y
+        BRA         OUTCH1
+getchar                        * Input one character into B register.
+        PSHS        A,B,X,Y
+GETCH0
+        LDA         #0
+        LEAX        1,S
+        LDY         #1
+        OS9         I$Read
+        BCS         GETCH0
+        PULS        A,B,X,Y,PC
+putcr                          * Output a newline.
+        LDB         #C$CR
+        bsr         putchar
+        LDB         #C$LF
+        PSHS        X,Y
+OUTCH1  PSHS        A,B
+        LEAX        1,S
+        LDA         #1
+        LDY         #1
+        OS9         I$Write
+        PULS        A,B,X,Y,PC
+getpoll
+        PSHS        X,Y,D
+        LDA         #0
+        LDB         #SS.Ready
+        OS9         I$GetStt
+        CMPB        #$F6       Not Ready
+        BNE         RSENSE
+        CLRB
+        PULS        X,Y,D,PC
+RSENSE
+        ORCC        #1        set carry to indicate ready
+RNSENSE
+        PULS        X,Y,D,PC
+
+getline                        * Input line at address in X, length in B.
+        PSHS        A,B,X,Y
+GETLN0
+        CLRA
+        TFR         D,Y
+        LDA         <stdin
+        OS9         I$ReadLn
+        BCS         GETLN0
+        LEAY        -1,Y
+        TFR         Y,D
+*        LDA         D,X
+*        CMPA        #C$CR
+*        BNE         GETLN1
+*        LEAY        -1,Y
+GETLN1  STY         ,S
+        PULS        A,B,X,Y,PC
+putline                        * Output string at address in X, length in B.
+        PSHS        A,B,X,Y
+        CLRA
+        TFR         D,Y
+        LDA         <stdin
+        OS9         I$WritLn
+        PULS        A,B,X,Y,PC
+
+setecho lda          #1
+        bra          sss
+noecho  clra
+sss      pshs         a
+        sta          ,s
+        LDA         <stdin
+        ldb          #SS.Opt
+        LDX         <work
+        leax        readbuff,X
+        OS9         I$GetStt
+        bcs         err2
+        LDA         ,s
+        STA         PD.EKO-PD.OPT,X
+setopts
+        ldb         #SS.Opt         
+        lda         <stdin
+        OS9         I$SetStt
+err2
+        puls        a,pc
+
+delay   PSHS        D,X  * address **$21** 
+                         * On input the D register contains the number of timer 
+                         * ticks to wait. Each timer tick is 20ms
+        TFR         D,X
+        OS9         F$Sleep
+        PULS        D,X,PC
+
+
+
+         emod
+eom      equ   *
+         end
--- a/os9/level2/cmds/fixbasic.pl	Wed Dec 26 07:57:02 2018 +0900
+++ b/os9/level2/cmds/fixbasic.pl	Thu Dec 27 01:17:31 2018 +0900
@@ -1,23 +1,42 @@
 #!/usr/bin/perl
-#
+# 
+# 
+#  the basic source include direct ACIA access 
+#   which is not allowed in OS-9 
+#   sbc09 emulator on OS-9, echos input in default 
+#   the basic assumes input has no echo, so call echo
+#   off at initialization 
 
 while(<>) {
     next if (/^ACIA/ .. /^TDRE/) ;
     next if (/^TSTBRK/ .. /^        END/) ;
     if (/^CLEAR/) {
-print <<"EOFEOF"
-       JSR	\$24  ;; echo off (but it is not suuported on pty.asm )
+print <<"EOFEOF";
+       JSR	\$24  ;; echo off 
 EOFEOF
     }
-    if (/^GL02/) {
-        print "GL02\n";      # do not echo input
-        next;
+    #    if (/^GL02/) {
+    #    print "GL02\n";      # do not echo input
+    #    next;
+    #    }
+    if (/FDB\s+CLEAR/) {
+        print;
+print <<"EOFEOF";
+        FCC     /BYE/
+        FCB     EOL
+        FDB     EXIT
+EOFEOF
+       next;
     }
     print;
 }
 
-
-print <<"EOFEOF"
+print <<"EOFEOF";
+EXIT    
+        JSR	\$24  ;; echo off 
+        JSR	\$27  ;; echo on 
+        JMP    \$2a   ;; exit
+        
 ******************************
 ******************************
 TSTBRK	bsr	BRKEEE 	
@@ -47,3 +66,4 @@
 ******************************
 	END
 EOFEOF
+
--- a/os9/level2/cmds/sbc09.asm	Wed Dec 26 07:57:02 2018 +0900
+++ b/os9/level2/cmds/sbc09.asm	Thu Dec 27 01:17:31 2018 +0900
@@ -88,7 +88,8 @@
          puls  x,y
          jmp   $400
  
-Exit     clrb
+Exit     lbsr  setecho      
+         clrb
          os9   F$Exit
 
 iotbl
@@ -102,9 +103,11 @@
          fdb   xopenout-iotbl           ; $15
          fdb   xabortin-iotbl           ; $18
          fdb   xclosein-iotbl           ; $1B
-         fdb   xcloseout-iotbl          ; $21
-         fdb   delay-iotbl              ; $24
-         fdb   noecho-iotbl             ; $27
+         fdb   xcloseout-iotbl          ; $1E
+         fdb   delay-iotbl              ; $21
+         fdb   noecho-iotbl             ; $24
+         fdb   setecho-iotbl            ; $27
+         fdb   exit-iotbl               ; $2a
 iotblend
 
 L0049
@@ -238,17 +241,26 @@
 xcloseout
         RTS
 
-noecho  LDA         <stdin
-        CLRB
+setecho lda          #1
+        bra          sss
+noecho  clra
+sss     pshs         a
+        sta          ,s
+        LDA         <stdin
+        ldb          #SS.Opt
         LDX         <work
         leax        readbuff,X
         OS9         I$GetStt
         bcs         err2
-        CLR         IT.EKO,X
-        CLRB         
+        LDA         ,s
+        STA         PD.EKO-PD.OPT,X
+setopts
+        ldb         #SS.Opt         
+        lda         <stdin
         OS9         I$SetStt
 err2
-        RTS
+        puls        a,pc
+
 
 delay   PSHS        D,X  * address **$21** 
                          * On input the D register contains the number of timer 
@@ -257,6 +269,9 @@
         OS9         F$Sleep
         PULS        D,X,PC
 
+exit    bsr        setecho
+        clrb
+        os9        F$Exit
 
 
          emod