ack/mach/mantra/int/mloopa

485 lines
10 KiB
Plaintext
Raw Normal View History

1986-12-09 11:13:14 +00:00
.define e_memflt
.sect .text
.sect .rom
.sect .data
.sect .bss
.sect .text
1984-07-23 11:49:00 +00:00
e_array: cl -(sp) ; bra error
e_range: mov #0x1,-(sp) ; bra error
e_set: mov #0x2,-(sp) ; bra error
e_iovfl: mov #0x3,-(sp) ; bra error
e_fovfl: mov #0x4,-(sp) ; bra error
e_funfl: mov #0x5,-(sp) ; bra error
e_idivz: mov #0x6,-(sp) ; bra error
e_fdivz: mov #0x7,-(sp) ; bra error
e_iund: mov #0x8,-(sp) ; bra error
e_fund: mov #0x9,-(sp) ; bra error
e_conv: mov #0xA,-(sp) ; bra error
e_stack: mov #0x10,-(sp) ; bra fatal
e_heap: mov #0x11,-(sp) ; bra error
1984-07-23 11:49:00 +00:00
e_illins: mov #0x12,-(sp) ; bra fatal
e_oddz: mov #0x13,-(sp) ; bra fatal
e_case: mov #0x14,-(sp) ; bra fatal
1984-07-23 11:49:00 +00:00
e_memflt: mov #0x15,-(sp) ; bra fatal
e_badptr: mov #0x16,-(sp) ; bra fatal
e_badpc: mov #0x17,-(sp) ; bra fatal
e_badlae: mov #0x18,-(sp) ; bra error
e_badmon: mov #0x19,-(sp) ; bra error
e_badlin: mov #0x1A,-(sp) ; bra error
e_badgto: mov #0x1B,-(sp) ; bra error
1988-04-28 15:16:07 +00:00
flnim: bra e_illins
no8bar: bra e_oddz
1984-07-23 11:49:00 +00:00
!---------------------------------------------------------------------------
! ERRORS AND TRAPS
!----------------------------------------------------------------------------
fatal: clr.l -(sp) !dummy return address
pea hlt_z !RETURN FROM FATAL HALTS
mov 8(sp),-(sp)
error: movem.l d0/d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4/a5/a6,-(sp)
mov 60(sp),d0 !ERROR NUMBER IN d0
1987-03-31 09:23:20 +00:00
lea retsize,a1
1988-04-22 17:19:40 +00:00
move.l eb,a6 !JUST TO BE SURE
1988-07-15 11:17:17 +00:00
lea retarea,a5 !JUST TO BE SURE
lea loop,a4
1984-07-23 11:49:00 +00:00
move.l #16,d1
1987-03-31 09:23:20 +00:00
1: move.w -(a1),-(sp)
1984-07-23 11:49:00 +00:00
dbra d1,1b
cmp.w #0xB,d0
bge 0f !FATAL ERROR , START ERROR HANDLING
move.l #0x1,d1
asl.l d0,d1
move.w ignmask,d2
not.w d2
and.w d2,d1
bne 0f
move.l #16,d1
1987-03-31 09:23:20 +00:00
lea retsize,a1
1: move.w (sp)+,(a1)+
1984-07-23 11:49:00 +00:00
dbra d1,1b
movem.l (sp)+,d0/d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4/a5/a6
add.l wrd,sp !REMOVE ERROR NUMBER
rts
0: move.l uerrorp,a0
cmp.l #-1,a0
beq notrap
mov d0,-(sp)
move.l uerrorp,-(sp)
move.l #-1,uerrorp !USER MUST SET TRAP AGAIN
bra cai_z
!-----------------------------------------------------------------------------
rtt_z: move.l a2,sp
add.l #0x10,sp !REMOVE RETURN STATUS BLOCK
add.l wrd,sp !REMOVE ERROR NUMBER
move.l #16,d0
1987-03-31 09:23:20 +00:00
lea retsize,a1
1: move.w (sp)+,(a1)+
1984-07-23 11:49:00 +00:00
dbra d0,1b
movem.l (sp)+,d0/d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4/a5/a6
add.l wrd,sp
rts
trp_z: sub.l #4,sp
mov 4(sp),(sp) !COPY ERROR NUMBER
move.l a4,word(sp) !RETURN ADDRESS TO MAIN LOOP
bra error
sig_z: move.l (sp),d0
move.l uerrorp,(sp)
move.l d0,uerrorp
jmp (a4)
1986-12-09 11:13:14 +00:00
.sect .data
uerrorp: .data4 0x-1
.sect .text
1984-07-23 11:49:00 +00:00
!-----------------------------------------------------------------------------
!FIRST INFORMATION ABOUT THE KIND OF THE ERROR
notrap: add.l #38,sp
movem.l (sp)+,d1/d2/d3/d4/d5/d6/d7/a0/a1/a2/a3/a4/a5/a6
notrap1: comp #29,d0 !ERROR NUMBER STILL IN d0
blt 1f !START PRINTING ERROR
extend d0 !NUMBER.
move.l d0,d1
lea erno+5,a0
bsr itoa
move.l #609,d0
bra 2f
1984-07-23 11:49:00 +00:00
1: mulu #21,d0
2: lea emerr,a0
1984-07-23 11:49:00 +00:00
move.l #20,-(sp)
pea 0(a0,d0)
mov #2,-(sp) !STANDARD ERROR
1987-03-30 09:39:38 +00:00
bsr _Xwrite
1984-07-23 11:49:00 +00:00
add.l wrd+4,sp
!NEXT INFORMATION ABOUT THE LINE NUMBER
1987-04-06 17:59:57 +00:00
clr.l d1
mov (a6),d1
1984-07-23 11:49:00 +00:00
lea emess+14,a0
bsr itoa
move.l #30,-(sp)
pea emess
mov #2,-(sp)
1987-03-30 09:39:38 +00:00
bsr _Xwrite
1984-07-23 11:49:00 +00:00
add.l wrd+4,sp
!NOW INFORMATION ABOUT THE FILES
2: move.l 4(a6),a0
cmp.l #0,a0
beq 5f
1987-03-31 09:23:20 +00:00
move.l a0,a1
1984-07-23 11:49:00 +00:00
sub.l #4,sp
1987-03-31 09:23:20 +00:00
move.l a1,-(sp)
1984-07-23 11:49:00 +00:00
move.l #-1,d0
1: add.l #1,d0
1987-03-31 09:23:20 +00:00
tst.b (a1)+
1984-07-23 11:49:00 +00:00
bne 1b
move.l d0,4(sp)
mov #2,-(sp)
1987-03-30 09:39:38 +00:00
bsr _Xwrite
1984-07-23 11:49:00 +00:00
add.l wrd+4,sp
5: move.w #0x0A,-(sp)
move.l #2,-(sp)
pea 4(sp)
mov #2,-(sp)
1987-03-30 09:39:38 +00:00
bsr _Xwrite
1984-07-23 11:49:00 +00:00
add.l wrd+6,sp
comp #0xB,(sp)
beq 1f
move.l #-1,argc
clr.l -(sp) !dummy return address
bra hlt_z
1: add.l wrd,sp
jmp (a4)
!---------------------------------------------------------------------------
! EXIT HANDLING
!--------------------------------------------------------------------------
hlt_z: add.l #4,sp !remove return address
#if prof
1986-12-09 11:13:14 +00:00
.sect .data
1984-07-23 11:49:00 +00:00
emprof: .asciz "em_profile\0"
.align 2
1986-12-09 11:13:14 +00:00
.sect .bss
1984-07-23 11:49:00 +00:00
profile: .space 4
ltime: .space 4
profsiz: .space 4
1986-12-09 11:13:14 +00:00
.sect .text
tst.l firstp
beq lhalt
1988-05-04 16:49:58 +00:00
pea emprof
bsr _Xunlink
testen (sp)+
blt 1f
1984-07-23 11:49:00 +00:00
mov #0x1B6,-(sp)
pea emprof
1987-03-30 09:39:38 +00:00
bsr _Xcreat
1984-07-23 11:49:00 +00:00
testen (sp)+
1988-05-04 16:49:58 +00:00
blt 1f
1984-07-23 11:49:00 +00:00
mov (sp)+,d0
move.l ltime,a4 !a4 points at bottem of prof table
bsr tabprint
1988-05-04 16:49:58 +00:00
1:
1984-07-23 11:49:00 +00:00
#endif
#if flow
tst.l firstp
beq lhalt
1988-05-04 16:49:58 +00:00
pea emflow
bsr _Xunlink
testen (sp)+
blt 1f
1984-07-23 11:49:00 +00:00
mov #0x1B6,-(sp)
pea emflow
1987-03-30 09:39:38 +00:00
bsr _Xcreat
1984-07-23 11:49:00 +00:00
testen (sp)+
1988-05-04 16:49:58 +00:00
blt 1f
1984-07-23 11:49:00 +00:00
mov (sp)+,d0
move.l flowsiz,-(sp)
move.l lflow,-(sp)
mov d0,-(sp)
1987-03-30 09:39:38 +00:00
bsr _Xwrite
1988-05-04 16:49:58 +00:00
testen (sp)+
blt 1f
add.l #4,sp
1986-12-09 11:13:14 +00:00
.sect .data
1984-07-23 11:49:00 +00:00
emflow: .asciz "em_flow\0"
.align 2
1986-12-09 11:13:14 +00:00
.sect .bss
1984-07-23 11:49:00 +00:00
lflow: .space 4
flowsiz: .space 4
1986-12-09 11:13:14 +00:00
.sect .text
1988-05-04 16:49:58 +00:00
1:
1984-07-23 11:49:00 +00:00
#endif
#if count
tst.l firstp
beq lhalt
1988-05-04 16:49:58 +00:00
pea emcount
bsr _Xunlink
testen (sp)+
blt 1f
1984-07-23 11:49:00 +00:00
mov #0x1B6,-(sp)
pea emcount
1987-03-30 09:39:38 +00:00
bsr _Xcreat
1984-07-23 11:49:00 +00:00
testen (sp)+
1988-05-04 16:49:58 +00:00
blt 1f
1984-07-23 11:49:00 +00:00
mov (sp)+,d0
move.l lcount,a4
bsr tabprint
1988-05-04 16:49:58 +00:00
1:
1986-12-09 11:13:14 +00:00
.sect .data
1984-07-23 11:49:00 +00:00
emcount: .asciz "em_count\0"
.align 2
1986-12-09 11:13:14 +00:00
.sect .bss
1984-07-23 11:49:00 +00:00
lcount: .space 4
countsiz: .space 4
#endif
#if opfreq
1986-12-09 11:13:14 +00:00
.sect .data
1984-07-23 11:49:00 +00:00
emopf: .asciz "em_opfreq\0"
.align
1986-12-09 11:13:14 +00:00
.sect .bss
1988-06-06 10:30:57 +00:00
counttab: .space 1892
1986-12-09 11:13:14 +00:00
.sect .text
1988-05-04 16:49:58 +00:00
pea emopf
bsr _Xunlink
testen (sp)+
blt 1f
1984-07-23 11:49:00 +00:00
mov #0x1B6,-(sp)
pea emopf
1987-03-30 09:39:38 +00:00
bsr _Xcreat
1984-07-23 11:49:00 +00:00
testen (sp)+
1988-05-04 16:49:58 +00:00
blt 1f
1984-07-23 11:49:00 +00:00
mov (sp)+,d0
move.l #1884,-(sp)
pea counttab
mov d0,-(sp)
1987-03-30 09:39:38 +00:00
bsr _Xwrite
1988-05-04 16:49:58 +00:00
testen (sp)+
blt 1f
add.l #4,sp
1:
1984-07-23 11:49:00 +00:00
#endif
#if count+flow+prof
1986-12-09 11:13:14 +00:00
.sect .bss
1984-07-23 11:49:00 +00:00
countfld: .space 4 !COUNT NUMBER - NUMBER OF LINE 1 OF PROC
countptr: .space 4 !COUNT NUMBER OF CURRENT LINE
#endif
lhalt:
1984-07-23 11:49:00 +00:00
#if last
1986-12-09 11:13:14 +00:00
.sect .text
1988-05-04 16:49:58 +00:00
pea emlast
bsr _Xunlink
testen (sp)+
1989-04-14 18:33:56 +00:00
beq 1f
testen (sp)+ ! ignore result
1:
1984-07-23 11:49:00 +00:00
mov #0x1B6,-(sp)
pea emlast
1987-03-30 09:39:38 +00:00
bsr _Xcreat
1984-07-23 11:49:00 +00:00
testen (sp)+
1989-04-14 18:33:56 +00:00
bne halt
1984-07-23 11:49:00 +00:00
mov (sp)+,d6 !d6 contains file descriptor
cmp.l #-1,linused-4 !test if buffer is fully used
beq 0f
bsr nexttab
bra 1f
1987-03-31 09:23:20 +00:00
0: lea lasttable,a1
1: tst.l (a1)
1984-07-23 11:49:00 +00:00
bne 2f !exists entry in table
move.l #22,-(sp) !here case no lines processed
pea mess1
mov d6,-(sp)
1987-03-30 09:39:38 +00:00
bsr _Xwrite
1988-05-04 16:49:58 +00:00
testen (sp)+
1989-04-14 18:33:56 +00:00
bne halt
1988-05-04 16:49:58 +00:00
add.l #4,sp
1984-07-23 11:49:00 +00:00
bra 9f
1987-10-16 17:57:09 +00:00
2: move.l a1,-(sp)
move.l #7,-(sp) !announce new file name
1984-07-23 11:49:00 +00:00
pea mess2
mov d6,-(sp)
1987-03-30 09:39:38 +00:00
bsr _Xwrite
1988-05-04 16:49:58 +00:00
testen (sp)+
1989-04-14 18:33:56 +00:00
bne halt
1988-05-04 16:49:58 +00:00
add.l #4,sp
1987-10-16 17:57:09 +00:00
move.l (sp)+,a1
1987-03-31 09:23:20 +00:00
move.l (a1),d7
1984-07-23 11:49:00 +00:00
move.l d7,a0 !keep file pointer in d7
1987-03-31 09:23:20 +00:00
clr.l (a1)+ !this will stop the printing
1984-07-23 11:49:00 +00:00
move.l #-1,d1 !d1 will contain length of file name
3: add.l #1,d1
tst.b (a0)+
bne 3b
1987-04-02 14:04:17 +00:00
move.l a1,-(sp)
1984-07-23 11:49:00 +00:00
move.l d1,-(sp)
move.l d7,-(sp)
mov d6,-(sp)
1987-03-30 09:39:38 +00:00
bsr _Xwrite
1989-04-14 18:33:56 +00:00
testen (sp)+
bne halt
add.l #4,sp
1987-04-02 14:04:17 +00:00
move.l (sp)+,a1
1987-03-31 09:23:20 +00:00
4: move.l (a1),d1 !next print line numbers
1984-07-23 11:49:00 +00:00
lea mess3,a0
bsr itoa
1987-04-02 14:04:17 +00:00
move.l a1,-(sp)
1984-07-23 11:49:00 +00:00
move.l #12,-(sp)
pea mess3
mov d6,-(sp)
1987-03-30 09:39:38 +00:00
bsr _Xwrite
1988-05-04 16:49:58 +00:00
testen (sp)+
1989-04-14 18:33:56 +00:00
bne halt
1988-05-04 16:49:58 +00:00
add.l #4,sp
1987-04-02 14:04:17 +00:00
move.l (sp)+,a1
1984-07-23 11:49:00 +00:00
bsr nexttab
1987-03-31 09:23:20 +00:00
tst.l (a1) !in case 0 no more lines
1984-07-23 11:49:00 +00:00
beq 9f
1987-03-31 09:23:20 +00:00
cmp.l (a1),d7
1984-07-23 11:49:00 +00:00
bne 2b !new file name
1987-03-31 09:23:20 +00:00
clr.l (a1)+ !skip file name
1984-07-23 11:49:00 +00:00
bra 4b !only new line
9:
1989-04-14 18:33:56 +00:00
clr.l -(sp)
1986-12-09 11:13:14 +00:00
.sect .data
1984-07-23 11:49:00 +00:00
emlast: .asciz "em_last"
mess1: .asciz "no line processed yet\n"
mess2: .asciz "\nfile :"
mess3: .asciz " \n"
.align 2
1986-12-09 11:13:14 +00:00
.sect .bss
lasttable: .space 512
1984-07-23 11:49:00 +00:00
linused: .space 4
#endif
1986-12-09 11:13:14 +00:00
.sect .text
1987-03-30 09:39:38 +00:00
halt: bsr _Xexit
1984-07-23 11:49:00 +00:00
1986-12-09 11:13:14 +00:00
.sect .data
1984-07-23 11:49:00 +00:00
emerr:
.asciz "ARRAY BOUND ERROR \n"
.asciz "RANGE BOUND ERROR \n"
.asciz "SET BOUND ERROR \n"
.asciz "INTEGER OVERFLOW \n"
.asciz "FLOATING OVERFLOW \n"
.asciz "FLOATING UNDERFLOW \n"
.asciz "INT. DIV. BY ZERO \n"
.asciz "DIVIDE BY 0.0 \n"
.asciz "UNDEFINED INTEGER \n"
.asciz "UNDEFINED FLOAT \n"
.asciz "CONVERSION ERROR \n"
.asciz "NO FLOATING POINT \n"
.asciz "NO 8 BYTE ARITH. \n"
.asciz "NO LOAD FILE \n"
.asciz "LOAD FILE ERROR \n"
.asciz "PROGRAM TOO LARGE \n"
.asciz "STACK OVERFLOW \n"
.asciz "HEAP OVERFLOW \n"
.asciz "ILLEGAL INSTRUCTION\n"
.asciz "ILLEGAL SIZE ARG. \n"
.asciz "CASE ERROR \n"
.asciz "ADDRESS NON EX. MEM\n"
.asciz "BAD POINTER USED \n"
.asciz "PR COUNT. OUT RANGE\n"
.asciz "BAD ARG. OF LAE \n"
.asciz "BAD MONITOR CALL \n"
.asciz "ARG OF LIN TOO HIGH\n"
.asciz "GTO DESCR. ERROR \n"
.asciz "BAD RETURN SIZE \n"
erno:
.asciz "ERRNO \n"
1984-07-23 11:49:00 +00:00
emess:
.asciz "ON SOURCE LINE OF\n"
.align 2
!-----------------------------------------------------------------------------
! SUBROUTINES FOR THE INTERPRETOR
!------------------------------------------------------------------------------
1986-12-09 11:13:14 +00:00
.sect .text
1984-07-23 11:49:00 +00:00
#if last
1987-03-31 09:23:20 +00:00
nexttab: move.l linused,a1
add.l #8,a1
cmp.l #linused,a1 !top of buffer reached?
1984-07-23 11:49:00 +00:00
bne 1f !if so back to bottom
1987-03-31 09:23:20 +00:00
sub.l #512,a1
1: move.l a1,linused
1984-07-23 11:49:00 +00:00
rts
#endif
#if count+prof
!SUBROUTINE FOR PRINTING TABLES . EXPECTS BOTTOM OF TABLE IN a4 AND FILE
!DESCRIPTOR IN d0 .IN maxcount NUMBER OF 4 BYTE WORDS IN THE TABLE.
1986-12-09 11:13:14 +00:00
.sect .text
tabprint: mov d0,-(sp) !KEEP FILE DESCRIPTOR FOR WRITING
lea buffer,a3
1987-03-31 09:23:20 +00:00
move.l firstp,a1 !IN a1 POINTER TO CURRENT PROC.
move.l #0,a2 !IN a2 POINTER TO FILENAME .
1987-03-31 09:23:20 +00:00
2: move.l 16(a1),d0
beq 9f !LAST PROCEDURE , EXCEPTION .
move.l d0,a6 !IN a6 POINTER TO NEXT PROCEDURE .
7: move.l 8(a6),d7 !COUNTPTR OF NEXT IN d7
bne 8f
move.l 16(a6),d0
beq 9f
move.l d0,a6
bra 7b
1987-03-31 09:23:20 +00:00
8: move.l 8(a1),d6 !COUNTPTR OF CURRENT IN d6.
move.l 12(a1),d5 !FIRST LINE NUMBER IN d5.
beq 1f !NO LINES : GO ON.
1987-03-31 09:23:20 +00:00
cmp.l 20(a1),a2 !START PRINTING FILE NAME .
beq 6f !NO NEW NAME.
1987-03-31 09:23:20 +00:00
move.l 20(a1),a2 !NEW FILE NAME.
cmp.l #0,a2 !NO FILE NAME .
beq 6f
move.l #0,d1 !START SCANNING FILE NAME
5: move.b (a2),d0 !d1 WILL CONTAIN NUMBER OF SYMBOLS.
beq 4f
add.l #1,d1
add.l #1,a2
bra 5b
4: sub.l d1,a2
move.l d1,-(sp)
move.l a2,-(sp)
mov 8(sp),-(sp) !WRITE FILE NAME.
1987-03-30 09:39:38 +00:00
bsr _Xwrite
1988-05-04 16:49:58 +00:00
testen (sp)+
blt 3f
add.l #4,sp !CLEAN STACK.
6: sub.l d6,d7 !IN d7 NUMBER OF LINES OF CURRENT PROC.
asl.l #2,d6
0: move.l a3,a0
move.l d5,d1 !SET UP FOR CALLING itoa.
bsr itoa
lea 11(a3),a0
move.l 0(a4,d6),d1
bsr itoa
move.l #23,-(sp)
pea buffer
mov 8(sp),-(sp)
1987-03-30 09:39:38 +00:00
bsr _Xwrite !PRINT LINE NUMBER AND INTEGER .
1988-05-04 16:49:58 +00:00
testen (sp)+
blt 3f
add.l #4,sp !CLEAN STACK.
add.l #1,d5 !NEXT LINE NUMBER .
add.l #4,d6 !NEXT COUNT.
sub.l #1,d7 !ONE LINE LESS TO GO.
bhi 0b
1987-03-31 09:23:20 +00:00
1: move.l a6,a1
cmp.l #0,a1
bne 2b
add.l wrd,sp !REMOVE FILE DESCR.
rts !READY.
9: move.l maxcount,d7
move.l #0,a6 !NO NEXT PROCEDURE.
bra 8b
1988-05-04 16:49:58 +00:00
3:
testen (sp)+
testen (sp)+
rts
1986-12-09 11:13:14 +00:00
.sect .data
buffer: .asciz " \n"
1986-12-09 11:13:14 +00:00
.sect .text
#endif