scc: 6809 runtime support
authorAlan Cox <alan@linux.intel.com>
Wed, 29 Jun 2016 17:20:45 +0000 (18:20 +0100)
committerAlan Cox <alan@linux.intel.com>
Wed, 29 Jun 2016 17:20:45 +0000 (18:20 +0100)
15 files changed:
Applications/SmallC/6809/ccstart.u [deleted file]
Applications/SmallC/6809/crunas.s [new file with mode: 0644]
Applications/SmallC/6809/crunas09.u [deleted file]
Applications/SmallC/6809/exit.u [deleted file]
Applications/SmallC/6809/faults.u [deleted file]
Applications/SmallC/6809/io.u [deleted file]
Applications/SmallC/6809/mrabs.s [moved from Applications/SmallC/6809/mrabs.u with 65% similarity]
Applications/SmallC/6809/prabs.s [moved from Applications/SmallC/6809/prabs.u with 62% similarity]
Applications/SmallC/6809/sdiv.s [new file with mode: 0644]
Applications/SmallC/6809/sdiv.u [deleted file]
Applications/SmallC/6809/shift.s [moved from Applications/SmallC/6809/shift.u with 57% similarity]
Applications/SmallC/6809/smod.s [new file with mode: 0644]
Applications/SmallC/6809/smod.u [deleted file]
Applications/SmallC/6809/sumul.s [new file with mode: 0644]
Applications/SmallC/6809/sumul.u [deleted file]

diff --git a/Applications/SmallC/6809/ccstart.u b/Applications/SmallC/6809/ccstart.u
deleted file mode 100644 (file)
index ffeb176..0000000
+++ /dev/null
@@ -1,25 +0,0 @@
-|       Run-time start off for ccv1 on the Physics 6809
-.globl  _edata
-.globl  _main
-| Initialize stack
-        lds     #/1000
-        ldx     #_edata | clear all of memory
-l2:     clr     (x)+
-        cmpx    #/0fff
-        bne     l2
-| Circumvent EPROM bug
-        ldx     #/ff3b
-        ldb     #6
-l1:     pshs    x
-        decb
-        bne l1
-|       clear everything so that start conds are
-|       always same
-        clra
-        clrb
-        tfr     a,dp
-        tfr     d,x
-        tfr     d,y
-        tfr     d,u
-        jsr     _main
-        jmp     /fc00
diff --git a/Applications/SmallC/6809/crunas.s b/Applications/SmallC/6809/crunas.s
new file mode 100644 (file)
index 0000000..efc028f
--- /dev/null
@@ -0,0 +1,75 @@
+|       csa09 Small C v1 comparison support
+|       All are dyadic except for lneg.
+.globl  __eq
+.globl  __ne
+.globl  __lt
+.globl  __le
+.globl  __gt
+.globl  __ge
+.globl  __ult
+.globl  __ule
+.globl  __ugt
+.globl  __uge
+.globl  __lneg
+.globl  __bool
+
+__eq:   cmpd 2,s
+        lbeq true
+        lbra false
+
+__ne:   cmpd 2,s
+        lbne true
+        lbra false
+
+__lt:   cmpd 2,s
+        bgt true
+        bra false
+
+__le:   cmpd 2,s
+        bge true
+        bra false
+
+__gt:   cmpd 2,s
+        blt true
+        bra false
+
+__ge:   cmpd 2,s
+        ble true
+        bra false
+
+__ult:  cmpd 2,s
+        bhi true
+        bra false
+
+__ule:  cmpd 2,s
+        bhs true
+        bra false
+
+__ugt:  cmpd 2,s
+        blo true
+        bra false
+
+__uge:  cmpd 2,s
+        bls true
+        bra false
+
+__lneg: cmpd #0
+        beq ltrue
+        ldd #0
+        rts
+ltrue:  ldd #1
+        rts
+
+__bool: bsr     __lneg
+        bra     __lneg
+
+true:   ldd #1
+        ldx ,s
+        leas 4,s
+        jmp ,x
+
+false:  clra
+        clrb
+        ldx ,s
+        leas 4,s
+        jmp  ,x
diff --git a/Applications/SmallC/6809/crunas09.u b/Applications/SmallC/6809/crunas09.u
deleted file mode 100644 (file)
index 4b20f81..0000000
+++ /dev/null
@@ -1,85 +0,0 @@
-|       csa09 Small C v1 comparison support
-|       All are dyadic except for lneg.
-.globl  eq
-.globl  ne
-.globl  lt
-.globl  le
-.globl  gt
-.globl  ge
-.globl  ult
-.globl  ule
-.globl  ugt
-.globl  uge
-.globl  lneg
-.globl  bool
-.globl  _eend,_edata,_etext
-.globl  _Xstktop,_brkend
-
-eq:     cmpd 2(s)
-        lbeq true
-        lbra false
-
-ne:     cmpd 2(s)
-        lbne true
-        lbra false
-
-lt:     cmpd 2(s)
-        bgt true
-        bra false
-
-le:     cmpd 2(s)
-        bge true
-        bra false
-
-gt:     cmpd 2(s)
-        blt true
-        bra false
-
-ge:     cmpd 2(s)
-        ble true
-        bra false
-
-ult:    cmpd 2(s)
-        bhi true
-        bra false
-
-ule:    cmpd 2(s)
-        bhs true
-        bra false
-
-ugt:    cmpd 2(s)
-        blo true
-        bra false
-
-uge:    cmpd 2(s)
-        bls true
-        bra false
-
-lneg:   cmpd #0
-        beq ltrue
-        ldd #0
-        rts
-ltrue:  ldd #1
-        rts
-
-bool:   bsr     lneg
-        bra     lneg
-
-true:   ldd #1
-        ldx (s)
-        leas 4(s)
-        jmp (x)
-
-false:  clra
-        clrb
-        ldx (s)
-        leas 4(s)
-        jmp  (x)
-_Xstktop:       tfr     s,d
-        rts
-_etext  =       .
-        .bss
-_eend   =       .
-        .data
-_brkend:        .wval   _eend
-_edata  =       .
diff --git a/Applications/SmallC/6809/exit.u b/Applications/SmallC/6809/exit.u
deleted file mode 100644 (file)
index 423fd67..0000000
+++ /dev/null
@@ -1,3 +0,0 @@
-|       Small C v1 exit routine (physics computer)
-.globl  _exit
-_exit:  jmp     /fc00
diff --git a/Applications/SmallC/6809/faults.u b/Applications/SmallC/6809/faults.u
deleted file mode 100644 (file)
index 6e7db80..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-|       MC6809 Concurrent Euclid fault codes
-ASSERTFAIL = 0
-RANGECHECK = 1
-CASERANGE = 2
-| fault codes for runtime routines
-OUTOFSPACE = 20
-.globl ASSERTFAIL
-.globl RANGECHECK
-.globl CASERANGE
-.globl  OUTOFSPACE
diff --git a/Applications/SmallC/6809/io.u b/Applications/SmallC/6809/io.u
deleted file mode 100644 (file)
index 1f3a63f..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-|       Small C v1 io (putchar) for physics machine
-.globl  _putchar
-_putchar=.
-        lda     /9000
-        bita    #2
-        beq     _putchar
-        lda     3(s)
-        sta     /9001
-        cmpa    #10.
-        bne     out
-        ldd     #13.
-        pshs    d
-        lbsr    _putchar
-        leas    2(s)
-out:    rts
-
-.globl  _getchar
-_getchar=.
-        lda     /9000
-        bita    #1
-        beq     _getchar
-        ldb     /9001
-        clra
-        andb    #/7F
-        cmpb    #04
-        bne     noteot
-        ldd     #-1
-noteot: rts
similarity index 65%
rename from Applications/SmallC/6809/mrabs.u
rename to Applications/SmallC/6809/mrabs.s
index 97f0662..10943a0 100644 (file)
@@ -5,22 +5,22 @@
 |       if result (from mod) should be negative.
 |
 |
-.globl mrabs
-        left=8.
-        right=4.
-        sign=3.
-mrabs:  clr     sign(s)
-        ldd     left(s)
+.globl __mrabs
+;       left=8.
+;       right=4.
+;       sign=3.
+__mrabs:clr     3,s
+        ldd     8,s
         bge     tryr
         nega
         negb
         sbca    #0
-        std     left(s)
-        inc     sign(s)
-tryr:   ldd     right(s)
+        std     8,s
+        inc     3,s
+tryr:   ldd     4,s
         bge     done
         nega
         negb
         sbca    #0
-        std     right(s)
+        std     4,s
 done:   rts
similarity index 62%
rename from Applications/SmallC/6809/prabs.u
rename to Applications/SmallC/6809/prabs.s
index 40b6dc8..8df42ac 100644 (file)
@@ -5,23 +5,23 @@
 |       if result (from divide) should be negative.
 |
 |
-.globl prabs
-        left=8.
-        right=4.
-        sign=3.
-prabs:  clr     sign(s)
-        ldd     left(s)
+.globl __prabs
+|       left=8.
+|       right=4.
+|       sign=3.
+__prabs:clr     3,s
+        ldd     8,s
         bge     tryr
         nega
         negb
         sbca    #0
-        std     left(s)
-        inc     sign(s)
-tryr:   ldd     right(s)
+        std     8,s
+        inc     3,s
+tryr:   ldd     4,s
         bge     done
         nega
         negb
         sbca    #0
-        dec     sign(s)
-        std     right(s)
+        dec     3,s
+        std     4,s
 done:   rts
diff --git a/Applications/SmallC/6809/sdiv.s b/Applications/SmallC/6809/sdiv.s
new file mode 100644 (file)
index 0000000..335892b
--- /dev/null
@@ -0,0 +1,64 @@
+|       signed divide
+|       calling: (left / right)
+|               push left
+|               ldd right
+|               jsr sdiv
+|       result in d, arg popped.
+|
+|       left=6
+|       right=2
+|       sign=1
+|       count=0
+|       return=4
+|       CARRY=1
+.globl __sdiv,__div
+.globl __prabs
+__sdiv: leas    -4,s
+        std     2,s
+        bne     nozero
+       ldd     #8      ; SIGFPE
+       pshs    d,x     ; need a dummy
+       ldx     #0
+       ldd     #39     ; kill
+       swi             ; kill(0,SIGFPE)
+       puls    d,x
+       rts
+;
+;      FIXME - self signal
+;
+
+nozero: jsr     __prabs
+__div:  clr     0,s        ; prescale divisor
+        inc     0,s
+mscl:   inc     0,s
+        aslb
+        rola
+        bpl     mscl
+        std     2,s
+        ldd     6,s
+        clr     6,s
+        clr     6+1,s
+div1:   subd    2,s        ; check subtract
+        bcc     div2
+        addd    2,s
+        andcc   #~1
+        bra     div3
+div2:   orcc    #1
+div3:   rol     6+1,s       ; roll in carry
+        rol     6,s
+        lsr     2,s
+        ror     2+1,s
+        dec     0,s
+        bne     div1
+        ldd     6,s
+        tst     1,s         ; sign fiddle
+        beq     nochg
+        nega
+        negb
+        sbca    #0
+nochg:  std     2,s        ; move return addr
+        ldd     4,s
+        std     6,s
+        ldd     2,s
+        leas    6,s
+        rts
diff --git a/Applications/SmallC/6809/sdiv.u b/Applications/SmallC/6809/sdiv.u
deleted file mode 100644 (file)
index 3b17770..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-|       signed divide
-|       calling: (left / right)
-|               push left
-|               ldd right
-|               jsr sdiv
-|       result in d, arg popped.
-|
-        left=6
-        right=2
-        sign=1
-        count=0
-        return=4
-        CARRY=1
-.globl sdiv,div,ASSERTFAIL
-.globl prabs
-sdiv:   leas    -4(s)
-        std     right(s)
-        bne     nozero
-        swi2
-        .byte   ASSERTFAIL
-nozero: jsr     prabs
-div:    clr     count(s)        | prescale divisor
-        inc     count(s)
-mscl:   inc     count(s)
-        aslb
-        rola
-        bpl     mscl
-        std     right(s)
-        ldd     left(s)
-        clr     left(s)
-        clr     left+1 <tel:+1>(s)
-div1:   subd    right(s)        | check subtract
-        bcc     div2
-        addd    right(s)
-        andcc   #~CARRY
-        bra     div3
-div2:   orcc    #CARRY
-div3:   rol     left+1 <tel:+1>(s)       | roll in carry
-        rol     left(s)
-        lsr     right(s)
-        ror     right+1 <tel:+1>(s)
-        dec     count(s)
-        bne     div1
-        ldd     left(s)
-        tst     sign(s)         | sign fiddle
-        beq     nochg
-        nega
-        negb
-        sbca    #0
-nochg:  std     right(s)        | move return addr
-        ldd     return(s)
-        std     left(s)
-        ldd     right(s)
-        leas    6(s)
-        rts
similarity index 57%
rename from Applications/SmallC/6809/shift.u
rename to Applications/SmallC/6809/shift.s
index 0ced5ec..035fd8a 100644 (file)
@@ -1,32 +1,32 @@
 |       Shift support for Small C v1 sa09
-.globl  asr
-asr:    tstb
+.globl __asr
+__asr:  tstb
         bge     okr
         negb
-        bra     asl
+        bra     __asl
 okr:    incb
         pshs    b
-        ldd     3(s)
-asrl:   dec     (s)
+        ldd     3,s
+asrl:   dec     ,s
         beq     return
         asra
         rorb
         bra     asrl
 
-.globl  asl
-asl:    tstb
+.globl __asl
+__asl:  tstb
         bge     okl
         negb
-        bra     asr
+        bra     __asr
 okl:    incb
         pshs    b
-        ldd     3(s)
-asll:   dec     (s)
+        ldd     3,s
+asll:   dec     ,s
         beq     return
         aslb
         rola
         bra     asll
 
-return: ldx     1(s)
-        leas    5(s)
-        jmp     (x)
+return: ldx     1,s
+        leas    5,s
+        jmp     ,x
diff --git a/Applications/SmallC/6809/smod.s b/Applications/SmallC/6809/smod.s
new file mode 100644 (file)
index 0000000..7a0f667
--- /dev/null
@@ -0,0 +1,58 @@
+|       signed mod
+|       calling: (left / right)
+|               push left
+|               ldd right
+|               jsr smod
+|       result in d, arg popped.
+|
+|       left=6
+|       right=2
+|       sign=1
+|       count=0
+|       return=4
+|       CARRY=1
+.globl __smod,__mod,ASSERTFAIL
+.globl __mrabs
+__smod: leas    -4,s
+        std     2,s
+        bne     nozero
+       ldd     #8      ; SIGFPE
+       pshs    d,x     ; need a dummy
+       ldd     #39     ; sigkill
+       swi
+       puls    d,x
+       rts
+nozero: jsr     __mrabs
+__mod:  clr     0,s        ; prescale divisor
+        inc     0,s
+mscl:   inc     0,s
+        aslb
+        rola
+        bpl     mscl
+        std     2,s
+        ldd     6,s
+        clr     6,s
+        clr     6+1,s
+mod1:   subd    2,s        ; check subtract
+        bcc     mod2
+        addd    2,s
+        andcc   #~1
+        bra     mod3
+mod2:   orcc    #1
+mod3:   rol     6+1,s       ; roll in carry
+        rol     6,s
+        lsr     2,s
+        ror     2+1,s
+        dec     0,s
+        bne     mod1
+        tst     1,s         ; sign fiddle
+        beq     nochg
+        nega
+        negb
+        sbca    #0
+nochg:  std     2,s        ; move return addr
+        ldd     4,s
+        std     6,s
+        ldd     2,s
+        leas    6,s
+        rts
diff --git a/Applications/SmallC/6809/smod.u b/Applications/SmallC/6809/smod.u
deleted file mode 100644 (file)
index 737cb90..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-|       signed mod
-|       calling: (left / right)
-|               push left
-|               ldd right
-|               jsr smod
-|       result in d, arg popped.
-|
-        left=6
-        right=2
-        sign=1
-        count=0
-        return=4
-        CARRY=1
-.globl smod,mod,ASSERTFAIL
-.globl mrabs
-smod:   leas    -4(s)
-        std     right(s)
-        bne     nozero
-        swi2
-        .byte   ASSERTFAIL
-nozero: jsr     mrabs
-mod:    clr     count(s)        | prescale divisor
-        inc     count(s)
-mscl:   inc     count(s)
-        aslb
-        rola
-        bpl     mscl
-        std     right(s)
-        ldd     left(s)
-        clr     left(s)
-        clr     left+1 <tel:+1>(s)
-mod1:   subd    right(s)        | check subtract
-        bcc     mod2
-        addd    right(s)
-        andcc   #~CARRY
-        bra     mod3
-mod2:   orcc    #CARRY
-mod3:   rol     left+1 <tel:+1>(s)       | roll in carry
-        rol     left(s)
-        lsr     right(s)
-        ror     right+1 <tel:+1>(s)
-        dec     count(s)
-        bne     mod1
-        tst     sign(s)         | sign fiddle
-        beq     nochg
-        nega
-        negb
-        sbca    #0
-nochg:  std     right(s)        | move return addr
-        ldd     return(s)
-        std     left(s)
-        ldd     right(s)
-        leas    6(s)
-        rts
diff --git a/Applications/SmallC/6809/sumul.s b/Applications/SmallC/6809/sumul.s
new file mode 100644 (file)
index 0000000..27edd58
--- /dev/null
@@ -0,0 +1,33 @@
+|       signed/unsigned multiply
+|       calling (left * right)
+|       push left
+|       ldd right
+|       jsr [u|s]mul (same entry point)
+|       result in d, stack is popped
+.globl __smul,__umul
+__smul:
+__umul:
+       pshs    d
+        lda     2+2,s
+        mul             ; left msb * right lsb
+        pshs    b       ; save high order
+        ldb     -1+3,s ; right lsb
+        lda     3+3,s  ; left lsb
+        mul
+        pshs    d
+        lda     3+5,s  ; left lsb
+        ldb     -2+5,s ; right msb
+        beq     small   ; is zero?
+        mul             ; no, gotta do it too
+        tfr     b,a
+        clrb
+        addd    ,s++   ; partial prod
+        bra     big
+small:  puls    d       ; aha! don't need third mul
+big:    adda    ,s+
+        pshs    d
+        ldd     4,s    ; rearrange return address
+        std     6,s
+        puls    d
+        leas    4,s
+        rts
diff --git a/Applications/SmallC/6809/sumul.u b/Applications/SmallC/6809/sumul.u
deleted file mode 100644 (file)
index 806c9ca..0000000
+++ /dev/null
@@ -1,32 +0,0 @@
-|       signed/unsigned multiply
-|       calling (left * right)
-|       push left
-|       ldd right
-|       jsr [u|s]mul (same entry point)
-|       result in d, stack is popped
-.globl smul,umul
-smul=.
-umul:   pshs    d
-        lda     2+2 <tel:+2>(s)
-        mul             | left msb * right lsb
-        pshs    b       | save high order
-        ldb     -1+3 <tel:+3>(s) | right lsb
-        lda     3+3 <tel:+3>(s)  | left lsb
-        mul
-        pshs    d
-        lda     3+5 <tel:+5>(s)  | left lsb
-        ldb     -2+5 <tel:+5>(s) | right msb
-        beq     small   | is zero?
-        mul             | no, gotta do it too
-        tfr     b,a
-        clrb
-        addd    (s)++   | partial prod
-        bra     big
-small:  puls    d       | aha! don't need third mul
-big:    adda    (s)+
-        pshs    d
-        ldd     4(s)    | rearrange return address
-        std     6(s)
-        puls    d
-        leas    4(s)
-        rts