From 0928518b8d31c75fba2e081cc1a9d1110a034264 Mon Sep 17 00:00:00 2001 From: ceriel Date: Fri, 3 Nov 1989 11:54:41 +0000 Subject: [PATCH] Added a nicer trap handler --- mach/minix/libsys/LIST | 1 + mach/minix/libsys/Makefile | 2 +- mach/minix/libsys/trp.s | 114 +++++++++++++++++++++++++++++++++++++ 3 files changed, 116 insertions(+), 1 deletion(-) create mode 100644 mach/minix/libsys/trp.s diff --git a/mach/minix/libsys/LIST b/mach/minix/libsys/LIST index baa746b13..cb64e1a44 100644 --- a/mach/minix/libsys/LIST +++ b/mach/minix/libsys/LIST @@ -55,3 +55,4 @@ write.c brksize.s sendrec.s catchsig.s +trp.s diff --git a/mach/minix/libsys/Makefile b/mach/minix/libsys/Makefile index 28b86039b..9a2007496 100644 --- a/mach/minix/libsys/Makefile +++ b/mach/minix/libsys/Makefile @@ -25,7 +25,7 @@ libsys.a: libsys_s.a march . libsys.a libsys_o.a: libsys.a ../../../lib/i86/tail_em - mkdir X; cd X; aal x ../libsys.a; aal x ../../../../lib/i86/tail_em; aal rv ../libsys_o.a *.o ; cd .. + mkdir X; cd X; aal x ../../../../lib/i86/tail_em; aal x ../libsys.a; aal rv ../libsys_o.a *.o ; cd .. rm -rf X clean: diff --git a/mach/minix/libsys/trp.s b/mach/minix/libsys/trp.s new file mode 100644 index 000000000..1aac8b779 --- /dev/null +++ b/mach/minix/libsys/trp.s @@ -0,0 +1,114 @@ +.sect .text ; .sect .rom; .sect .data; .sect .bss +.define .trpdivz +.define .trpilin +.define .trpcase +.define .trprang +.define .trpset +.define .trpnofp +.define .trpheap +.define .trp +.define .stop + +.sect .text +.extern .trpdivz +.extern .trpilin +.extern .trpcase +.extern .trprang +.extern .trpset +.extern .trpnofp +.extern .trpheap +.extern .trp + +.trpdivz: +mov ax,6 +mov dx,.Mdivz +jmp .Trp +.trpilin: +mov ax,18 +mov dx,.Milin +jmp .Trp +.trpcase: +mov ax,20 +mov dx,.Mcase +jmp .Trp +.trprang: +mov ax,1 +mov dx,.Mrang +jmp .Trp +.trpset: +mov ax,2 +mov dx,.Mset +jmp .Trp +.trpnofp: +mov ax,18 +mov dx,.Mnofp +jmp .Trp +.trpheap: +mov ax,17 +mov dx,.Mheap +jmp .Trp + +.Trp: +xor bx,bx +.extern .trppc +xchg bx,(.trppc) +test bx,bx +jz 2f +push ax +call (bx) +pop ax +ret +2: +mov bx,22 +push bx +push dx +mov ax,2 +push ax +call _write +.stop: +call _exit + +.trp: +mov dx,ax +cmp dx,21 +jae 1f +sal dx,1 +mov bx,.Mtable +add bx,dx +mov bx,(bx) +test bx,bx +jz 1f +mov dx,bx +jmp 2f +1: +mov bx,.Mtrp+14 +mov cx,6 +mov dx,ax +1: +and dx,7 +add dx,'0' +movb (bx),dl +dec bx +sar dx,1 +sar dx,1 +sar dx,1 +loop 1b +mov dx,.Mtrp +2: +jmp .Trp + +.sect .rom +.Mtable: + .data2 0, .Mrang, .Mset, 0, 0, 0, .Mdivz, 0 + .data2 0, 0, 0, 0, 0, 0, 0, 0 + .data2 0, .Mheap, .Milin, .Milin, .Mcase + +.Mdivz: .asciz "Error: Division by 0 \n" +.Milin: .asciz "Illegal EM instruct'n\n" +.Mcase: .asciz "Err in EM case instr \n" +.Mrang: .asciz "Variable out of range\n" +.Mset: .asciz "Err in EM set instr \n" +.Mnofp: .asciz "Floating pt not impl.\n" +.Mheap: .asciz "Heap overflow \n" + +.Mtrp: .asciz "EM trap 0000000 octal\n" -- 2.34.1