From 668b4ca6e72a77efed956ff0433f55c5580cc502 Mon Sep 17 00:00:00 2001 From: ceriel Date: Mon, 3 Oct 1988 10:53:47 +0000 Subject: [PATCH] many minor changes --- mach/m68020/libem/LIST | 2 +- mach/m68020/libem/Makefile | 3 ++ mach/m68020/libem/aar.s | 1 + mach/m68020/libem/cmi.s | 5 ++- mach/m68020/libem/cms.s | 5 ++- mach/m68020/libem/cmu.s | 5 ++- mach/m68020/libem/csa.s | 1 + mach/m68020/libem/csb.s | 1 + mach/m68020/libem/dia.s | 79 +++++++++++++++++++++++++++++++++++++ mach/m68020/libem/fat.s | 2 +- mach/m68020/libem/inn.s | 2 + mach/m68020/libem/lar.s | 18 +++++---- mach/m68020/libem/mon.s | 2 +- mach/m68020/libem/sar.s | 14 ++++--- mach/m68020/libem/set.s | 3 ++ mach/m68020/libem/shp.s | 1 + mach/m68020/libem/strscript | 3 ++ mach/m68020/libem/trp.s | 9 ++--- mach/m68020/libem/trpstr.c | 34 ++++++++++++++++ 19 files changed, 161 insertions(+), 29 deletions(-) create mode 100644 mach/m68020/libem/strscript create mode 100644 mach/m68020/libem/trpstr.c diff --git a/mach/m68020/libem/LIST b/mach/m68020/libem/LIST index f8083f250..7c68063df 100644 --- a/mach/m68020/libem/LIST +++ b/mach/m68020/libem/LIST @@ -10,10 +10,10 @@ set.s inn.s fat.s trp.s +trpstr.s mon.s nop.s dia.s -printf.s cii.s cuu.s cmi.s diff --git a/mach/m68020/libem/Makefile b/mach/m68020/libem/Makefile index d7303de43..52413ad78 100644 --- a/mach/m68020/libem/Makefile +++ b/mach/m68020/libem/Makefile @@ -26,3 +26,6 @@ opr : pr: @arch pv libem_s.a | pr -h `pwd`/libem_s.a @pr `pwd`/end.s + +trpstr.s: trpstr.c strscript + sh strscript diff --git a/mach/m68020/libem/aar.s b/mach/m68020/libem/aar.s index b8d666c96..01d1a4727 100644 --- a/mach/m68020/libem/aar.s +++ b/mach/m68020/libem/aar.s @@ -4,6 +4,7 @@ .sect .data .sect .bss .sect .text +EILLINS = 18 .aar: ! (on entry d0 contains the integer size in the descriptor) diff --git a/mach/m68020/libem/cmi.s b/mach/m68020/libem/cmi.s index 4846142b3..477f0f324 100644 --- a/mach/m68020/libem/cmi.s +++ b/mach/m68020/libem/cmi.s @@ -8,9 +8,10 @@ ! on entry d0: # bytes in 1 block ! on exit d0: result .cmi: - move.l (sp)+, d2 ! return address + move.l (sp)+, d1 ! return address move.l sp, a0 ! address of top block lea (sp,d0.l), a1 ! address of lower block + move.l d1,-(sp) move.l d0, d1 asr.l #2, d0 1: @@ -22,7 +23,7 @@ bge 3f neg.l d0 ! less 3: + move.l (sp)+,a0 lea (sp,d1.l*2), sp ! new sp; two blocks popped - move.l d2,a0 jmp (a0) ! return .align 2 diff --git a/mach/m68020/libem/cms.s b/mach/m68020/libem/cms.s index ae9945e34..79cb19fa5 100644 --- a/mach/m68020/libem/cms.s +++ b/mach/m68020/libem/cms.s @@ -8,9 +8,10 @@ ! d0 contains set size ! on exit d0 is zero for equal, non-zero for not equal .cms: - move.l (sp)+, d2 ! return address + move.l (sp)+, d1 ! return address move.l sp, a0 ! address of top block lea (sp,d0.l), a1 ! address of lower block + move.l d1,-(sp) move.l d0, d1 asr.l #2, d0 1: @@ -19,7 +20,7 @@ sub.l #1, d0 bne 1b 2: + move.l (sp)+,a0 lea (sp,d1.l*2), sp ! new sp; two blocks popped - move.l d2,a0 jmp (a0) .align 2 diff --git a/mach/m68020/libem/cmu.s b/mach/m68020/libem/cmu.s index 8faa6267b..08f4b96a6 100644 --- a/mach/m68020/libem/cmu.s +++ b/mach/m68020/libem/cmu.s @@ -8,9 +8,10 @@ ! on entry d0: # bytes in 1 block ! on exit d0: result .cmu: - move.l (sp)+, d2 ! return address + move.l (sp)+, d1 ! return address move.l sp, a0 ! address of top block lea (sp,d0.l), a1 ! address of lower block + move.l d1,-(sp) move.l d0, d1 asr.l #2, d0 1: @@ -22,7 +23,7 @@ bcc 3f neg.l d0 ! less 3: + move.l (sp)+,a0 lea (sp,d1.l*2), sp ! new sp; two blocks popped - move.l d2, a0 jmp (a0) .align 2 diff --git a/mach/m68020/libem/csa.s b/mach/m68020/libem/csa.s index 2cec60e00..b540a2e74 100644 --- a/mach/m68020/libem/csa.s +++ b/mach/m68020/libem/csa.s @@ -3,6 +3,7 @@ .sect .rom .sect .data .sect .bss +ECASE=20 .sect .text diff --git a/mach/m68020/libem/csb.s b/mach/m68020/libem/csb.s index e61fc4fa6..550f496c9 100644 --- a/mach/m68020/libem/csb.s +++ b/mach/m68020/libem/csb.s @@ -3,6 +3,7 @@ .sect .rom .sect .data .sect .bss +ECASE=20 .sect .text diff --git a/mach/m68020/libem/dia.s b/mach/m68020/libem/dia.s index 05d88fc70..42ec8a68f 100644 --- a/mach/m68020/libem/dia.s +++ b/mach/m68020/libem/dia.s @@ -38,6 +38,85 @@ del = 0177 move.l #unknwn, d2 bra 2b +.sect .bss +_getal: + .space 12 +_char: + .space 1 + .align 4 +.sect .data +hexs: + .ascii "0123456789abcdef" + .align 4 +.sect .text +_printf: + movem.l d0/d1/d2/a0/a1/a2/a3/a4/a5/a6, -(sp) + lea (44, sp), a6 ! a6 <- address of arguments + move.l (a6)+, a5 ! a5 <- address of format +next: move.b (a5)+, d0 + beq out + cmp.b #'%', d0 + beq procnt +put: move.l d0, -(sp) + jsr (_putchar) ! long argument on stack + tst.l (sp)+ + bra next + +procnt: move.b (a5)+, d0 + cmp.b #'d', d0 ! NOTE: %d means unsigned. + beq digit + cmp.b #'x', d0 + beq hex + cmp.b #'s', d0 + beq string + cmp.b #'%', d0 ! second % has to be printed. + beq put + tst.b -(a5) ! normal char should be printed + bra next + +string: move.l (a6)+, a2 ! a2 <- address of string +sloop: move.b (a2)+, d0 + beq next + move.l d0, -(sp) + jsr (_putchar) ! long argument on stack + tst.l (sp)+ + bra sloop + +digit: move.l (a6)+, d1 ! d1 <- integer + move.l #_getal+12, a2 ! a2 <- ptr to last part of buf + clr.b -(a2) ! stringterminator +1: divul.l #10, d2:d1 ! d1 <- qotient; d2 <- remainder + add.l #'0', d2 + move.b d2, -(a2) + tst.l d1 ! if quotient = 0 then ready + bne 1b + bra sloop ! print digitstring. + +hex: move.l (a6)+, d1 ! d1 <- integer + move.l #_getal+12, a2 ! a2 <- ptr to last part of buf + clr.b -(a2) ! stringterminator + move.l #7, d2 ! loop control +1: move.l d1, d0 + and.l #15, d0 + move.b (hexs,d0.w), -(a2) ! hex digit + asr.l #4, d1 + dbf d2, 1b + bra sloop + +out: + movem.l (sp)+, d0/d1/d2/a0/a1/a2/a3/a4/a5/a6 + rts + + +_putchar: + move.l #1, -(sp) + pea (11,sp) + move.l #1, -(sp) + jsr (_write) + lea (12, sp), sp + rts +.align 2 + .sect .data fmt: .asciz "%s, line %d: " unknwn: .asciz "unknown file" diff --git a/mach/m68020/libem/fat.s b/mach/m68020/libem/fat.s index 378dcdd99..772838735 100644 --- a/mach/m68020/libem/fat.s +++ b/mach/m68020/libem/fat.s @@ -7,5 +7,5 @@ .sect .text .fatal: jsr (.trp) - jmp (EXIT) + jmp (_exit) .align 2 diff --git a/mach/m68020/libem/inn.s b/mach/m68020/libem/inn.s index 8acd9945f..0d7a97020 100644 --- a/mach/m68020/libem/inn.s +++ b/mach/m68020/libem/inn.s @@ -5,6 +5,8 @@ .sect .bss .sect .text +ESET=2 + .inn: ! d0 bitnumber ! d1 setsize in bytes ! on exit: 0 or 1 in d0 diff --git a/mach/m68020/libem/lar.s b/mach/m68020/libem/lar.s index 4a9e50465..92519872c 100644 --- a/mach/m68020/libem/lar.s +++ b/mach/m68020/libem/lar.s @@ -4,6 +4,7 @@ .sect .data .sect .bss .sect .text +EILLINS=18 ! (on entry d0 contains the integer size in the descriptor) .lar: cmp.l #4, d0 @@ -16,37 +17,38 @@ ! a1: base address ! d0: index ! d1: # bytes / element - ! d2: save return address ! For address calculation; see comment in 'aar.s'. - move.l (sp)+, d2 ! return address + move.l (sp)+, d1 ! return address move.l (sp)+, a0 ! descriptor address move.l (sp)+, d0 ! index move.l (sp)+, a1 ! array base address sub.l (a0), d0 ! relative index + move.l d1,-(sp) move.l (8,a0), d1 ! # bytes / element cmp.l #1, d1 bne 2f - clr.l -(sp) + move.l (sp),a0 + clr.l (sp) move.b (a1,d0.l), (3,sp) ! one byte element - bra 5f + jmp (a0) 2: cmp.l #2, d1 bne 4f - clr.l -(sp) + move.l (sp),a0 + clr.l (sp) move.w (a1,d0.l*2), (2,sp) ! two byte element - bra 5f + jmp (a0) 4: muls.l d1, d0 add.l d0, a1 ! address of 4n byte element add.l d1, a1 ! because of predecrement asr.l #2, d1 sub.l #1, d1 + move.l (sp)+,a0 1: move.l -(a1), -(sp) dbf d1, 1b -5: - move.l d2,a0 jmp (a0) .align 2 diff --git a/mach/m68020/libem/mon.s b/mach/m68020/libem/mon.s index 5c5f36984..4500edf5e 100644 --- a/mach/m68020/libem/mon.s +++ b/mach/m68020/libem/mon.s @@ -10,7 +10,7 @@ pea (fmt) jsr (.diagnos) add.l #8, sp - jmp (EXIT) + jmp (_exit) .sect .data fmt: .asciz "system call %d not implemented\n" diff --git a/mach/m68020/libem/sar.s b/mach/m68020/libem/sar.s index 251421fb5..380665fd3 100644 --- a/mach/m68020/libem/sar.s +++ b/mach/m68020/libem/sar.s @@ -3,6 +3,7 @@ .sect .rom .sect .data .sect .bss +EILLINS=18 .sect .text ! (on entry d0 contains the integer size in the descriptor) @@ -17,38 +18,39 @@ ! a1: base address ! d0: index ! d1: # bytes / element - ! d2: return address ! For address calculation; see comment in 'aar.s'. ! If the element size is a fraction of EM_WSIZE (4) ! the calculation is done by adding. - move.l (sp)+, d2 ! return address + move.l (sp)+, d1 ! return address move.l (sp)+, a0 move.l (sp)+, d0 move.l (sp)+, a1 + move.l d1,-(sp) ! return address sub.l (a0), d0 move.l (8,a0), d1 ! # bytes / element cmp.l #1, d1 bne 2f + move.l (sp)+,a0 move.l (sp)+, d1 move.b d1, (a1,d0.l) ! store one byte element - bra 5f + jmp (a0) 2: cmp.l #2, d1 bne 4f + move.l (sp)+,a0 move.l (sp)+, d1 move.w d1, (a1,d0.l*2) ! store two byte element - bra 5f + jmp (a0) 4: ! here: 4n byte element muls.l d1, d0 add.l d0, a1 ! address of 4n byte element asr.l #2, d1 sub.l #1, d1 + move.l (sp)+,a0 1: move.l (sp)+, (a1)+ dbf d1, 1b -5: - move.l d2,a0 jmp (a0) .align 2 diff --git a/mach/m68020/libem/set.s b/mach/m68020/libem/set.s index c2a94be64..fd1f8cfbd 100644 --- a/mach/m68020/libem/set.s +++ b/mach/m68020/libem/set.s @@ -4,9 +4,12 @@ .sect .data .sect .bss .sect .text +ESET=2 .set: ! d0 bitnumber ! d1 setsize in bytes + ! a1 saved d2 + ! a0 return address move.l (sp)+, a0 move.l d2, a1 diff --git a/mach/m68020/libem/shp.s b/mach/m68020/libem/shp.s index 582f45ce5..2d6c3b5c8 100644 --- a/mach/m68020/libem/shp.s +++ b/mach/m68020/libem/shp.s @@ -3,6 +3,7 @@ .sect .rom .sect .data .sect .bss +EHEAP=17 .sect .text .strhp: diff --git a/mach/m68020/libem/strscript b/mach/m68020/libem/strscript new file mode 100644 index 000000000..51b62fd45 --- /dev/null +++ b/mach/m68020/libem/strscript @@ -0,0 +1,3 @@ +acc -c.s -L -LIB -I../../../h trpstr.c +sed s/_trpstr/.trpstr/g < trpstr.s > trpstr.ss +mv trpstr.ss trpstr.s diff --git a/mach/m68020/libem/trp.s b/mach/m68020/libem/trp.s index 17e519f60..313fd17a3 100644 --- a/mach/m68020/libem/trp.s +++ b/mach/m68020/libem/trp.s @@ -29,12 +29,9 @@ add.l #4, sp rts 9: - pea (fmt) + jsr (.trpstr) + move.l d0,-(sp) jsr (.diagnos) lea (4, sp), sp - jsr (__cleanup) - jmp (EXIT) - -.sect .data -fmt: .asciz "trap %d called\n" + jsr (_exit) .align 2 diff --git a/mach/m68020/libem/trpstr.c b/mach/m68020/libem/trpstr.c new file mode 100644 index 000000000..9f1002611 --- /dev/null +++ b/mach/m68020/libem/trpstr.c @@ -0,0 +1,34 @@ +#include +char * +trpstr(d) +{ + switch(d) + { + case EARRAY: return "array bound error"; + case ERANGE: return "range bound error"; + case ESET: return "set bound error"; + case EIOVFL: return "integer overflow"; + case EFOVFL: return "floating overflow"; + case EFUNFL: return "floating underflow"; + case EIDIVZ: return "divide by 0"; + case EFDIVZ: return "divide by 0.0"; + case EIUND: return "undefined integer"; + case EFUND: return "undefined real"; + case ECONV: return "conversion error"; + case ESTACK: return "stack overflow"; + case EHEAP: return "heap overflow"; + case EILLINS: return "illegal instruction"; + case EODDZ: return "illegal size argument"; + case ECASE: return "case error"; + case EMEMFLT: return "addressing non-existent memory"; + case EBADPTR: return "bad pointer used"; + case EBADPC: return "program counter out of range"; + case EBADMON: return "bad monitor call"; + case EBADLIN: + case EBADGTO: + case EBADLAE: + default: + return "strange trap"; + } + /*NOTREACHED*/ +} -- 2.34.1