--- /dev/null
+libem_s.a
+ara.s
+cvf.s
+cii.s
+cmi.s
+cmp.s
+cmu.s
+csa.s
+csb.s
+cuu.s
+exg.s
+inn.s
+los.s
+rck.s
+ret.s
+set.s
+sts.s
+nop.s
+mon.s
+dvi.s
+dvu.s
+mli.s
+mlu.s
+shp.s
+sig.s
+cms.s
+gto.s
+fat.s
+trp.s
+dia.s
+printf.s
+lxl.s
+lxa.s
+lpb.s
--- /dev/null
+.define .sar
+.define .lar
+.define .aar
+
+ !register usage:
+ ! a0 : descriptor address
+ ! d0 : index
+ ! a1 : base address
+ .text
+.aar:
+ move.l (sp)+,d2 ! return address
+ move.l (sp)+,a0
+ move.w (sp)+,d0
+ move.l (sp)+,a1
+ sub (a0),d0 ! index - lower bound : relative index
+ !chk 2(a0),d0
+ !blt 9f
+ !cmp 2(a0),d0
+ !bgt 9f
+ mulu 4(a0),d0 ! total # bytes
+ add d0,a1 ! address of element
+ move.l a1,-(sp)
+ move.l d2,-(sp)
+ rts
+
+
+.lar:
+ move.l (sp)+,d2 ! return address
+ move.l (sp)+,a0
+ move.w (sp)+,d0
+ move.l (sp)+,a1
+ sub (a0),d0
+ !chk 2(a0),d0
+ !blt 9f
+ !cmp 2(a0),d0
+ !bgt 9f
+ move 4(a0),d1
+ mulu d1,d0
+ add d0,a1
+ add d1,a1
+ asr #1,d1
+ bne 3f
+ clr d1
+ move.b -(a1),d1
+ move d1,-(sp)
+ bra 4f
+3:
+ move -(a1),-(sp)
+ sub #1,d1
+ bgt 3b
+4:
+ move.l d2,-(sp)
+ rts
+
+
+!9:
+ !move.w #EARRAY,-(sp)
+ !jmp .fat
+.sar:
+ move.l (sp)+,d2
+ move.l (sp)+,a0
+ move.w (sp)+,d0
+ move.l (sp)+,a1
+ sub (a0),d0
+ !chk 2(a0),d0
+ !blt 9b
+ !cmp 2(a0),d0
+ !bgt 9b
+ move 4(a0),d1
+ mulu d1,d0
+ add d0,a1
+ asr #1,d1
+ bne 3f
+ move (sp)+,d1
+ move.b d1,(a1)
+ bra 4f
+3:
+ move (sp)+,(a1)+
+ sub #1,d1
+ bgt 3b
+4:
+ move.l d2,-(sp)
+ rts
--- /dev/null
+.define .cii
+
+ .text
+.cii:
+ move.l (sp)+,a0 ! return address
+ move (sp)+,d0 ! destination size
+ sub (sp)+,d0 ! destination - source size
+ bgt 1f
+ sub d0,sp ! pop extra bytes
+ bra 3f
+1:
+ move (sp),d1
+ ext.l d1
+ swap d1
+ asr #1,d0
+2:
+ move.w d1,-(sp)
+ sub #1,d0
+ bgt 2b
+3:
+ jmp (a0)
--- /dev/null
+.define .cmi, .cmi_
+
+ ! NUM == 4
+ ! result in d1
+ .text
+.cmi:
+.cmi_:
+ move.l (sp)+,a0
+ move.l #1,d1
+ move.l (sp)+,d0
+ cmp.l (sp)+,d0
+ bne 1f
+ clr d1
+ 1:
+ ble 2f
+ neg d1
+ 2:
+ jmp (a0)
--- /dev/null
+.define .cmp
+
+ .text
+.cmp:
+ move.l (sp)+,a0 ! return address
+ move.l #1,d1
+ move.l (sp)+,d0
+ cmp.l (sp)+,d0
+ bne 1f
+ clr d1
+ 1:
+ bcs 2f
+ neg d1
+ 2:
+ jmp (a0)
--- /dev/null
+.define .cms
+
+ ! d0 contains set size
+
+ .text
+.cms:
+ move.l (sp)+,d2 ! return address
+ move.l sp,a0
+ move.l sp,a1
+ add d0,a1
+ move.w d0,d1
+ asr #1,d0
+1:
+ cmp (a0)+,(a1)+
+ bne 2f
+ sub #1,d0
+ bgt 1b
+2:
+ asl #1,d1
+ add d1,sp
+ move.w d0,-(sp)
+ move.l d2,-(sp)
+ rts
--- /dev/null
+.define .cmu
+
+ ! d0 : # bytes of 1 block
+ .text
+.cmu:
+ move.l (sp)+,d2 ! reta
+ move.l sp,a0 ! top block
+ move.l sp,a1
+ move.l d2,-(sp)
+ add d0,a1 ! lower block
+ move d0,d2
+ asr #1,d0
+ move.l #1,d1 ! greater
+1:
+ cmp (a0)+,(a1)+
+ bne 2f
+ sub #1,d0
+ bgt 1b
+ clr d1 ! equal
+2:
+ bcc 3f
+ neg d1 ! less
+3:
+ move.l (sp)+,a0
+ asl #1,d2
+ add d2,sp ! new sp
+ jmp (a0)
--- /dev/null
+if m68k2 -c $1 1>&2
+then echo `basename $1 $2`.s
+else exit 1
+fi
--- /dev/null
+.define .csa
+
+ .text
+.csa:
+ move.l (sp)+,a0 ! case descriptor
+ move (sp)+,d0 ! index
+ move.l (a0)+,a1 ! default address
+ sub (a0)+,d0 ! index - lower bound
+ blt 1f
+ cmp (a0)+,d0 ! rel. index <-> upper - lower bound
+ bgt 1f
+ asl #2,d0
+ add d0,a0
+ move.l (a0),d1 ! test jump address
+ move.l d1,d0
+ beq 1f
+ move.l d1,a1
+ bra 3f
+1:
+ move.l a1,d0 ! test default jump address
+ beq 2f
+3:
+ jmp (a1)
+2:
+ move.w #ECASE,-(sp)
+ jmp .fat
--- /dev/null
+.define .csb
+
+ .text
+.csb:
+ move.l (sp)+,a0 ! case descriptor
+ move (sp)+,d0 ! index
+ move.l (a0)+,a1 ! default jump address
+ move.w (a0)+,d1 ! # entries
+ beq 2f
+1:
+ cmp (a0)+,d0
+ beq 3f
+ tst.l (a0)+ ! skip jump address
+ sub #1,d1
+ bgt 1b
+2:
+ move.l a1,d1 ! default jump address
+ bne 4f
+ move.w #ECASE,-(sp)
+ jmp .fat
+3:
+ move.l (a0)+,a1 ! get jump address
+4:
+ jmp (a1)
--- /dev/null
+.define .ciu
+.define .cui
+.define .cuu
+
+ .text
+.ciu:
+.cui:
+.cuu:
+ move.l (sp)+,a0 ! return address
+ move (sp)+,d0 ! destination size
+ sub (sp)+,d0
+ bgt 1f
+ sub d0,sp
+ jmp (a0)
+1:
+ asr #1,d0
+2:
+ clr -(sp)
+ sub #1,d0
+ bgt 2b
+ jmp (a0)
--- /dev/null
+.define .cfi,.cif,.cfu,.cuf,.cff
+
+ .text
+
+ ! this is a dummy float conversion routine
+.cfi:
+.cif:
+.cfu:
+.cuf:
+.cff:
+ move.l (sp)+,a0 ! return address
+ move (sp)+,d0 ! destination size
+ sub (sp)+,d0 ! diff. in sizes
+ sub d0,sp
+ jmp (a0)
--- /dev/null
+.define .diagnos
+
+space = 040
+del = 0177
+
+ .text
+.diagnos:
+ move.w hol0,-(sp)
+ move.l hol0+FILN_AD,d2
+ beq 1f
+ move.l d2,a0
+ move.l #40,d0
+3:
+ move.b (a0)+,d1
+ beq 2f
+ cmp.b #del,d1
+ bge 1f
+ cmp.b #space,d1
+ blt 1f
+ sub #1,d0
+ bgt 3b
+ clr.b (a1)
+2:
+ move.l d2,-(sp)
+ pea fmt
+ jsr _printf
+ add #10,sp
+ jmp _printf
+
+1:
+ move.l #unknwn,d2
+ bra 2b
+
+ .data
+fmt: .asciz "%s, line %d: "
+unknwn: .asciz "unknown file"
+.align 2
--- /dev/null
+.define .dvi
+
+ ! signed long divide
+ .text
+.dvi:
+ move.l (sp)+,a0 ! return address
+ move.l (sp)+,d0
+ move.l (sp)+,d1
+ move.l d3,-(sp) ! save d3 and d4
+ move.l d4,-(sp)
+ clr.l d4
+ tst.l d0 ! divisor
+ bpl 1f
+ neg.l d0
+ not d4
+1:
+ tst.l d1 ! dividend
+ bpl 2f
+ neg.l d1
+ not d4
+ swap d4
+ not d4
+ swap d4
+2:
+ move.l d1,-(sp)
+ move.l d0,-(sp)
+ jsr .dvu
+ tst d4
+ beq 5f
+ neg.l d1 ! quotient
+5:
+ tst.l d4
+ bpl 6f
+ neg.l d2 ! remainder
+6:
+ move.l (sp)+,d4 ! restore d4 and d3
+ move.l (sp)+,d3
+ jmp (a0)
--- /dev/null
+.define .dvu
+
+ ! unsigned long divide
+ ! register usage:
+ ! : d0 divisor
+ ! d1 dividend
+ ! exit : d1 quotient
+ ! d2 remainder
+ .text
+.dvu:
+ move.l (sp)+,a1 ! return address
+ move.l (sp)+,d0
+ move.l (sp)+,d1
+ move.l d3,-(sp) ! save d3
+ tst.l d0
+ bne 0f
+ move.l (sp)+,d3
+ move.w #EIDIVZ,-(sp)
+ jsr .trp
+0:
+ clr.l d2
+ move.l #32,d3
+3:
+ lsl.l #1,d1
+ roxl.l #1,d2
+ cmp.l d0,d2
+ blt 4f
+ sub.l d0,d2
+ add #1,d1
+4:
+ sub #1,d3
+ bgt 3b
+ move.l (sp)+,d3
+ jmp (a1)
--- /dev/null
+.define .exg
+
+ ! d0 : exchange size in bytes
+ .text
+.exg:
+ move.l (sp)+,d2 ! return address
+ move.l sp,a1
+ sub.w d0,sp
+ move.l sp,a0
+ move.w d0,d1
+1:
+ move.w (a1)+,(a0)+
+ sub #1,d0
+ bgt 1b
+ move.l sp,a1
+ asr #1,d1
+1:
+ move.w (a1)+,(a0)+
+ sub #1,d1
+ bgt 1b
+ move.l a1,sp
+ move.l d2,-(sp)
+ rts
--- /dev/null
+.define .fat
+
+ .text
+.fat:
+ jsr .trp
+ jmp EXIT
--- /dev/null
+.define .gto
+.extern .gto
+
+.gto:
+ ! nonlocal goto
+ ! the argument on the stack is a pointer to a GTO-descriptor containing:
+ ! - the new local base
+ ! - the new stackpointer
+ ! - the new program counter
+ !
+ ! The main task of the GTO instruction is to restore the registers
+ ! used for local variables. It uses a word stored in each stackframe,
+ ! indicating how many data -and address registers the procedure of
+ ! that stackframe has.
+
+ move.l (sp)+,a0
+ add.l #8,a0 ! a0 now points to new local base entry
+ ! of the descriptor
+ cmp.l (a0),a6 ! GTO within same procedure?
+ beq noregs
+ move.l d0,savd0 ! gto may not destroy the return area
+ move.l d1,savd1
+1:
+ tst.l (a6)
+ beq err
+ unlk a6
+ move.w (sp)+,d0 ! word indicating which regs. were saved
+ jsr restr
+ cmp.l (a0),a6
+ bne 1b
+ move.l savd0,d0
+ move.l savd1,d1
+noregs:
+ move.l -4(a0),sp
+ move.l -8(a0),a0 ! new program counter
+ jmp (a0)
+err:
+ move.w #EBADGTO,-(sp)
+ jmp .fat
+
+restr:
+ ! restore the registers. Note that scratch register a0 may
+ ! not be changed here. d0 contains (8*#addr.regs + #data regs.)
+ ! note that registers are assigned in the order d7,d6 .. and
+ ! a5,a4...
+
+ move.l (sp)+,d2 ! return address; can't use a0 here
+ move.w d0,d1
+ and.l #7,d0 ! #data registers
+ asl.l #1,d0 ! * 2
+ lea etabd,a1
+ sub.l d0,a1
+ jmp (a1)
+ move.l (sp)+,d3
+ move.l (sp)+,d4
+ move.l (sp)+,d5
+ move.l (sp)+,d6
+ move.l (sp)+,d7
+etabd:
+ and.l #070,d1
+ asr.l #2,d1 ! # address registers
+ lea etaba,a1
+ sub.l d1,a1
+ jmp (a1)
+ move.l (sp)+,a2
+ move.l (sp)+,a3
+ move.l (sp)+,a4
+ move.l (sp)+,a5
+etaba:
+ move.l d2,a1
+ jmp (a1) ! return
+.data
+savd0: .long 0
+savd1: .long 0
+.text
--- /dev/null
+.define .inn
+
+! d0 : set size in bytes
+! d1 : bitnumber
+
+ .text
+.inn:
+ move.l (sp)+,d2 ! return address
+ move.w (sp)+,d1
+ move.l sp,a1
+ add d0,a1
+ move.l sp,a0
+ move.l d2,-(sp)
+ move d1,d2
+ asr #3,d2
+ bchg #0,d2
+ cmp d0,d2
+ bcc 1f
+ add d2,a0
+ btst d1,(a0)
+ beq 1f
+ move.l #1,d0
+ bra 2f
+1:
+ clr d0
+2:
+ move.l (sp)+,a0
+ move.l a1,sp
+ jmp (a0)
--- /dev/null
+.define .los
+
+ ! d0 : # bytes
+ ! a0 : source address
+ .text
+.los:
+ move.l (sp)+,a1
+ move.w (sp)+,d0
+ move.l (sp)+,a0
+ cmp #1,d0
+ bne 1f
+ clr d0
+ move.b (a0),d0
+ move.w d0,-(sp)
+ bra 3f
+1:
+ add d0,a0
+ asr #1,d0
+2:
+ move -(a0),-(sp)
+ sub #1,d0
+ bgt 2b
+3:
+ jmp (a1)
--- /dev/null
+.define .lpb
+.extern .lpb
+.lpb:
+ ! convert local to argument base
+ ! should not destroy register d2 (used by lxa/lxl)
+
+ move.l (sp)+,a1 ! return address
+ move.l (sp)+,a0 ! local base
+ move.w 4(a0),d0 ! register save word
+ move.w d0,d1
+ and.l #7,d0 ! #data registers
+ and.l #070,d1
+ asr.l #3,d1 ! #address registers
+ add.w d1,d0
+ asl.l #2,d0 ! 4 * #registers
+ add.w #10,d0 ! reg. save word, lb, pc
+ add.l d0,a0
+ jmp (a1)
--- /dev/null
+.define .lxa
+.extern .lxa
+.lxa:
+ ! #levels (>= 0) on stack
+
+ move.l (sp)+,a0 ! return address
+ move.w (sp)+,d2
+ move.l a0,-(sp)
+ move.l a6,a0
+1:
+ move.l a0,-(sp)
+ jsr .lpb
+ sub #1,d2
+ blt 2f
+ move.l (a0),a0
+ bra 1b
+2:
+ rts
--- /dev/null
+.define .lxl
+.extern .lxl
+.lxl:
+ ! #levels on stack (> 0)
+
+ move.l (sp)+,a0 ! return address
+ move.w (sp)+,d2 ! d2 is not destroyed by .lpb
+ move.l a0,-(sp)
+ sub.w #1,d2
+ move.l a6,a0
+1:
+ move.l a0,-(sp)
+ jsr .lpb
+ move.l (a0),a0
+ dbf d2,1b
+ rts ! result in a0
--- /dev/null
+.define .mli
+
+
+ .text
+.mli:
+ move.l (sp)+,a0
+ move.l (sp)+,d1
+ move.l (sp)+,d0
+ move.l d5,-(sp)
+ clr d5
+ tst.l d0
+ bpl 1f
+ neg.l d0
+ not d5
+1:
+ tst.l d1
+ bpl 2f
+ neg.l d1
+ not d5
+2:
+ move.l d0,-(sp)
+ move.l d1,-(sp)
+ jsr .mlu
+ tst d5
+ beq 3f
+ neg.l d1
+ negx.l d0
+3:
+ move.l (sp)+,d5
+ jmp (a0)
--- /dev/null
+.define .mlu
+
+ ! entry : d0 multiplicand
+ ! d1 multiplier
+ ! exit : d0 high order result
+ ! d1 low order result
+
+ .text
+.mlu:
+ move.l (sp)+,a1
+ move.l (sp)+,d1
+ move.l (sp)+,d0
+ movem.l d3/d4/d6,-(sp)
+ move.l d1,d3
+ move.l d1,d2
+ swap d2
+ move.l d2,d4
+ mulu d0,d1
+ mulu d0,d2
+ swap d0
+ mulu d0,d3
+ mulu d4,d0
+ clr.l d6
+ swap d1
+ add d2,d1
+ addx.l d6,d0
+ add d3,d1
+ addx.l d6,d0
+ swap d1
+ clr d2
+ clr d3
+ swap d2
+ swap d3
+ add.l d2,d0
+ add.l d3,d0
+ movem.l (sp)+,d3/d4/d6
+ jmp (a1)
--- /dev/null
+.define .mon
+ .text
+.mon:
+ move.l (sp)+,a0
+ pea fmt
+ jsr .diagnos
+ add #6,sp
+ jmp EXIT
+
+ .data
+fmt: .asciz "system call %d not implemented"
+.align 2
--- /dev/null
+.define .nop
+
+ .text
+.nop:
+ move.w hol0,-(sp)
+ pea fmt
+ jsr .diagnos
+ add #6,sp
+ rts
+
+ .data
+fmt: .asciz "test %d\n"
+.align 2
--- /dev/null
+.define _printn
+.define _printf
+.text
+_putchar:
+ move.w #1,-(sp)
+ pea 7(sp)
+ move.w #1,-(sp)
+ jsr _write
+ add.l #8,sp
+ rts
+_printf:
+ link a6,#-12
+.data
+_12:
+ .short 28786
+ .short 26990
+ .short 29798
+ .short 11875
+ .short 0
+.text
+ pea 8+4(a6)
+ move.l (sp)+,-6(a6)
+I004:
+ move.l 8+0(a6),-(sp)
+ move.l (sp),-(sp)
+ move.l (sp)+,a0
+ add #1,a0
+ move.l a0,-(sp)
+ move.l (sp)+,8+0(a6)
+ move.l (sp)+,a0
+ clr d0
+ move.b (a0),d0
+ move.w d0,-(sp)
+ move.w (sp),-(sp)
+ move.w (sp)+,-2(a6)
+ move.w #37,-(sp)
+ move.w (sp)+,d0
+ cmp (sp)+,d0
+ beq I005
+ move.w -2(a6),-(sp)
+ tst (sp)+
+ beq I002
+ move.w -2(a6),-(sp)
+ jsr _putchar
+ add #2,sp
+ jmp I004
+I005:
+ move.l 8+0(a6),-(sp)
+ move.l (sp),-(sp)
+ move.l (sp)+,a0
+ add #1,a0
+ move.l a0,-(sp)
+ move.l (sp)+,8+0(a6)
+ move.l (sp)+,a0
+ clr d0
+ move.b (a0),d0
+ move.w d0,-(sp)
+ move.w (sp)+,-2(a6)
+ move.w -2(a6),-(sp)
+ move.w #100,-(sp)
+ move.w (sp)+,d0
+ cmp (sp)+,d0
+ beq I008
+ move.w -2(a6),-(sp)
+ move.w #117,-(sp)
+ move.w (sp)+,d0
+ cmp (sp)+,d0
+ bne I007
+I008:
+ move.l -6(a6),-(sp)
+ move.l (sp)+,a0
+ add #2,a0
+ move.l a0,-(sp)
+ move.l (sp),-(sp)
+ move.l (sp)+,-6(a6)
+ move.l (sp)+,a0
+ move.w -2(a0),-(sp)
+ move.w (sp)+,-8(a6)
+ move.w -2(a6),-(sp)
+ move.w #100,-(sp)
+ move.w (sp)+,d0
+ cmp (sp)+,d0
+ bne I009
+ move.w -8(a6),-(sp)
+ tst (sp)+
+ bge I009
+ move.w #0,-(sp)
+ move.w -8(a6),-(sp)
+ move.w (sp)+,d0
+ move.w (sp)+,d1
+ sub d0,d1
+ move.w d1,-(sp)
+ move.w (sp)+,-8(a6)
+ move.w #45,-(sp)
+ jsr _putchar
+ add #2,sp
+I009:
+ move.w -8(a6),-(sp)
+ jsr _printn
+ add #2,sp
+ jmp I004
+I007:
+ move.w -2(a6),-(sp)
+ move.w #115,-(sp)
+ move.w (sp)+,d0
+ cmp (sp)+,d0
+ bne I004
+ move.l -6(a6),-(sp)
+ move.l (sp)+,a0
+ add #4,a0
+ move.l a0,-(sp)
+ move.l (sp),-(sp)
+ move.l (sp)+,-6(a6)
+ move.l (sp)+,a0
+ move.l -4(a0),-(sp)
+ move.l (sp)+,-12(a6)
+I00c:
+ move.l -12(a6),-(sp)
+ move.l (sp),-(sp)
+ move.l (sp)+,a0
+ add #1,a0
+ move.l a0,-(sp)
+ move.l (sp)+,-12(a6)
+ move.l (sp)+,a0
+ clr d0
+ move.b (a0),d0
+ move.w d0,-(sp)
+ move.w (sp),-(sp)
+ move.w (sp)+,-2(a6)
+ tst (sp)+
+ beq I004
+ move.w -2(a6),-(sp)
+ jsr _putchar
+ add #2,sp
+ jmp I00c
+I002:
+ unlk a6
+ rts
+_printn:
+ link a6,#-2
+.data
+_15:
+ .short 12337
+ .short 12851
+ .short 13365
+ .short 13879
+ .short 14393
+ .short 0
+.text
+ move.w 8+0(a6),-(sp)
+ move.w #10,-(sp)
+ move.w (sp)+,d0
+ clr.l d1
+ move.w (sp)+,d1
+ divu d0,d1
+ move.w d1,-(sp)
+ move.w (sp),-(sp)
+ move.w (sp)+,-2(a6)
+ tst (sp)+
+ beq I013
+ move.w -2(a6),-(sp)
+ jsr _printn
+ add #2,sp
+I013:
+ pea _15
+ move.w 8+0(a6),-(sp)
+ move.w #10,-(sp)
+ move.w (sp)+,d0
+ clr.l d1
+ move.w (sp)+,d1
+ divu d0,d1
+ swap d1
+ move.w d1,-(sp)
+ move.w (sp)+,d0
+ ext.l d0
+ add.l (sp)+,d0
+ move.l d0,-(sp)
+ move.l (sp)+,a0
+ clr d0
+ move.b (a0),d0
+ move.w d0,-(sp)
+ jsr _putchar
+ add #2,sp
+ unlk a6
+ rts
--- /dev/null
+.define .rck
+
+ .text
+.rck:
+ move.l (sp)+,a1
+ move.l (sp)+,a0 ! descriptor address
+ move.w (sp),d0
+ cmp (a0),d0
+ blt 1f
+ cmp 2(a0),d0
+ ble 2f
+1:
+ move.w #ERANGE,-(sp)
+ jsr .trp
+2:
+ jmp (a1)
--- /dev/null
+.define .ret
+
+ .text
+.ret:
+ beq 3f
+ cmp #2,d0
+ bne 1f
+ move (sp)+,d0
+ bra 3f
+1:
+ cmp #4,d0
+ bne 2f
+ move.l (sp)+,d0
+ bra 3f
+2:
+ cmp #8,d0
+ bne 4f
+ move.l (sp)+,d0
+ move.l (sp)+,d1
+3:
+ unlk a6
+ rts
+4:
+ move.w #EILLINS,-(sp)
+ jmp .fat
--- /dev/null
+.define .set
+
+ ! d0 : setsize in bytes
+ ! d1 : bitnumber
+ .text
+.set:
+ move.l (sp)+,a0
+ move.w (sp)+,d1
+ move.w d0,d2
+ asr #1,d2
+1:
+ clr -(sp)
+ sub #1,d2
+ bgt 1b
+ move.l sp,a1 ! set base
+ move.w d1,d2
+ asr #3,d2
+ bchg #0,d2
+ cmp d0,d2
+ bcs 1f
+ move.w #ESET,-(sp)
+ move.l a0,-(sp)
+ jmp .trp
+1:
+ add d2,a1
+ bset d1,(a1)
+ jmp (a0)
--- /dev/null
+.define .strhp
+
+ .text
+.strhp:
+ move.l (sp)+,a0
+ move.l (sp)+,d0 ! heap pointer
+ move.l d0,.reghp
+ cmp.l .limhp,d0
+ bmi 1f
+ add.l #0x400,d0
+ and.l #~0x3ff,d0
+ move.l d0,.limhp
+ move.l d0,-(sp)
+ jsr _brk
+ tst.l (sp)+
+ tst.w d0
+ bne 2f
+1:
+ jmp (a0)
+2:
+ move.w #EHEAP,-(sp)
+ jmp .fat
--- /dev/null
+.define .sig
+
+ .text
+.sig:
+ move.l (sp)+,a0
+ move.l (sp)+,a1 ! trap pc
+ move.l .trppc,-(sp)
+ move.l a1,.trppc
+ jmp (a0)
--- /dev/null
+.define .sts
+
+ ! d0 : # bytes
+ ! a0 : destination address
+ .text
+.sts:
+ move.l (sp)+,a1
+ move.w (sp)+,d0
+ move.l (sp)+,a0
+ cmp #1,d0
+ bne 1f
+ move.w (sp)+,d0
+ move.b d0,(a0)
+ bra 3f
+1:
+ asr #1,d0
+2:
+ move.w (sp)+,(a0)+
+ sub #1,d0
+ bgt 2b
+3:
+ jmp (a1)
--- /dev/null
+.define .trp
+
+ .text
+.trp:
+ move.l (sp)+,a1 ! return address
+ move.w (sp)+,d0 ! error number
+ move.l a1,-(sp)
+ move.w d0,-(sp)
+ cmp #16,d0
+ bcc 1f
+ cmp #8,d0
+ bcc 4f
+ btst d0,.trpim
+ bra 5f
+4:
+ btst d0,.trpim+1
+5:
+ bne 3f
+1:
+ move.l .trppc,a0
+ move.l a0,d0
+ beq 9f
+ clr.l .trppc
+ jsr (a0)
+3:
+ add #2,sp
+ rts
+9:
+ pea fmt
+ jsr .diagnos
+ jmp EXIT
+
+ .data
+.rettrp: .long 0
+fmt: .asciz "trap %d called\n"
+.align 2
--- /dev/null
+.define CERASE,CKILL,CSTOP,CSTART
+.define .lino,.filn
+
+.define F_DUM,EXIT
+
+.define begtext,begdata,begbss
+.define EARRAY,ERANGE,ESET,EIDIVZ,EHEAP,EILLINS,ECASE,EBADGTO
+.define hol0,.reghp,.limhp,.trpim,.trppc
+.define LINO_AD,FILN_AD
+
+! EM runtime start-off for the Bleasdale 68000 system
+
+
+CERASE = 010
+CKILL = 030
+CSTART = 021
+CSTOP = 023
+F_DUM = 0
+
+
+LINO_AD = 0
+FILN_AD = 4
+
+EARRAY = 0
+ERANGE = 1
+ESET = 2
+EIDIVZ = 6
+EHEAP = 17
+EILLINS = 18
+ECASE = 20
+EBADGTO = 27
+
+.base 0x20000
+ .text
+begtext:
+ ! Bleasdale puts the argument and environment vectors
+ ! themselves on top of the stack, instead of POINTERS
+ ! to these vectors. We get things right here.
+ move.l 4(sp),a0
+ clr.l -4(a0)
+ move.l sp,a0
+ sub.l #8,sp
+ move.l (a0),(sp)
+ add.l #4,a0
+ move.l a0,4(sp)
+1:
+ tst.l (a0)+
+ bne 1b
+ move.l 4(sp),a1
+ cmp.l (a1),a0
+ blt 2f
+ sub.l #4,a0
+2:
+ move.l a0,8(sp)
+
+ ! Now the stack contains an argc (4 bytes), argv-pointer and
+ ! envp pointer.
+
+ add.l #2,sp !convert argc from 4-byte to 2-byte
+ pea endbss
+ jsr _brk
+ add.l #4,sp
+ jsr _m_a_i_n
+ add #010,sp
+EXIT:
+ jsr __exit
+
+ .data
+begdata:
+hol0:
+.lino:
+ .short 0,0 ! lino
+.filn:
+ .long 0 ! filn
+.reghp:
+ .long endbss
+.limhp:
+ .long endbss
+.trppc:
+ .long 0
+.trpim:
+ .short 0
+
+
+ .bss
+begbss: