1: /
2: / APL assembly-language assist for floating-point
3: /
4:
5: .globl _fppinit, _error
6:
7: SIGFPE = 8. / signal # for flt-point exception
8: rtt = 6 / opcode for RTT instruction
9: stst = 170300^tst / "stst" opcode
10: bhs = bcc
11:
12: /
13: / Enable FPP traps and route floating-point execeptions
14: / to special handler.
15: /
16:
17: _fppinit:
18: mov r5,-(sp)
19: mov sp,r5
20: sys signal; SIGFPE; fpetrap
21: stfps r0
22: bis $7400,r0
23: ldfps r0
24: mov (sp)+,r5
25: rts pc
26:
27:
28: /
29: / Exception trap handler
30: /
31: / Attempt to figure out the reason for the floating-point
32: / exception by immediately dumping the error register.
33: / If another process generates a floating-point exception
34: / before this service routine is called, the error register
35: / will be meaningless. We just take our lumps in that case.
36: /
37:
38: fpetrap:
39: stst fpstatus / note: static allocation
40: mov r5,-(sp)
41: mov sp,r5
42: mov r1,-(sp)
43: mov r0,-(sp)
44: sys signal; SIGFPE; fpetrap
45: mov mesg,-(sp) / default message
46: mov fpstatus,r0
47: cmp r0,$nmesg
48: bhs 1f
49: add $mesg,r0 / pointer to specific message
50: mov (r0),(sp)
51: 1:
52: jsr pc, _error / print error and APL traceback
53: tst (sp)+ / "can't" ever execute this code
54: mov (sp)+,r0
55: mov (sp)+,r1
56: mov (sp)+,r5
57: rtt
58:
59: .data
60:
61: mesg: mesg0
62: mesg2
63: mesg4
64: mesg6
65: mesg8
66: mesg10
67: mesg12
68: mesg14
69: nmesg = . - mesg
70:
71: mesg0: <floating exception\0>
72: mesg2: <floating opcode error\0>
73: mesg4: <floating divide by zero\0>
74: mesg6: <floating-to-integer conversion error\0>
75: mesg8: <floating overflow\0>
76: mesg10: <floating underflow\0>
77: mesg12: <undefined floating-point variable\0>
78: mesg14: <floating-point maintenance trap\0>
79: .even
80:
81: .bss
82:
83: fpstatus: .=.+4
Defined functions
SIGFPE
defined in line
7; used 2 times
_fppinit
declared in line
5; defined in line
17; used 1 times
bhs
defined in line
10; used 1 times
Defined variables
mesg
defined in line
61; used 3 times
mesg0
defined in line
71; used 1 times
mesg2
defined in line
72; used 1 times
mesg4
defined in line
73; used 1 times
mesg6
defined in line
74; used 1 times
mesg8
defined in line
75; used 1 times
nmesg
defined in line
69; used 1 times