changeset 86:4967d1acd34a

add sbc09.asm
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Mon, 20 Aug 2018 00:48:11 +0900
parents 4652761a60f9
children 60e629904ad6
files src/os9/level2/cmds/Makefile src/os9/level2/cmds/loop.asm src/os9/level2/cmds/sbc09.asm
diffstat 3 files changed, 253 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/src/os9/level2/cmds/Makefile	Sun Aug 12 12:34:56 2018 +0900
+++ b/src/os9/level2/cmds/Makefile	Mon Aug 20 00:48:11 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
+    game09 sbc09
 
 
 all : $(OBJ2) $(OBJ1)
@@ -18,6 +18,8 @@
 game09 :
 	$(A09) -l $@.lst  -o $@ ../../../../game09/$@.asm
 
+sbc09 :
+	$(A09) -l $@.lst  -o $@ $@.asm
 mdir :
 	$(A09) -l $@.lst  -o $@ $(SRC2)/$@.asm
 mfree :
--- a/src/os9/level2/cmds/loop.asm	Sun Aug 12 12:34:56 2018 +0900
+++ b/src/os9/level2/cmds/loop.asm	Mon Aug 20 00:48:11 2018 +0900
@@ -1,16 +1,15 @@
 ********************************************************************
-* Cmp - Binary file comparison utility
+* loop dummy loader
 *
 * $Id$
 *
 * Edt/Rev  YYYY/MM/DD  Modified by
 * Comment
 * ------------------------------------------------------------------
-*   1      2003/01/20  Boisy G. Pitre
-* Rewritten in assembly for size.
+*   1      2018/07/30  S. Kono
 
-         nam   Cmp
-         ttl   Binary file comparison utility
+         nam   Loop
+         ttl   Dummy loop
 
          ifp1
          use   defsfile
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/os9/level2/cmds/sbc09.asm	Mon Aug 20 00:48:11 2018 +0900
@@ -0,0 +1,246 @@
+********************************************************************
+* sbc09 emulator
+*
+* $Id$
+*
+* Edt/Rev  YYYY/MM/DD  Modified by
+* Comment
+* ------------------------------------------------------------------
+*   1      2018/08/20  S. Kono
+* Emulatoe sbc09 on os9 lv2
+
+         nam   Sbc09
+         ttl   Sbc09 emulator
+
+         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
+readbuff rmb   $100
+         org   $400
+emstart  rmb   $e000-.
+size     equ   .
+
+name     fcs   /Sbc09/
+         fcb   edition
+
+start    
+         clr   <stdin
+         stx   <parmptr         save parameter pointer
+         lda   #READ.           read access mode
+         os9   I$Open           open file
+         bcs   L0049            branch if error
+         sta   <filepath        else save path to file
+         stx   <parmptr         and updated parm pointer
+L001F    lda   <filepath        get path
+         leax  readbuff,u       point X to read buffer
+         ldy   #200             read up to 200 bytes
+         os9   I$ReadLn         read it!
+         bcs   L0035            branch if error
+         bsr   srecords
+         bra   L001F            else exit
+L0035    cmpb  #E$EOF           did we get an EOF error?
+*         bne   L0049            exit if not
+         lda   <filepath        else get path
+         os9   I$Close          and close it
+         bcs   L0049            branch if error
+*         ldx   <parmptr         get param pointer
+*         lda   ,x               get char
+*         cmpa  #C$CR            end of command line?
+*         bne   start            branch if not
+
+copytbl
+         leax  iotbl,pcr
+         leay  iotblend,pcr
+         pshs  x,y
+         ldy   #(iotblend-iotbl)
+l1       ldb   #$7e     * JMP
+         stb   ,u+
+         ldd   ,x++
+         addb  1,s
+         adca  ,s
+         std   ,u++
+         cmpx  2,s
+         bne   l1
+         puls  x,y
+         jmp   $400
+ 
+Exit     clrb
+         os9   F$Exit
+
+iotbl
+         fdb   getchar-iotbl
+         fdb   putchar-iotbl
+         fdb   getline-iotbl
+         fdb   putline-iotbl
+         fdb   putcr-iotbl  
+         fdb   getpoll-iotbl
+         fdb   xopenin-iotbl
+         fdb   xopenout-iotbl
+         fdb   xabortin-iotbl
+         fdb   xclosein-iotbl
+         fdb   xcloseout-iotbl
+         fdb   delay-iotbl
+iotblend
+
+L0049
+err     ldb    #1
+        bra     Exit
+
+srecords
+        leax   readbuff,u
+        clr    <chksum
+sline   lda    ,x+
+        cmpa   #'S'
+        bne    slast
+        lda    ,x+
+        cmpa   #'1'
+        bne    slast
+        bsr    gthex2
+        subb   #3
+        stb    <bcount
+        bsr    gthex2
+        stb    <adr
+        bsr    gthex2
+        stb    <adr+1
+        lda    <bcount
+        ldy    <adr
+sbyte   bsr    gthex2
+        stb    ,y+
+        deca   
+        bgt    sbyte
+slast
+        bsr    gthex2
+        lda    <chksum
+        cmpa   #$ff
+        bne    err1
+err1
+        rts
+
+gthex4  pshs   d
+        bsr    gthex2
+        stb    ,s
+        bsr    gthex2
+        stb    1,s
+        puls   d,pc
+
+gthex2  pshs   b
+        bsr    gthex1
+        aslb
+        aslb
+        aslb
+        aslb
+        stb    ,s
+        bsr    gthex1
+        addb   ,s
+        stb    ,s
+        addb   <chksum
+        stb    <chksum
+        puls   b,pc
+
+gthex1  ldb    ,x+
+        subb   #'0'
+        blo    rgethex1 
+        cmpb   #9
+        bls    rgethex1
+        subb   #7
+rgethex1 
+        rts
+
+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
+*        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
+xopenin
+xopenout
+xabortin
+xclosein
+xcloseout
+        RTS
+
+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
+        org         $400
+        lbra        Exit
+
+
+
+
+         emod
+eom      equ   *
+         end