changeset 164:c90b9be8c307

TL1 module write
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 10 Apr 2019 07:42:15 +0900
parents e09e66204c71
children 5aefcd52aba8
files TL1/TL1os9.asm
diffstat 1 files changed, 123 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/TL1/TL1os9.asm	Tue Apr 09 23:11:08 2019 +0900
+++ b/TL1/TL1os9.asm	Wed Apr 10 07:42:15 2019 +0900
@@ -53,6 +53,7 @@
 RSW    RMB 1     0 word lookup, 0xff word register mode in tlook
 GEND   RMB 2     end of global name
 SSW    RMB 1
+runmod RMB 1
 modofs RMB 2     module library offset
 
 filepath rmb   2
@@ -69,7 +70,7 @@
 ioentry  rmb   $80
 readbuff rmb   bufsiz+1
 
-OBJSTART RMB 12
+OBJSTART RMB 11
 
 
 * OBJECT PG AREA
@@ -99,9 +100,20 @@
 OBJMP  JMP OBJECT,u
 
 
-start    ldy   #-2              17 xx xx
+start    LEAY OBJECT,u
+         STY PC
+         lda   ,x
+         cmpa  '-'
+         bne   run
+         leax  1,x
+         lda   ,x+
+         cmp   'c'
+         bne   run
+         lbsr  modsetup
+         bra   fread 
+run      ldy   #-2              17 xx xx
          sty   modofs
-         clr   <stdin
+fread    clr   <stdin
          stx   <parmptr         save parameter pointer
          stu   <work            save parameter pointer
          lda   #READ.           read access mode
@@ -176,8 +188,6 @@
        decb
        bne tbl1
        sty TEND
-       LEAX OBJECT,u
-       STX PC
 ** 
        LBSR CRLF
        BSR REG0
@@ -1408,6 +1418,107 @@
 EL     LDX PC
        LBRA C
 
+modsetup
+       pshs  x,y,u
+       lda   #$ff
+       sta   <runmod
+       puls  x,y,pc
+       ldy   <pc
+       ldd   #$87CD
+       std   ,y++
+       ldd   #$0c0a
+       std   ,y++
+       ldd   #$000d
+       ldy   <pc
+       leay  0xd,y
+       ldx   ,s
+       bsr   mkmodnam
+       sty   <runtop
+       leau  crt0top,pc
+       ldx   #LIBEND-crt0top
+libcpy ldd   ,u++
+       std   ,y++
+       leax  -2,x
+       bhi   libcpy
+       sty   <PC
+       ldd   <runtop
+       subd   #LIBEND+2
+       std    modofs
+       puls   x,y,u,pc
+
+mkmodnam pshs x,y.u
+m0     lda    ,x+
+       bne    m2
+       cmpa   '/'
+       bne    m0
+       tfr    x,u
+       bra    m0
+m1     lda    ,u+
+       beq    m3
+       cmpa   '.'
+       beq    m3
+       sta    ,y+
+       bra    m1
+m3     lda    -1,y
+       ora    #$80
+       sta    -1,y
+       sty    2,s
+       puls  x,y,u,pc
+
+modend leax   OBJECT,u         * header setup
+       ldy    <PC
+       sty    2,x
+       * header parity
+       clra
+       ldb    #7
+m4     adda   ,x+
+       decb
+       bne    m4
+       sta    ,x+              header parity
+       leay    OBJECT,u
+       leay   crt0-crt0top,y
+       sty    ,x++             start address
+       ldy    GEND
+       clra
+       clrb
+m5     tst    ,y+
+       bpl    m5
+       beq    m6
+       leay   1,y
+       addd   #1
+       bra    m5
+m6     std    $b,u             global size
+       * mod CRC
+       pshs   d,u
+       leax   OBJECT,u
+       ldu    <PC
+       clr    ,u
+       clr    1,u
+       clr    2,u
+       os9    F$CRC
+
+       * write to file
+       ldu    2,s
+       leax   OBJECT,u
+       ldd    4,x
+       leax   d,x
+       lda    2                write
+       os9    I$Open
+       bcs    ERROR
+       sta    ,s
+       ldu    2,s
+       leax   OBJECT,u
+       ldd    <PC
+       addd   #3
+       pshs   x
+       subd   ,s++
+       lda    ,s
+       os9    I$Write
+       bcs    ERROR
+       clra
+       os9    F$Exit          all end
+
+
 **********************
 * ADVANCE WORD
 **
@@ -1515,6 +1626,8 @@
 * & I/0 CONTROL
 **
 
+crt0top
+
 **
 * PUSH LB & SET NEW LB
 **
@@ -1841,6 +1954,11 @@
         TFR         D,X
         OS9         F$Sleep
         PULS        D,X,PC
+
+crt0    stx         <args
+        leax        OBJSTART,u
+        *   compiled code follows
+
 LIBEND