From ad815f10617327842a4766a0230113fb7fc7ce71 Mon Sep 17 00:00:00 2001 From: bal Date: Fri, 14 Dec 1984 15:41:14 +0000 Subject: [PATCH] Initial revision --- mach/m68k2/libem/LIST | 34 +++++++ mach/m68k2/libem/ara.s | 83 ++++++++++++++++ mach/m68k2/libem/cii.s | 21 ++++ mach/m68k2/libem/cmi.s | 18 ++++ mach/m68k2/libem/cmp.s | 15 +++ mach/m68k2/libem/cms.s | 23 +++++ mach/m68k2/libem/cmu.s | 27 ++++++ mach/m68k2/libem/compmodule | 4 + mach/m68k2/libem/csa.s | 26 +++++ mach/m68k2/libem/csb.s | 24 +++++ mach/m68k2/libem/cuu.s | 21 ++++ mach/m68k2/libem/cvf.s | 15 +++ mach/m68k2/libem/dia.s | 37 ++++++++ mach/m68k2/libem/dvi.s | 38 ++++++++ mach/m68k2/libem/dvu.s | 34 +++++++ mach/m68k2/libem/exg.s | 23 +++++ mach/m68k2/libem/fat.s | 6 ++ mach/m68k2/libem/gto.s | 75 +++++++++++++++ mach/m68k2/libem/inn.s | 29 ++++++ mach/m68k2/libem/los.s | 24 +++++ mach/m68k2/libem/lpb.s | 18 ++++ mach/m68k2/libem/lxa.s | 18 ++++ mach/m68k2/libem/lxl.s | 16 ++++ mach/m68k2/libem/mli.s | 30 ++++++ mach/m68k2/libem/mlu.s | 37 ++++++++ mach/m68k2/libem/mon.s | 12 +++ mach/m68k2/libem/nop.s | 13 +++ mach/m68k2/libem/printf.s | 185 ++++++++++++++++++++++++++++++++++++ mach/m68k2/libem/rck.s | 16 ++++ mach/m68k2/libem/ret.s | 25 +++++ mach/m68k2/libem/set.s | 27 ++++++ mach/m68k2/libem/shp.s | 22 +++++ mach/m68k2/libem/sig.s | 9 ++ mach/m68k2/libem/sts.s | 22 +++++ mach/m68k2/libem/trp.s | 36 +++++++ mach/m68k2/libsys/head_em.s | 86 +++++++++++++++++ 36 files changed, 1149 insertions(+) create mode 100644 mach/m68k2/libem/LIST create mode 100644 mach/m68k2/libem/ara.s create mode 100644 mach/m68k2/libem/cii.s create mode 100644 mach/m68k2/libem/cmi.s create mode 100644 mach/m68k2/libem/cmp.s create mode 100644 mach/m68k2/libem/cms.s create mode 100644 mach/m68k2/libem/cmu.s create mode 100755 mach/m68k2/libem/compmodule create mode 100644 mach/m68k2/libem/csa.s create mode 100644 mach/m68k2/libem/csb.s create mode 100644 mach/m68k2/libem/cuu.s create mode 100644 mach/m68k2/libem/cvf.s create mode 100644 mach/m68k2/libem/dia.s create mode 100644 mach/m68k2/libem/dvi.s create mode 100644 mach/m68k2/libem/dvu.s create mode 100644 mach/m68k2/libem/exg.s create mode 100644 mach/m68k2/libem/fat.s create mode 100644 mach/m68k2/libem/gto.s create mode 100644 mach/m68k2/libem/inn.s create mode 100644 mach/m68k2/libem/los.s create mode 100644 mach/m68k2/libem/lpb.s create mode 100644 mach/m68k2/libem/lxa.s create mode 100644 mach/m68k2/libem/lxl.s create mode 100644 mach/m68k2/libem/mli.s create mode 100644 mach/m68k2/libem/mlu.s create mode 100644 mach/m68k2/libem/mon.s create mode 100644 mach/m68k2/libem/nop.s create mode 100644 mach/m68k2/libem/printf.s create mode 100644 mach/m68k2/libem/rck.s create mode 100644 mach/m68k2/libem/ret.s create mode 100644 mach/m68k2/libem/set.s create mode 100644 mach/m68k2/libem/shp.s create mode 100644 mach/m68k2/libem/sig.s create mode 100644 mach/m68k2/libem/sts.s create mode 100644 mach/m68k2/libem/trp.s create mode 100644 mach/m68k2/libsys/head_em.s diff --git a/mach/m68k2/libem/LIST b/mach/m68k2/libem/LIST new file mode 100644 index 000000000..477787039 --- /dev/null +++ b/mach/m68k2/libem/LIST @@ -0,0 +1,34 @@ +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 diff --git a/mach/m68k2/libem/ara.s b/mach/m68k2/libem/ara.s new file mode 100644 index 000000000..3c3f179a1 --- /dev/null +++ b/mach/m68k2/libem/ara.s @@ -0,0 +1,83 @@ +.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 diff --git a/mach/m68k2/libem/cii.s b/mach/m68k2/libem/cii.s new file mode 100644 index 000000000..045d7c72e --- /dev/null +++ b/mach/m68k2/libem/cii.s @@ -0,0 +1,21 @@ +.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) diff --git a/mach/m68k2/libem/cmi.s b/mach/m68k2/libem/cmi.s new file mode 100644 index 000000000..dd5e554cd --- /dev/null +++ b/mach/m68k2/libem/cmi.s @@ -0,0 +1,18 @@ +.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) diff --git a/mach/m68k2/libem/cmp.s b/mach/m68k2/libem/cmp.s new file mode 100644 index 000000000..f2d962f9e --- /dev/null +++ b/mach/m68k2/libem/cmp.s @@ -0,0 +1,15 @@ +.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) diff --git a/mach/m68k2/libem/cms.s b/mach/m68k2/libem/cms.s new file mode 100644 index 000000000..1ff61a85e --- /dev/null +++ b/mach/m68k2/libem/cms.s @@ -0,0 +1,23 @@ +.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 diff --git a/mach/m68k2/libem/cmu.s b/mach/m68k2/libem/cmu.s new file mode 100644 index 000000000..624e2cb68 --- /dev/null +++ b/mach/m68k2/libem/cmu.s @@ -0,0 +1,27 @@ +.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) diff --git a/mach/m68k2/libem/compmodule b/mach/m68k2/libem/compmodule new file mode 100755 index 000000000..eb1ccef3c --- /dev/null +++ b/mach/m68k2/libem/compmodule @@ -0,0 +1,4 @@ +if m68k2 -c $1 1>&2 +then echo `basename $1 $2`.s +else exit 1 +fi diff --git a/mach/m68k2/libem/csa.s b/mach/m68k2/libem/csa.s new file mode 100644 index 000000000..9d3e036f4 --- /dev/null +++ b/mach/m68k2/libem/csa.s @@ -0,0 +1,26 @@ +.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 diff --git a/mach/m68k2/libem/csb.s b/mach/m68k2/libem/csb.s new file mode 100644 index 000000000..c36ecf003 --- /dev/null +++ b/mach/m68k2/libem/csb.s @@ -0,0 +1,24 @@ +.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) diff --git a/mach/m68k2/libem/cuu.s b/mach/m68k2/libem/cuu.s new file mode 100644 index 000000000..d1db8f5ca --- /dev/null +++ b/mach/m68k2/libem/cuu.s @@ -0,0 +1,21 @@ +.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) diff --git a/mach/m68k2/libem/cvf.s b/mach/m68k2/libem/cvf.s new file mode 100644 index 000000000..d0b081ddc --- /dev/null +++ b/mach/m68k2/libem/cvf.s @@ -0,0 +1,15 @@ +.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) diff --git a/mach/m68k2/libem/dia.s b/mach/m68k2/libem/dia.s new file mode 100644 index 000000000..849f29e23 --- /dev/null +++ b/mach/m68k2/libem/dia.s @@ -0,0 +1,37 @@ +.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 diff --git a/mach/m68k2/libem/dvi.s b/mach/m68k2/libem/dvi.s new file mode 100644 index 000000000..508f66707 --- /dev/null +++ b/mach/m68k2/libem/dvi.s @@ -0,0 +1,38 @@ +.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) diff --git a/mach/m68k2/libem/dvu.s b/mach/m68k2/libem/dvu.s new file mode 100644 index 000000000..2c3dea8d6 --- /dev/null +++ b/mach/m68k2/libem/dvu.s @@ -0,0 +1,34 @@ +.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) diff --git a/mach/m68k2/libem/exg.s b/mach/m68k2/libem/exg.s new file mode 100644 index 000000000..042f80fb8 --- /dev/null +++ b/mach/m68k2/libem/exg.s @@ -0,0 +1,23 @@ +.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 diff --git a/mach/m68k2/libem/fat.s b/mach/m68k2/libem/fat.s new file mode 100644 index 000000000..fe2e07826 --- /dev/null +++ b/mach/m68k2/libem/fat.s @@ -0,0 +1,6 @@ +.define .fat + + .text +.fat: + jsr .trp + jmp EXIT diff --git a/mach/m68k2/libem/gto.s b/mach/m68k2/libem/gto.s new file mode 100644 index 000000000..c78ca22ac --- /dev/null +++ b/mach/m68k2/libem/gto.s @@ -0,0 +1,75 @@ +.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 diff --git a/mach/m68k2/libem/inn.s b/mach/m68k2/libem/inn.s new file mode 100644 index 000000000..79d057c53 --- /dev/null +++ b/mach/m68k2/libem/inn.s @@ -0,0 +1,29 @@ +.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) diff --git a/mach/m68k2/libem/los.s b/mach/m68k2/libem/los.s new file mode 100644 index 000000000..5bc40cc89 --- /dev/null +++ b/mach/m68k2/libem/los.s @@ -0,0 +1,24 @@ +.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) diff --git a/mach/m68k2/libem/lpb.s b/mach/m68k2/libem/lpb.s new file mode 100644 index 000000000..325677352 --- /dev/null +++ b/mach/m68k2/libem/lpb.s @@ -0,0 +1,18 @@ +.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) diff --git a/mach/m68k2/libem/lxa.s b/mach/m68k2/libem/lxa.s new file mode 100644 index 000000000..ff0df4269 --- /dev/null +++ b/mach/m68k2/libem/lxa.s @@ -0,0 +1,18 @@ +.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 diff --git a/mach/m68k2/libem/lxl.s b/mach/m68k2/libem/lxl.s new file mode 100644 index 000000000..7ab2354eb --- /dev/null +++ b/mach/m68k2/libem/lxl.s @@ -0,0 +1,16 @@ +.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 diff --git a/mach/m68k2/libem/mli.s b/mach/m68k2/libem/mli.s new file mode 100644 index 000000000..fdf9242c1 --- /dev/null +++ b/mach/m68k2/libem/mli.s @@ -0,0 +1,30 @@ +.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) diff --git a/mach/m68k2/libem/mlu.s b/mach/m68k2/libem/mlu.s new file mode 100644 index 000000000..b8522da48 --- /dev/null +++ b/mach/m68k2/libem/mlu.s @@ -0,0 +1,37 @@ +.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) diff --git a/mach/m68k2/libem/mon.s b/mach/m68k2/libem/mon.s new file mode 100644 index 000000000..dabe65a92 --- /dev/null +++ b/mach/m68k2/libem/mon.s @@ -0,0 +1,12 @@ +.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 diff --git a/mach/m68k2/libem/nop.s b/mach/m68k2/libem/nop.s new file mode 100644 index 000000000..f7dd9db14 --- /dev/null +++ b/mach/m68k2/libem/nop.s @@ -0,0 +1,13 @@ +.define .nop + + .text +.nop: + move.w hol0,-(sp) + pea fmt + jsr .diagnos + add #6,sp + rts + + .data +fmt: .asciz "test %d\n" +.align 2 diff --git a/mach/m68k2/libem/printf.s b/mach/m68k2/libem/printf.s new file mode 100644 index 000000000..cc79a6964 --- /dev/null +++ b/mach/m68k2/libem/printf.s @@ -0,0 +1,185 @@ +.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 diff --git a/mach/m68k2/libem/rck.s b/mach/m68k2/libem/rck.s new file mode 100644 index 000000000..52af333aa --- /dev/null +++ b/mach/m68k2/libem/rck.s @@ -0,0 +1,16 @@ +.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) diff --git a/mach/m68k2/libem/ret.s b/mach/m68k2/libem/ret.s new file mode 100644 index 000000000..a1b394de0 --- /dev/null +++ b/mach/m68k2/libem/ret.s @@ -0,0 +1,25 @@ +.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 diff --git a/mach/m68k2/libem/set.s b/mach/m68k2/libem/set.s new file mode 100644 index 000000000..7d32c69de --- /dev/null +++ b/mach/m68k2/libem/set.s @@ -0,0 +1,27 @@ +.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) diff --git a/mach/m68k2/libem/shp.s b/mach/m68k2/libem/shp.s new file mode 100644 index 000000000..8390632a3 --- /dev/null +++ b/mach/m68k2/libem/shp.s @@ -0,0 +1,22 @@ +.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 diff --git a/mach/m68k2/libem/sig.s b/mach/m68k2/libem/sig.s new file mode 100644 index 000000000..3fa3e0bcf --- /dev/null +++ b/mach/m68k2/libem/sig.s @@ -0,0 +1,9 @@ +.define .sig + + .text +.sig: + move.l (sp)+,a0 + move.l (sp)+,a1 ! trap pc + move.l .trppc,-(sp) + move.l a1,.trppc + jmp (a0) diff --git a/mach/m68k2/libem/sts.s b/mach/m68k2/libem/sts.s new file mode 100644 index 000000000..937c9304b --- /dev/null +++ b/mach/m68k2/libem/sts.s @@ -0,0 +1,22 @@ +.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) diff --git a/mach/m68k2/libem/trp.s b/mach/m68k2/libem/trp.s new file mode 100644 index 000000000..36045db47 --- /dev/null +++ b/mach/m68k2/libem/trp.s @@ -0,0 +1,36 @@ +.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 diff --git a/mach/m68k2/libsys/head_em.s b/mach/m68k2/libsys/head_em.s new file mode 100644 index 000000000..7c7eb12b6 --- /dev/null +++ b/mach/m68k2/libsys/head_em.s @@ -0,0 +1,86 @@ +.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: -- 2.34.1