Home » Archimedes archive » Zipped Apps » BCPL » BCPL/armlib/a/mclibr

BCPL/armlib/a/mclibr

This website contains an archive of files for the Acorn Electron, BBC Micro, Acorn Archimedes, Commodore 16 and Commodore 64 computers, which Dominic Ford has rescued from his private collection of floppy disks and cassettes.

Some of these files were originally commercial releases in the 1980s and 1990s, but they are now widely available online. I assume that copyright over them is no longer being asserted. If you own the copyright and would like files to be removed, please contact me.

Tape/disk: Home » Archimedes archive » Zipped Apps » BCPL
Filename: BCPL/armlib/a/mclibr
Read OK:
File size: AEB1 bytes
Load address: 0000
Exec address: 0000
File contents
;*******************-*- Mode: Assembler -*-****************************
;*  Title:	BCPL system library				      *
;*  Author:	Harry Meekings					      *
;*  Lastedit:	20 Nov 89 16:42:44 by Harry Meekings		      *
;*		Copyright (c) 1986 by Acorn Computers Ltd	      *
;**********************************************************************

; This is the source of the main assembler part of the BCPL library.  It
; is linked to by the files which are used to make various versions of the
; library, namely  MCLibAR  to make the 'normal' version
;		   MCLibA   to make the aof version
;		   MCLibLR  to make the Lisp version.
; Do NOT try assembling this file on its own.

LibraryMajorVersion * 1
LibraryMinorVersion * 8

r1		RN	1
r2		RN	2
r3		RN	3
r4		RN	4
r5		RN	5
r6		RN	6
r7		RN	7
r13		RN	13
r11		RN	11
r12		RN	12

		GET $.ALib.Headers.Brazil
		GET $.ALib.Headers.Errors

; co-routine stuff kept at the base of a stack

cb_next 	*	0*4*StackDirn
cb_caller	*	1*4*StackDirn
cb_stackend	*	2*4*StackDirn
cb_resume_rp	*	4*4*StackDirn
cb_fn		*	5*4*StackDirn
cb_real_stack	*	6*4*StackDirn

Start		GlobNo	1
hostProcessor	GlobNo	2
result2 	GlobNo	13
lineBuff	GlobNo	17
cis		GlobNo	31
cos		GlobNo	32
returnCode	GlobNo	39
stackBase	GlobNo	40
blockList	GlobNo	57
randomState	GlobNo	89
loadPoint	GlobNo	142
vduStream	GlobNo	144
errorStream	GlobNo	145
streamChain	GlobNo	146
topOfStore	GlobNo	148

BinRdCh 	GlobNo	44
BinWrCh 	GlobNo	45
Abort		GlobNo	63
Fault		GlobNo	95
LibInitIO	GlobNo	111
LibTerminateIO	GlobNo	143

 [ aof
	AREA	|BCPL$$Codf|, CODE, READONLY
	; to follow just after the bcpl code.
	&	1002

; Standard BCPL header ...
	Module	SysLib,"22 Feb 88 13:37:16"
 |
CodeStart
	B	LibraryInit

; Standard BCPL header ...
	Module	SysLib,"22 Feb 88 13:37:16"
 ]

LocalDataP
	Address localData
	&	-1
	=	7, "Initial"

 [ :LNOT:aof
relocated
	Address Start	; this tells me whether we are being rerun
			; (if so, it has the base of this section added)
 ]
 [ lispmode=1
 ; these things (which are a table of addresses to go to
 ; on dereference errors) get copied on startup to sit at
 ; small negative offsets from RG.
Xcar_init
	Address xrplacw2_a4
	Address xrplacw2_a1
	Address xrplacw2_a2
	Address xrplacw2_a3
	Address xrplacw2_w1
	Address xrplacw2_w2

	Address xrplacw1_a4
	Address xrplacw1_a1
	Address xrplacw1_a2
	Address xrplacw1_a3
	Address xrplacw1_w1
	Address xrplacw1_w2

	Address xrplacd_a4
	Address xrplacd_a1
	Address xrplacd_a2
	Address xrplacd_a3
	Address xrplacd_w1
	Address xrplacd_w2

	Address xrplaca_a4
	Address xrplaca_a1
	Address xrplaca_a2
	Address xrplaca_a3
	Address xrplaca_w1
	Address xrplaca_w2

	Address xcdr_a4
	Address xcdr_a1
	Address xcdr_a2
	Address xcdr_a3
	Address xcdr_w1
	Address xcdr_w2

	Address xcar_a4
	Address xcar_a1
	Address xcar_a2
	Address xcar_a3
	Address xcar_w1
	Address xcar_w2
Xcar_init_end
 ]

 [ aof
	ENTRY
 ]
LibraryInit
 ; first pass through the BCPL sections present determines
 ; the highest referenced global.
 [ aof
	LDR	rb, =|BCPL$$Code$$Limit|
	LDR	r1, =|BCPL$$Code$$Base|
 |
	LDR	rb, relocated
	ADR	r1, Start
 ]
	MOV	r5, #150
	LDR	r4, [r1, #0]	; magic constant to identify BCPL
nextmodule
	MOV	r6, r1
	LDMIA	r1, {r2, r3}
	CMPS	r2, r4
	BNE	endinit 	; not BCPL
 [ aof
	CMP	r1, rb
	BGE	endinit
 ]
	ADD	r1, r3, r1	; start of global initialisations
nextinit
	LDMFD	r1!, {r2, r3}
	CMPS	r3, #0
	BNE	nextinit
 ; that's that module finished
 ; Now a temporary fix until we have a linkage editor.
 ; At the end of each compiled module (after the global
 ; initialisations) there is a table, started with
 ; &12345678 and terminated with &87654321, of the offsets
 ; in the module which require the module base adding in.
 ; This must be done in the first pass, because global
 ; initialisations are values which need relocating
	CMPS	r2, r5
	MOVGE	r5, r2
 [ :LNOT:aof
	LDR	r3, [r1, #0]
	LDR	r2, relocstart
	CMPS	r2, r3
	BNE	nextmodule
	LDR	r2, relocend
	ADD	r1, r1, #4
	CMPS	rb, #0		; the assumption is
	BNE	dont_relocate	; that we are being re-run
nx1
	LDMFD	r1!, {r3}
	CMPS	r3, r2
	LDRNE	r0, [r3, r6]
	ADDNE	r0, r0, r6
	STRNE	r0, [r3, r6]
	BNE	nx1
	B	nextmodule

dont_relocate
	LDMFD	r1!, {r3}
	CMPS	r3, r2
	BNE	dont_relocate
 ]
	B	nextmodule

endinit
 ; Now r1 is the end of code, and r5+1 the number of
 ; globals required.  The global vector gets allocated
 ; at r1+64, leaving some workspace locations below rg.
 ; The stack then goes immediately above the global vector.
 [ aof
	LDR	r1, =|Image$$DataLimit|
 ]
	ADD	rg, r1, #64
 [ lispmode=1
	ADD	rg, rg, #Xcar_init_end-Xcar_init
	ADR	r2, Xcar_init
	ADR	r3, Xcar_init_end
Xcar_loop
	LDR	r0, [r2],#+4
	STR	r0, [r1,#+4]!
	CMPS	r2, r3
	BNE	Xcar_loop
 ]
	ADD	rp, rg, r5, ASL #2
	ADD	rp, rp, #4
	STR	r5, [rg, #0]	; global 0 = max global
clear
	MOV	r6, #&ae000000
	ADD	r6, r6, #&950000
	ADD	r6, r6, r5, ASL #2
	STR	r6, [rg, r5, ASL #2]
	SUBS	r5, r5, #1
	BNE	clear

 ; second pass through BCPL code, filling in global
 ; initialisations.

 [ aof
	LDR	r1, =|BCPL$$Code$$Base|
 |
	ADR	r1, Start
 ]
nextm2
	LDMFD	r1, {r2, r3}
	CMPS	r2, r4
	BNE	endi2		; not BCPL
 [ aof
	CMP	r1, rb
	BGE	endi2
 ]
	ADD	r1, r3, r1	; start of initialisations
nexti2
	LDMFD	r1!, {r2, r3}	; next (gno, addr) pair
	CMPS	r3, #0
	STRNE	r3, [rg, r2, ASL #2]
	BNE	nexti2
 ; that's that module finished.
 ; temporary fix again - step over the relocation words.
 [ :LNOT:aof
	LDR	r3, [r1, #0]
	LDR	r2, relocstart
	CMPS	r2, r3
	BNE	nextm2
	LDR	r2, relocend
nx2	LDMFD	r1!, {r3}
	CMPS	r3, r2
	BNE	nx2
 ]
	B	nextm2
endi2

; I have for the moment abandoned here the pretence of support
; for downward-growing stacks
	LDR	rl, LocalDataP
	SWI	GetEnv			; top of store + 1 in r1
	STR	r1, [rg, #G_topOfStore]

	MOV	r0, rp, LSR #2
	STR	r0, [rg, #G_blockList]
	MOV	r2, #RootStackSize	 ; simulate a GetVec
	RSB	r2, r2, #0
	STR	r2, [rp]
	SUB	r3, rp, r2, ASL #2	 ; stack top +4 (a hw address)
 [ StackDirn=1
	ADD	rp, rp, #4
 |
	MOV	r0, r3
	SUB	rp, r3, #4
	MOV	r3, r0
 ]
	MOV	r0, rp, LSR #2
	STR	r0, [rg, #G_stackBase]
	MOV	r0, #0		; co-routine stuff : next
	MVN	r2, #0		; caller=-1 => root
	MOV	r4, r3, LSR #2	; stackend (as BCPL address)
	SUB	r4, r4, #1
 [ StackDirn=1
	STMIA	rp, {r0, r2, r4}
 |
	STMDA	rp, {r0, r2, r4}
 ]
	MVN	r2, #0
	STR	r2, [rp, #cb_fn]
	ADD	rp, rp, #cb_real_stack
	MOV	rts, rp

	SUB	r2, r1, #8	; highest (hw) address in heap
	SUB	r1, r2, r3	; free heap size in bytes
	MOV	r1, r1, LSR #2	;  ...........	 in BCPL words
	MOV	r0, r3, LSR #2
	STR	r0, [rl, #O_freeHeapChain]
	STR	r1, [r3]
	MOV	r4, #0
	STR	r4, [r3, r1, ASL #2]
	MOV	r2, r2, LSR #2
	STR	r2, [r3, #4]	; heap free chain (BCPL pointer)
	STR	r4, [rg, #G_lineBuff]
	STR	r4, [rg, #G_streamChain]
	OSbyte	0, 1		; host OS
	MOV	r1, r1, ASL #24
	ADD	r1, r1, #"A"
	STR	r1, [rg, #8]
	; Find out where the abort handlers currently are to determine whether
	; they should be set.  If their top byte is non-zero, then we are not
	; running under a debugger, and should install handlers (but only if we
	; have an Abort procedure).
	MOV	r0, #0
	MOV	r1, #0
	MOV	r2, #0
	MVN	r3, #1
	MOV	r4, #0
	MOV	r5, #0
	MOV	r6, #0
	MOV	r7, #0
	SWI	SetEnv

	MOV	rb, #0
	STR	rb, [rg, #G_returnCode]
	ADD	r0, rl, #O_oldAbortHandlers
	STMIA	r0, {r4-r7}
	ADD	r0, rl, #O_myAbortHandlers
	STMIA	r0, {r4-r7}
	LDR	r0, [rg, #G_Abort] ; set an abort handler only if there's
	MOV	r1, #&ae00	   ; a BCPL procedure for it to call
	ADD	r1, r1, #&95
	CMP	r1, r0, LSR #16
	BEQ	LeaveAbortHandlers
	MOV	r0, r4, LSR #24
	CMP	r0, #0
 B LeaveAbortHandlers
;	 BEQ	 LeaveAbortHandlers ; non-default

	ADR	r4, undef	   ; abort handlers
	ADR	r5, pref
	ADR	r6, dataab
	ADR	r7, addrex
	ADD	r0, rl, #O_myAbortHandlers
	STMIA	r0, {r4-r7}
	MOV	r0, #0
	MOV	r1, #0
	SWI	SetEnv
	MOV	rb, #1

LeaveAbortHandlers
	STR	rb, [rl, #O_beingDebugged]
	MOV	r0, #-2
	STR	r0, [rl, #O_eventHandlers]

	ADD	r0, rl, #O_regDump
	ADR	r1, CallBackHandler
	SWI	CallBack
	ADD	r2, rl, #O_oldCallBackRegisters
	STMIA	r2, {r0, r1}

	MOV	r0, #0
	STR	r0, [rl, #O_errorString]
	ADR	r0, ErrorHandler
	ADD	r1, rl, #O_errorBuffer
	ADR	r2, EscapeHandler
	ADR	r3, EventHandler
	SWI	Control
	ADD	r4, rl, #O_oldErrorHandler
	STMIA	r4, {r0-r3}

	; To keep Arthur happy, make sure callback is always used for
	; the acknowledgement of escape events
	MOV	r0, #9
	MOV	r1, #0
	MOV	r2, #-1
	SWI	64

 [ aof
	LDR	r0, =|BCPL$$Code$$Base|
 |
	ADR	r0, Start
 ]
	MOV	r0, r0, LSR #2
	STR	r0, [rg, #G_loadPoint]
	LDR	rgb, GlobsP
	ADD	rgb, rgb, #&40000000  ; that is the Z PSR bit
	LDR	rb, [rg, #G_LibInitIO]
	BL	CallGlob

	; rest of command line goes into the tty buffer
	SWI	EnterSVC
	SWI	GetEnv
	LDR	r2, [rg, #G_lineBuff]
	MOV	r2, r2, ASL #2
	MOV	r4, r2
	ADD	r2, r2, #3	; real buffer start
	LDRB	rb, [r4, #0]	; size of buffer
	ADD	rb, r2, rb	; pointer to end

cl1	CMPS	r2, rb
	BGE	cl3
	LDRB	r5, [r0], #1	; copy over
	STRB	r5, [r2], #1
	CMPS	r5, #0
	BNE	cl1

cl3	MOV	r5, #10 	; put in terminating newline
	STRB	r5, [r2, #-1]
	ADD	r1, r4, #3	; look for first space

cl2	LDRB	r5, [r1], #1
	CMPS	r5, #" "
	CMPNES	r5, #10
	BNE	cl2

	CMPS	r5, #10 	; if we found a newline (ie no args)
	SUBEQ	r1, r1, #1	; leave it for the decoder
	SUB	r2, r2, r1	; length of remainder
	STRB	r2, [r4, #2]
	SUB	r1, r1, r4
	SUB	r1, r1, #3	; offset of next char
	STRB	r1, [r4, #1]
	TEQP	pc, #0

	LDR	rb, [rg, #G_Start]
	BL	CallGlob

WindUp
	MOV	rts, rp
	LDR	rb, [rg, #G_LibTerminateIO]
	BL	CallGlob

	LDR	rl, LocalDataP
	ADD	r0, rl, #O_oldAbortHandlers
	LDMIA	r0, {r4 - r7}
	MOV	r0, #0
	MOV	r1, #0
	MOV	r2, #0
	MVN	r3, #1
	SWI	SetEnv

	ADD	r0, rl, #O_oldCallBackRegisters
	LDMIA	r0, {r0, r1}
	SWI	CallBack

	ADD	r0, rl, #O_oldErrorHandler
	LDMIA	r0, {r0-r3}
	SWI	Control

	LDR	r2, [rg, #G_returnCode]
	CMP	r2, #0
	LDRNE	r1, ABEXString
	SWI	Exit

ABEXString
	=	"ABEX"

	LTORG
GlobsP
	Address Globs

	&	-1
	=	7, "ErrHand"

ErrorHandler
	SWI	EnterSVC
	STMFD	r13!, {r0}
	LDR	r14, LocalDataP
	LDR	r0, [r14, #O_errorNumber]
	TST	r0, #&80000000
	LDREQ	r14, [r14, #O_errorBuffer]
	RSBEQ	r0, r0, #0
	ADDEQ	r13, r13, #4
	ORREQS	pc, r14, #OverflowBit

; Fatal error (eg FP fault or branch through zero)
	LDR	r0, [r14, #O_beingDebugged]
	CMP	r0, #0
	BNE	EnterAbort
	LDMFD	r13!, {r0}
	STMFD	r13, {r0, r1, r2}
	LDR	r0, [r14, #O_oldErrorBuffer]
	LDR	r1, [r14, #O_errorBuffer]
	STR	r1, [r0], #+4
	LDR	r1, [r14, #O_errorNumber]
	STR	r1, [r0], #+4
	ADD	r2, r14, #O_errorString
01	LDRB	r1, [r2], #+1
	STRB	r1, [r0], #+1
	CMP	r1, #0
	BNE	%B01
	LDMFD	r13!, {r0, r1, r2}
	LDR	pc, [r14, #O_oldErrorHandler]

EnterAbort
	ADD	r0, r14, #O_regDump
	STMIB	r0, {r1-r14}^
	LDMFD	r13!, {r0}
	STR	r0, [r14, #O_regDump]
	LDR	r1, [r14, #O_errorNumber]
	LDR	r2, [r14, #O_errorBuffer]
	B	abortedCallAbort

EscapeHandler	; make this look somewhat like an event
	TSTS	r11, #&40
	MOVEQ	pc, r14 	; ignore flag going away
	STMFD	r13!, {r0, r1, r2, r14}
	CMPS	r12, #0 	; if it is safe to do so now
	MOVEQ	r0, #&7e	; acknowledge the escape
	SWIEQ	Byte		; (otherwise have to wait until callback)
	MOV	r0, #-1
	MOV	r1, r11
	BL	EventHandler
	LDMFD	r13!, {r0, r1, r2, r14}
	CMPS	r12, #0
	MOVNE	r12, #1
	MOV	pc, r14

	&	-1
	=	7, "EvHandl"

EventHandler

	LDR	r11, LocalDataP
	ADD	r11, r11, #O_eventHandlers
	STMFD	r13!, {r1}
01	LDR	r1, [r11], #+12
	CMP	r1, r0
	CMPNE	r1, #-2
	BNE	%B01
	CMP	r1, #-2
	LDMFD	r13!, {r1}
	LDREQ	r11, LocalDataP
	LDREQ	pc, [r11, #O_oldEventHandler]
	LDR	pc, [r11, #-8]

update_flag
	LDR	r11, [r11, #-4]
	MOV	r0, r0, ASL #16
	ORR	r0, r0, r1, ASL #8
	ORR	r0, r0, r2
	ORR	r0, r0, #&80000000
	STR	r0, [r11]
return_code
	MOV	pc, r14

buffer_events
	LDR	r11, [r11, #-4]
	MOV	r0, r0, ASL #16
	ORR	r0, r0, r1, ASL #8
	ORR	r0, r0, r2
	LDMIA	r11!, {r1, r2, r12}
	STR	r0, [r12, r1, ASL #2]
	ADD	r1, r1, #1
	CMPS	r1, r12
	MOVEQ	r1, #0
	CMPS	r1, r2
	STRNE	r1, [r11, #-12]
	MOV	r12, #0 		; don't want callback
	MOV	pc, r14

	&	-1
	=	7, "CBHandl"

CallBackHandler
	; at the moment, this is only ever called after an escape
	; update event.  When I work out an interface, I should be
	; prepared to call a user procedure (of which there may of
	; course be many)

	LDR	r12, LocalDataP
	LDR	r14, [r12, #O_regDump+60]  ; user's pc value
	; proceed with the callback only if the SVC we were in was called
	; from user mode
	TSTS	r14, #3
	BEQ	EscCallBack2

	; Otherwise, reinstate the callback flag and resume the SVC.
	; Eventually, we will get called back on a return to user mode.
	MOV	r1, r14
	SWI	SetCallBack
	MOV	r14, r1
	LDMIA	r0, {r0 - r12}
	MOVS	pc, r14

EscCallBack2
	TEQP	pc, #0
	OSbyte	&7e		; acknowledge the escape
	ADD	r0, r12, #O_regDump
	LDMIA	r0, {r0-pc}^

 GlobDef 112,SetEventHandler

	LDR	rb, LocalDataP
	ADD	w2, rb, #O_eventHandlers
01	LDR	r0, [w2], #+12
	CMP	r0, a1
	CMPNE	r0, #-2
	BNE	%B01

	CMPS	a3, #ev_ignore
	BEQ	RemoveHandler

	ADD	w1, rb, #O_endEventHandlers
	CMP	w2, w1
	MOVGT	a1, #-1
	MOVGTS	pc, r14

	MOV	w1, a2, ASL #2
	CMP	a3, #ev_set_flag
	ADREQ	a2, update_flag
	CMP	a3, #ev_buffer
	ADREQ	a2, buffer_events
	STMDB	w2, {a1, a2, w1}
	CMP	r0, #-2
	STREQ	r0, [w2]
	MOVS	pc, r14


RemoveHandler
	CMP	r0, #-2
	MOVEQS	pc, r14
01	LDMIA	w2, {a1-a3}
	STMDB	w2, {a1-a3}
	ADD	w1, w1, #12
	CMP	a1, #-2
	BNE	%B01
	MOVS	pc, r14


undef	STMFD	r13!, {r14}
	MOV	r14, #Error_IllegalInstruction
	B	aborted

pref	STMFD	r13!, {r14}
	MOV	r14, #Error_PrefetchAbort
	B	aborted

dataab	STMFD	r13!, {r14}
	MOV	r14, #Error_DataAbort
	B	aborted

addrex	STMFD	r13!, {r14}
	MOV	r14, #Error_AddressException
	B	aborted

aborted
; entry here in SVC mode,  r14 set to the type of abort
; all user registers are as at the time of the abort.
; We fabricate a call from the point of the error to ABORT,
; lifting the stack a bit to allow for death at unfortunate
; times.  We assume that rp and rg have not been too badly savaged.
	STMFD	r13!, {r14}
	LDR	r14, LocalDataP
	ADD	r14, r14, #O_regDump
	STMIA	r14, {r0-r14}^
	LDMFD	r13!, {r1, r2}
abortedCallAbort
	TSTP	pc, #0			; back to user mode
	LDR	rgb, GlobsP		; in case destroyed
	ADD	rgb, rgb, #&40000000	; (that is the Z PSR bit)
	ADD	rts, rp, #200		; ignore what it was (?)
	LDR	rb, [rg, #G_Abort]
	MOV	r14, r2 		; the place of the fault (unadjusted)
	MOV	pc, rb

 GlobDef 35,Stop

	STR	a1, [rg, #G_returnCode]
	LDR	a3, [rg, #G_stackBase]
	MOV	a3, a3, ASL #2
	LDR	a2, [a3, #cb_caller]
	ADD	rp, a3, #cb_real_stack
	CMN	a2, #1		; if current coroutine is root,
	BEQ	WindUp		; terminate completely
	B	CreateCo2

 GlobDef 101,OSCLI

 ; oscli command
 ; command is a BCPL string (so needs conversion)
 ; Returns False if the command fails, True otherwise
 ; If the base of this program is not 1000, then it
 ; tries to run the command as a sub-program.

	STMEA	rts!, {r14}
	MOV	r1, a1, ASL #2
	MOV	r2, #0
	BL	crterm
	LDR	r0, =BaseAddress*2
	SUBS	r5, pc, r0
	MOV	r0, r1
	BLE	oscli_no_subp

osclix	STMEA	rts!, {r0, r2 - r4, r6, r7, rg}

	ADR	r0, oscli_exit
	ADD	r1, r5, #BaseAddress	; new memory limit
	MOV	r2, #0			; no change to real memory end
	MVN	r3, #1			;	    or local buffering
	LDR	r14, LocalDataP 	; reset abort handlers to initial set
	ADD	r4, r14, #O_oldAbortHandlers
	LDMIA	r4, {r4-r7}
	SWI	SetEnv

	ADD	r5, r14, #O_cliEnvSave
	STMIA	r5!, {r0 - r3}
	LDMEA	rts!, {r6, r7, rg}

	ADD	r0, r14, #O_oldCallBackRegisters
	LDMIA	r0, {r0, r1}
	SWI	CallBack

	MOV	r1, #0		; leave the error buffer
	ADR	r0, ErrorInCLI	; and insert a new error handler
	LDR	r2, [r14, #O_oldEscapeHandler]
	MOV	r3, #0		; leave my event handler in
	SWI	Control

	LDMEA	rts!, {r0, r2 - r4}
	STMIA	r5!, {r1 - r13}
	SWI	CLI
	MOVVC	r0, #-1
	MOVVS	r0, #0
	B	oscli_exit_2

oscli_exit
	MOV	r0, #-1
oscli_exit_2
	TSTP	pc, #0
	LDR	r14, LocalDataP
	STR	r0, [r14, #O_cliStatus]
	ADD	r5, r14, #O_cliR1ToR13Save
	LDMIA	r5, {r1 - r13}
	STMEA	rts!, {r2 - r4, r6, r7}

	ADD	r5, r14, #O_cliEnvSave
	LDMIA	r5!, {r0 - r3}
	ADD	r4, r14, #O_myAbortHandlers
	LDMIA	r4, {r4 - r7}
	SWI	SetEnv

	ADD	r0, r14, #O_regDump
	ADR	r1, CallBackHandler
	SWI	CallBack

	ADR	r0, ErrorHandler
	ADD	r1, r14, #O_errorBuffer
	ADR	r2, EscapeHandler
	ADR	r3, EventHandler
	SWI	Control

	; To keep Arthur happy, make sure callback is always used for
	; the acknowledgement of escape events
	MOV	r0, #9
	MOV	r1, #0
	MOV	r2, #-1
	SWI	64

	LDMEA	rts!, {r2 - r4, r6, r7}
	LDR	r0, [r14, #O_cliStatus]
	B	afterosf

oscli_no_subp
	SWI	CLI
	MOVVC	r0, #-1
	MOVVS	r0, #0
	B	afterosf

ErrorInCLI
	MOV	r0, #0
	B	oscli_exit_2

	&	-1
	=	7, "Call   "

CallGlob
	MOV	pc, rb

relocstart & &12345678
relocend & &87654321

 [ lispmode=1
LispEntryCount
; fixed offset	-&  from Globs
 ; profile counts of procedure entry.
 ; called by  jump  as first instruction of function
 ; followed by full-word count to increment.
 ; No registers have been saved: this routine does
 ; that.  Return is to	rb+8  (ie the instruction after
 ; the count).
	STMEA	rts!, {r14, rb, rl, rp}
	SUB	rp, rts, #16
	BIC	r14, rb, #&ff000000
	LDR	r0, [r14, #4]
	ADD	r0, r0, #1
	STR	r0, [r14, #4]
	ADD	pc, rb, #8

; Blink and Bexit are entry and exit sequences for small
; subroutines created by the block compiler from spotting
; identical pieces of code.  The subroutines presumably may
; not do much (no test for garbage collection in the call
; sequence).  The call adds a link to the top of the current
; stack frame (made relative to the block base so garbage
; collection needn't worry about it).  Note that the link has
; its top 8 bits removed, so calls of such routines must be
; executed conditionally only if they are the last things that
; are.
; On entry to both of the sequences, rb must be loaded with the
; address of the base of the block.

Blink	BIC	w2, r14, #P_key
	LDR	w1, [w2], #+4
	SUB	w2, w2, rb
	BIC	w2, w2, #P_key
	STMEA	rts!, {w2}
	ADD	pc, rb, w1

BExit	LDMEA	rts!, {r14}
	ADD	pc, r14, rb

	BCall	0
	BCall	1
	BCall	2
	BCall	3

	XCall	N
	XCall	3
	XCall	2
	XCall	1
	XCall	0

	CallN	FN
	CallN	N

	Call	F
	Call	L
	Call	3
	Call	2
	Call	1
	Call	0
 ]

Globs
	B	WindUp

 [ aof
	EXPORT	|SysLib._Mult|
|SysLib._Mult|
 ]
itimes
; fixed offset	&4  from Globs
 ; 32 * 32 bit multiply -> 32 bits: no overflow detection
 ; arguments in a1 and a2; result in a1 with a2 destroyed
 ; other registers preserved
 ; uses globals -1 & -2 as workspace
	STMDB	rg, {w1, r14}
	MOV	w1, #0
	MOVS	r14, a2
	RSBMI	r14, r14, #0
10	MOVS	r14, r14, LSR #1
	ADDCS	w1, w1, a1
	MOV	a1, a1, ASL #1
	BNE	%10
	MOV	a1, w1
	TEQS	a2, #0
	RSBMI	a1, a1, #0
	LDMDB	rg, {w1, pc}^

 [ aof
	EXPORT	|SysLib._QuotRem|
|SysLib._QuotRem|
 ]
quotrem
; fixed offset	&34  from Globs
 ; 32 bit divide
 ; dividend in a1, divisor in a2
 ; quotient returned in a1, remainder in a2
 ; other registers preserved
 ; uses globals -1 to -4 inclusive as workspace
	STMDB	rg, {a3, a4, w2, r14}
	MOVS	r14, a1
	RSBMI	r14, r14, #0
	MOVS	a3, a2
	BEQ	divideby0
	RSBMI	a3, a3, #0
	MOV	a4, #0
	MOV	w2, #1
11	CMPS	a3, #&80000000
	CMPCCS	a3, r14
	MOVCC	a3, a3, ASL #1
	MOVCC	w2, w2, ASL #1
	BCC	%11

12	CMPS	a3, r14
	ADDLS	a4, a4, w2
	SUBLS	r14, r14, a3
	MOVS	w2, w2, LSR #1
	MOVNE	a3, a3, LSR #1
	BNE	%12

	TEQS	a1, a2
	RSBMI	a4, a4, #0
	CMPS	a1, #0
	MOV	a2, r14
	RSBLT	a2, a2, #0
	MOV	a1, a4
	LDMDB	rg, {a3, a4, w2, pc}^
	MOVNV	r0, r0

entrycount
; fixed offset	&a0  from Globs
 ; profile counts of procedure entry.
 ; called by  jump  as first instruction of procedure,
 ; followed by full-word count to increment.
 ; No registers have been saved: this routine does
 ; that.  Return is to	rb+8  (ie the instruction after
 ; the count).
	STMEA	rts!, {r14, rb, rl, rp}
	SUB	rp, rts, #16
	LDR	rl, [rb, #-4]		; that was the standard entry sequence
	LDR	r0, [rb, #4]
	ADD	r0, r0, #1
	STR	r0, [rb, #4]
	ADD	pc, rb, #8

 [ aof
	EXPORT	|SysLib._Count|
|SysLib._Count|
 ]
count
; fixed offset	&bc  from Globs
 ; other profile counts.  Called by branch & link, followed
 ; by full-word count.	Return to  link+4.
 ; Can't use link directly to access the count, cos of PSR.
 ; Destroys no registers
	ADD	r14, r14, #4
	STMDB	rg, {r0, r14}
	BIC	r14, r14, #PSRBits
	LDR	r0, [w2, #0]
	ADD	r0, r0, #1
	STR	r0, [w2, #0]
	LDMDB	rg, {r0, pc}^

 [ lispmode=1
 ; it is carefully arranged that each of the following entries
 ; starts on a 16-byte boundary to ensure that all of them
 ; fit in the displacement field of a format 1 instruction
xcons
; fixed offset	&d8  from Globs
	EOR	a1, a1, a2
	EOR	a2, a2, a1
	EOR	a1, a1, a2
	B	cons
ncons
; fixed offset	&e8  from Globs
	MOV	a2, nil
cons
; fixed offset	&ec  from Globs
	LDR	w1, [rg, #G_fringe]
	CMPS	w1, rts
	BLT	consgc
	ADD	w1, w1, #FringeGap
	STMFD	w1!, {a1, a2}
	ADD	a1, w1, #P_pair
	SUB	w1, w1, #FringeGap
	STR	w1, [rg, #G_fringe]
	MOVS	pc, r14

fbind
; fixed offset	&110  from Globs
	STMEA	rts!, {a2, a3, r14}
	SUB	a2, w2, nil
	LDR	w2, [w2]
bindx
	BIC	w2, w2, #P_key
	LDMFD	w2, {w1, w2}
	BIC	w1, w1, #P_key
	LDMFD	w1, {a3, w1}
	BIC	a3, a3, #P_key
	LDR	r14, [a3]
	STR	r14, [rp, w1]
	STR	nil, [a3]
	CMPS	w2, nil
	BHI	bindx
	ADD	a2, a2, #P_id+P_spid
	STR	a2, [rp, w2]
	LDMEA	rts!, {a2, a3, pc}^

lispexit	; out of line, to be branched to by conditional exits
; fixed offset	&150  from Globs
	MOV	rts, rp
	LDMIB	rts, {rp, rl, pc}^

funbind
; fixed offset	&158  from Globs
	STMEA	rts!, {a3, r14}
ubindx
	BIC	w2, w2, #P_key
	LDMFD	w2, {w1, w2}
	BIC	w1, w1, #P_key
	LDMFD	w1, {a3, w1}
	BIC	a3, a3, #P_key
	LDR	r14, [rp, w1]
	STR	r14, [a3]
	CMPS	w2, nil
	BHI	ubindx
	STR	nil, [rp, w2]
	LDMEA	rts!, {a3, pc}^

add2
; fixed offset	&188  from Globs
	TSTS	a1, #P_numsk
	TSTEQS	a2, #P_numsk
	BNE	add2x
	MOV	a3, a1, LSL #7
	ADDS	a3, a3, a2, LSL #7
	MOVVC	a1, a3, LSR #7
	MOVVCS	pc, r14
add2x
	LDR	rb, [rg, #G_Add]
	MOV	pc, rb

diff2
; fixed offset	&1ac  from Globs
	TSTS	a1, #P_numsk
	TSTEQS	a2, #P_numsk
	BNE	diff2x
	MOV	a3, a1, LSL #7
	SUBS	a3, a3, a2, LSL #7
	MOVVC	a1, a3, LSR #7
	MOVVCS	pc, r14
diff2x
	LDR	rb, [rg, #G_Difference]
	MOV	pc, rb

sub1
; fixed offset	&1d0  from Globs
	TSTS	a1, #P_numsk
	BNE	sub1x
	CMPS	a1, #P_sgnbt
	SUBNE	a1, a1, #1
	BICNE	a1, a1, #P_numsk
	MOVNES	pc, r14
sub1x
	LDR	rb, [rg, #G_Sub1]
	MOV	pc, rb

add1
; fixed offset	&1f0  from Globs
	TSTS	a1, #P_numsk
	BNE	add1x
	ADD	a2, a1, #1
	CMPS	a2, #P_sgnbt
	BICNE	a1, a2, #P_numsk
	MOVNES	pc, r14
add1x
	LDR	rb, [rg, #G_Add1]
	MOV	pc, rb

equal
; fixed offset	&210  from Globs
	CMPS	a1, a2
	LDREQ	a1, [rg, #G_true]
	MOVEQS	pc, r14
	LDR	rb, [rg, #G_Equal]
	MOV	pc, rb

grtp
; fixed offset	&224  from Globs
	TSTS	a1, #P_numsk
	TSTEQS	a2, #P_numsk
	BNE	grtx
	MOV	a3, a1, LSL #7
	CMPS	a3, a2, LSL #7
	MOVLE	a1, nil
	LDRGT	a1, [rg, #G_true]
	MOVS	pc, r14
grtx
	LDR	rb, [rg, #G_Greaterp]
	MOV	pc, rb

lessp
; fixed offset	&24c  from Globs
	TSTS	a1, #P_numsk
	TSTEQS	a2, #P_numsk
	BNE	lessx
	MOV	a3, a1, LSL #7
	CMPS	a3, a2, LSL #7
	MOVGE	a1, nil
	LDRLT	a1, [rg, #G_true]
	MOVS	pc, r14
lessx
	LDR	rb, [rg, #G_Lessp]
	MOV	pc, rb

quotient
; fixed offset	&274  from Globs
	TSTS	a1, #P_numsk
	TSTEQS	a2, #P_numsk
	BNE	quotx
	MVN	r3, #P_numsk
	CMPS	a1, #P_sgnbt
	CMPEQS	a2, r3
	BNE	iquotient
quotx
	LDR	rb, [rg, #G_Quotient]
	MOV	pc, rb

remainder
; fixed offset	&298  from Globs
	TSTS	a1, #P_numsk
	TSTEQS	a2, #P_numsk
	BEQ	iremainder
	LDR	rb, [rg, #G_Remainder]
	MOV	pc, rb

times
; fixed offset	&2ac  from Globs
	TSTS	a1, #P_numsk
	TSTEQS	a2, #P_numsk
	BNE	xtimes
	MOV	w1, #0
	MOV	w2, a1, LSL #7
	MOVS	r3, a2, LSL #7
	MOV	r3, r3, ASR #7
	RSBLT	r3, r3, #0
51
	MOVS	r3, r3, LSR #1
	ADDCSS	w1, w1, w2
	BVS	xtimes
	ADDS	w2, w2, w2
	BVS	xtimes
	CMPS	r3, #0
	BNE	%51
	TSTS	a2, #P_sgnbt
	RSBNE	w1, w1, #0
	MOV	a1, w1, LSR #7
	MOVS	pc, r14
xtimes
	LDR	rb, [rg, #G_Mult]
	MOV	pc, rb

iquotient
; fixed offset	&300  from Globs
	STMDB	rg, {r0, r3, r4, r5, r14}
	MOVS	r14, r1, ASL #7
	RSBMI	r14, r14, #0
	MOVS	r3, r2, ASL #7
	BEQ	divideby0
	RSBMI	r3, r3, #0
	MOV	r0, r3
	MOV	r4, #0
	MOV	r5, #1
31
	CMPS	r3, #&80000000
	CMPCCS	r3, r14
	MOVCC	r3, r3, ASL #1
	MOVCC	r5, r5, ASL #1
	BCC	%31

32	CMPS	r3, r14
	ADDLS	r4, r4, r5
	SUBLS	r14, r14, r3
	MOVS	r5, r5, LSR #1
	MOVNE	r3, r3, LSR #1
	BNE	%32
	B	IQuotRemFixSigns
	& 0
	& 0
	& 0


iremainder
; fixed offset	&360  from Globs
	STR	r14, [rg, #-24]
	BL	iquotient
	MOV	r1, r14, LSR #7
	LDR	r14, [rg, #-24]
	MOVS	pc, r14

IQuotRemFixSigns
	EOR	r2, r1, r2
	TSTS	r2, #P_sgnbt
	BEQ	IQuotRemSameSigns
	RSB	r4, r4, #0
	CMPS	r14, #0
	SUBNE	r4, r4, #1
	SUBNE	r14, r14, r0
IQuotRemSameSigns
	TSTS	r1, #P_sgnbt
	RSBNE	r14, r14, #0
	BIC	r1, r4, #P_numsk
	LDMDB	rg, {r0, r3, r4, r5, pc}^
	& 0
	& 0
	& 0

CallPoll
; fixed offset	&3ac  from Globs
	LDR	rb, [rg, #G_PollSR]
	MOV	pc, rb

List2
; fixed offset	&3b4  from Globs
	LDR	w2, [rg, #G_fringe]
	CMPS	w2, rts
	BLT	gc_List2
	MOV	a3, a2
	ADD	w2, w2, #FringeGap
	SUB	a2, w2, #8
	ADD	a2, a2, #P_pair
	STMDB	w2!, {a1, a2, a3, nil}
	ADD	a1, w2, #P_pair
	SUB	w2, w2, #FringeGap
	STR	w2, [rg, #G_fringe]
	MOVS	pc, r14

List2Star
; fixed offset	&3e4  from Globs
	LDR	w2, [rg, #G_fringe]
	CMPS	w2, rts
	BLT	gc_List2Star
	MOV	w1, a3
	MOV	a3, a2
	ADD	w2, w2, #FringeGap
	SUB	a2, w2, #8
	ADD	a2, a2, #P_pair
	STMDB	w2!, {a1, a2, a3, w1}
	ADD	a1, w2, #P_pair
	SUB	w2, w2, #FringeGap
	STR	w2, [rg, #G_fringe]
	MOVS	pc, r14
	MOVNV	r0,r0
	MOVNV	r0,r0

List3
; fixed offset	&420  from Globs  (must be *16)
	LDR	w2, [rg, #G_fringe]
	CMPS	w2, rts
	BLT	gc_List3
	ADD	w2, w2, #FringeGap
	STMDB	w2!, {a3, nil}
	MOV	a3, a2
	ADD	w1, w2, #P_pair
	SUB	a2, w1, #8
	STMDB	w2!, {a1, a2, a3, w1}
	ADD	a1, w2, #P_pair
	SUB	w2, w2, #FringeGap
	STR	w2, [rg, #G_fringe]
	MOVS	pc, r14


	; from here on, alignment doesn't matter

	&	-1
	=	7,"CallSeq"
gc0	MOV	a1, nil 	; make all these safe over collection
				; (they probably were anyway, but ...)
gcL
gcF
gc1	MOV	a2, nil
gc2	MOV	a3, nil
gc3	ADR	r0, gc0 	; fake function name
	STMEA	rts!, {r0, rp, rl, r14}
	SUB	rp, rts, #16
	STMEA	rts!, {a1, a2, a3, rb}
	MOV	a1, #0
	MOV	a2, rb
	LDR	rb, [rg, #G_Rclm]
	BL	CallGlob
	LDMEA	rts!, {a1, a2, a3, rb}
	MOV	rts, rp 	; unwind our frame
	LDMIB	rp, {rp, rl, r14}
	BIC	pc, rb, #P_key ; and enter the target function

gcFN	CMPS	w1, #2		; may have had any number of arguments -
				; make them all safe
	MOVLE	a3, nil
	MOVLT	a2, nil
	CMPS	w1, #1
	MOVLT	a1, nil
gcN	ADR	r0, gc0 	; fake function name
	STMEA	rts!, {r0, rp, rl, r14}
	SUB	rp, rts, #16
	STMEA	rts!, {a1, a2, a3, w1, rb}
	MOV	a1, #0
	MOV	a2, rb
	LDR	rb, [rg, #G_Rclm]
	BL	CallGlob
	LDMEA	rts!, {a1, a2, a3, w1, rb}
	MOV	rts, rp 	; unwind our frame
	LDMIB	rp, {rp, rl, r14}
	BIC	w2, rb, #P_key	; and enter the target function
	ADD	pc, w2, #4

bgc0	MOV	a1, nil
bgc1	MOV	a2, nil
bgc2	MOV	a3, nil
bgc3	ADR	r0, gc0 	; fake function name
	STMEA	rts!, {r0, rp, rl, r14}
	SUB	rp, rts, #16
	STMEA	rts!, {a1, a2, a3, w2, rb}
	MOV	a1, #0
	MOV	a2, w2
	LDR	rb, [rg, #G_Rclm]
	BL	CallGlob
	LDMEA	rts!, {a1, a2, a3, w2, rb}
	MOV	rts, rp 	; unwind our frame
	LDMIB	rp, {rp, rl, r14}
	BIC	pc, w2, #P_key	; and enter the target function

	&	-1
	=	7,"Cons   "
consgc	ADR	r0, consgc
	STMEA	rts!, {r0, rp, rl, r14}
	SUB	rp, rts, #16
	STMEA	rts!, {a1, a2}
	ADR	r1, cons_space_mess
	MOV	a1, a1, LSR #2
	LDR	rb, [rg, #G_Rclm]
	BL	CallGlob
	LDMEA	rts!, {a1, a2}
	LDMEA	rts!, {r0, rp, rl, r14}
	B	cons

	&	-1
	=	7,"List2* "
gc_List2
	MOV	a3, nil
gc_List2Star
	ADR	r0, gc_List2
	STMEA	rts!, {r0, rp, rl, r14}
	SUB	rp, rts, #16
	STMEA	rts!, {a1, a2, a3}
	ADR	r1, cons_space_mess
	MOV	a1, a1, LSR #2
	LDR	rb, [rg, #G_Rclm]
	BL	CallGlob
	LDMEA	rts!, {a1, a2, a3}
	LDMEA	rts!, {r0, rp, rl, r14}
	B	List2Star

	&	-1
	=	7,"List3  "
gc_List3
	ADR	r0, gc_List3
	STMEA	rts!, {r0, rp, rl, r14}
	SUB	rp, rts, #16
	STMEA	rts!, {a1, a2, a3}
	ADR	r1, cons_space_mess
	MOV	a1, a1, LSR #2
	LDR	rb, [rg, #G_Rclm]
	BL	CallGlob
	LDMEA	rts!, {a1, a2, a3}
	LDMEA	rts!, {r0, rp, rl, r14}
	B	List3

cons_space_mess
	=	10,"Cons space"
	ALIGN 4

qcall0	QCallBody 0
	MOV	a3, #0
Interpretn
	MOV	a2, nil
Interpretl
	MOV	a4, nil
	MOV	a1, w2
	LDR	rb, [rg, #G_Funap]
	MOV	pc, rb

qcall1	QCallBody 1
	STR	a1, [rg, #G_arg1]
	MOV	a3, #1
	B	Interpretn

qcall2	QCallBody 2
	ADD	r0, rg, #G_arg1
	STMIA	r0, {a1, a2}
	MOV	a3, #2
	B	Interpretn

qcall3	QCallBody 3
	ADD	r0, rg, #G_arg1
	STMIA	r0, {a1, a2, a3}
	MOV	a3, #3
	B	Interpretn

qcallN	ADD	r0, rg, #G_arg1
	STMIA	r0, {a1, a2, a3}
	MOV	a3, w1
	B	Interpretn

qcallL	MVN	a3, #1	  ; -2
	MOV	a2, a1
	B	Interpretl

qcallF	MOV	a3, #0	  ; -1
	MOV	a2, a1
	B	Interpretl

qcallFN CMPS	w1, #2		; may have had any number of arguments -
				; make them all safe
	MOVLE	a3, nil
	MOVLT	a2, nil
	CMPS	w1, #1
	MOVLT	a1, nil
	ADD	r0, rg, #G_arg1
	STMIA	r0, {a1, a2, a3}
	MOV	a2, w1
	MOV	a1, w2
	LDR	rb, [rg, #G_LinkFexprn]
	MOV	pc, rb

xcar_a4 	MOV	w2, rb
xcar_w2 	MOV	w1, w2
xcar_w1 	MOV	a3, w1
xcar_a3 	MOV	a1, a3
xcar_a1 	MOV	a2, a1
xcar_a2 	MOV	a1, #E_car
		LDR	rb, [rg, #G_MixError]
		MOV	pc, rb

xcdr_a4 	MOV	w2, rb
xcdr_w2 	MOV	w1, w2
xcdr_w1 	MOV	a3, w1
xcdr_a3 	MOV	a1, a3
xcdr_a1 	MOV	a2, a1
xcdr_a2 	MOV	a1, #E_cdr
		LDR	rb, [rg, #G_MixError]
		MOV	pc, rb

xrplaca_a4	MOV	w2, rb
xrplaca_w2	MOV	w1, w2
xrplaca_w1	MOV	a3, w1
xrplaca_a3	MOV	a1, a3
xrplaca_a1	MOV	a2, a1
xrplaca_a2	MOV	a1, #E_rplaca
		LDR	rb, [rg, #G_MixError]
		MOV	pc, rb

xrplacd_a4	MOV	w2, rb
xrplacd_w2	MOV	w1, w2
xrplacd_w1	MOV	a3, w1
xrplacd_a3	MOV	a1, a3
xrplacd_a1	MOV	a2, a1
xrplacd_a2	MOV	a1, #E_rplacd
		LDR	rb, [rg, #G_MixError]
		MOV	pc, rb

xrplacw1_a4	MOV	w2, rb
xrplacw1_w2	MOV	w1, w2
xrplacw1_w1	MOV	a3, w1
xrplacw1_a3	MOV	a1, a3
xrplacw1_a1	MOV	a2, a1
xrplacw1_a2	MOV	a1, #E_rplacw1
		LDR	rb, [rg, #G_MixError]
		MOV	pc, rb

xrplacw2_a4	MOV	w2, rb
xrplacw2_w2	MOV	w1, w2
xrplacw2_w1	MOV	a3, w1
xrplacw2_a3	MOV	a1, a3
xrplacw2_a1	MOV	a2, a1
xrplacw2_a2	MOV	a1, #E_rplacw2
		LDR	rb, [rg, #G_MixError]
		MOV	pc, rb
 ]

divideby0
	ADR	a1, div0mess
	B	Call_Fault
div0mess
	=	17, "Division by zero",10

	ALIGN	4


 GlobDef 106,TKRErr
 ; TKRErr(buffer, maxlength)
 ; Moves the most recent error string into the given buffer.
 ; returns the (bcpl address of the) buffer, just as passed

	MOV	a3, a1, ASL #2
	LDR	rb, LocalDataP
	ADD	a4, rb, #O_errorString
	MOV	w2, #0
TKRErr1
	LDRB	rb, [a4],#+1
	CMPS	rb, #0
	BEQ	TKRErr2
	ADD	w2, w2, #1
	STRB	rb, [a3, w2]
	CMPS	w2, a2
	BLT	TKRErr1
TKRErr2
	STRB	w2, [a3]
	MOVS	pc, r14

r9 RN 9

 GlobDef 94, SWI
	ADR	w1, AfterSWI
	SUB	w1, w1, rts
	SUB	w1, w1, #12
	MOV	w1, w1, LSR #2
	BIC	w1, w1, #&ff000000
	ADD	w1, w1, #&ea000000	; B always
	ADD	a1, a1, #&EF000000	; SWI + Always
	STMEA	rts!, {a1, w1}
	STMEA	rts!, {nilbase, rgb, rg, rp}
	STMEA	rts!, {a3}
	MOV	a2, a2, ASL #2
	LDMIA	a2, {r0 - r9}
	SUB	pc, rts, #28
AfterSWI
	LDMEA	rts!, {rp}
	MOV	rp, rp, ASL #2
	STMIA	rp, {r0 - r9}
	LDMEA	rts!, {nilbase, rgb, rg, rp}
	SUB	rts, rts, #8
	MOVVC	a1, #0
	MOVS	pc, r14


 GlobDef 93,OSByte2

	MOV	r0, a1
	MOV	r1, a2
	MOV	r2, a3
	SWI	Byte
	MOVVS	a1, r0
	MOVVSS	pc, r14
	AND	a1, r1, #&ff
	ORR	a1, a1, r2, ASL #8
	BIC	a1, a1, #&ff0000
	ORRCS	a1, a1, #&800000
	BIC	a1, a1, #&ff000000
	MOVS	pc, r14

 GlobDef 104,OSByte

	MOV	r0, a1
	MOV	r1, a2
	MOV	r2, a3
	SWI	Byte
	STR	r2, [rg, #G_result2]
	MOV	a1, r1
	MOVS	pc, r14

 GlobDef 105,OSWord

	ANDS	r0, a1, #255
	MOV	r1, a2, ASL #2
	BEQ	rdline
	SWI	Word
	STR	r0, [rg, #G_result2]
	MOV	a1, r2
	MOVS	pc, r14

rdline	  ; ReadLine has to be done by a seperate kernel call:
	  ; OSWORD 0 won't do it.
	LDR	r0, [r1, #0]	; address of buffer
	MOV	r4, r0
	LDRB	r3, [r1, #6]	; max input byte
	LDRB	r2, [r1, #5]	; min  "     "
	LDRB	r1, [r1, #4]	; max input length
	SWI	ReadLine
	MOV	r2, #0		; the carry flag goes to Result2
	MVNCS	r2, r2
	STR	r2, [rg, #G_result2]
	MOVS	pc, r14

 GlobDef 96,OSArgs
 ; result := osargs(op, handle, ptr)

	MOV	r0, a1
	MOV	r1, a2
	MOV	r2, a3
	SWI	Args
	MOV	a1, r0
	STR	r2, [rg, #G_result2]
	MOVS	pc, r14


 GlobDef 99,OSFind

 ; OSFind(op, arg)
 ; op=0, (close) arg is file handle
 ; op ~=0 (open) arg is file name, returns handle
 ;	  filename is BCPL string: must be made into CR-terminated one
	STMEA	rts!, {r14}
	MOVS	r0, a1
	MOV	r1, a2
	MOV	r2, #0
	BEQ	doosf

	MOV	r1, r1, ASL #2
	BL	crterm

doosf
	SWI	Open
	STR	r0, [rg, #G_result2]
	MOVVS	r0, #0		; I suppose you can get an error here
afterosf
	CMPS	r2, #0		; r2 non-zero means an argument string needs
	MOVEQ	a1, r0		; shuffling up again
	LDMEQEA rts!, {pc}^
 ; r3 points to the last byte of the string as was, now its terminating CR
 ; r4 points to the first byte (was the length). r2 is the length.
osfc2
	LDRB	r1, [r3, #-1]
	STRB	r1, [r3], #-1
	CMPS	r3, r4
	BGT	osfc2
	STRB	r2, [r3]
	MOV	a1, r0
	LDMEA	rts!, {pc}^

crterm
	LDRB	r2, [r1, #0]	; length of filename
	AND	r3, r2, #3
	CMPS	r3, #3
	BEQ	osfdown
	MOV	r3, #&0D	; if there's room, add a terminating
	ADD	r1, r1, #1	; CR on the end of the string
	STRB	r3, [r1, r2]
	MOV	r2, #0
	MOV	pc, r14

osfdown 			; otherwise, shuffle the string down
	MOV	r3, r1		; one byte (remembering the length) and plant
	ADD	r5, r1, r2	; a CR at the end
osfcopy
	LDRB	r4, [r3, #1]
	STRB	r4, [r3], #1
	CMPS	r3, r5
	BLT	osfcopy
	MOV	r5, #&0D
	STRB	r5, [r3]
	MOV	r4, r1
	MOV	pc, r14

 GlobDef 100,OSFile

 ; osfile what, filename, args
 ; filename is a BCPL string (so needs conversion)
 ; args is a BCPL vector, but the addresses in it are real.
 ; If an error occurs, Result2 is returned non-zero
	STMEA	rts!, {r14}
	MOV	r0, a1
	MOV	r1, a2, ASL #2
	MOV	rb, a3
	MOV	r2, #0
	BL	crterm
	MOV	rb, rb, ASL #2
	STMEA	rts!, {r2, r3, r4}
	LDMIA	rb, {r2, r3, r4, r5}  ; u-k call wants args in registers
	SWI	File
	STMIA	rb, {r2, r3, r4, r5}  ; and returns them likewise
	MOV	r2, #0
	MVNVS	r2, #0
	STR	r2, [rg, #G_result2]
	LDMEA	rts!, {r2, r3, r4}
	B	afterosf

 GlobDef 107,OSGBPB
 ; OSGBPB function, handle, parameters
 ; parameters is a BCPL vector; addresses in it are HW ones.
 ; Returns result set on success of call (#0 if carry or overflow).
 ; result2 is the returned handle
	STMEA	rts!, {r14}
	MOV	r0, a1
	MOV	r1, a2
	MOV	rb, a3, ASL #2
	LDMIA	rb, {r2, r3, r4}
	SWI	Multiple
	STMIA	rb, {r2, r3, r4}
	STR	r1, [rg, #G_result2]
	MOV	a1, #0
	MOVCS	a1, #1
	MOVVS	a1, #-1
	LDMEA	rts!, {pc}^

 GlobDef 102,OSWrCh

	MOV	r0, a1
	SWI	WriteC
	MOV	a1, r0
	MOVS	pc, r14

 GlobDef 103,OSRdCh

	SWI	ReadC
	MOV	a1, r0
	MOV	r2, #0		; the carry flag goes to Result2
	MVNCS	r2, r2
	STR	r2, [rg, #G_result2]
	MOVS	pc, r14

 GlobDef 98,OSBPut

 ; osbput(byte, channel)
	MOV	r0, a1
	MOV	r1, a2
	SWI	BPut
	MOV	a1, #0
	MOVVS	a1, r0
	MOVS	pc, r14

 GlobDef 97,OSBGet

 ; osbget(channel)
 [ a1<>r1
	MOV	r1, a1
 ]
	SWI	BGet
	MOV	a1, r0
	MOVCCS	pc, r14
	MOV	a1, #&FF	; carry set -> endoffile
	MOV	a1, a1, ASL #1
	MOVS	pc, r14


 GlobDef 66,ReadBytes
;
;LET readbytes(v,b,n) = VALOF
;$( FOR j = 0 TO n - 1 DO
;   $(
;      LET c = rdch()
;      IF c = endstreamch then RESULTIS j
;      v%(b+j) := c
;   $)
;   RESULTIS n
;$)
;
	STMEA	rts!, {rb, rp, rl, r14}
	SUB	rp, rts, #16
	STMEA	rts!, {a3}
	CMPS	a3, #0
	BLE	ReadBytesExit
	ADD	a2, a2, a1, ASL #2
ReadBytesLoop
	STMEA	rts!, {a2, a3}
	LDR	rb, [rg, #G_BinRdCh]
	MOV	r14, pc
	MOV	pc, rb
	LDMEA	rts!, {a2, a3}
	MOV	w2, a1, LSR #1
	CMPS	w2, #&ff
	BEQ	ReadBytesReturnJ
	STRB	a1, [a2], #+1
	SUBS	a3, a3, #1
	BGT	ReadBytesLoop
ReadBytesExit
	LDMEA	rts!, {a1}
	MOV	rts, rp
	LDMIB	rts, {rp, rl, pc}^

ReadBytesReturnJ
	LDMEA	rts!, {a1}
	SUB	a1, a1, a3
	MOV	rts, rp
	LDMIB	rts, {rp, rl, pc}^


 GlobDef 67,WriteBytes

;AND writebytes(v,b,n) BE
;   FOR i = 0 TO n - 1 DO binarywrch(v%(b+i))
;
	STMEA	rts!, {rb, rp, rl, r14}
	SUB	rp, rts, #16
	CMPS	a3, #0
	BLE	WriteBytesExit
	ADD	a2, a2, a1, ASL #2
WriteBytesLoop
	LDRB	a1, [a2], #+1
	STMEA	rts!, {a2, a3}
	LDR	rb, [rg, #G_BinWrCh]
	MOV	r14, pc
	MOV	pc, rb
	LDMEA	rts!, {a2, a3}
	SUBS	a3, a3, #1
	BGT	WriteBytesLoop
WriteBytesExit
	MOV	rts, rp
	LDMIB	rts, {rp, rl, pc}^


 GlobDef 16,MulDiv
 ; muldiv(a, b, c)
 ; result = a*b/c
 ; result2 = a*b REM c
 ; the intermediate product is 64 bits long
 ; do everything using moduluses, and sort out signs later

	STMEA	rts!, {rb, rp, rl, r14}
	SUB	rp, rts, #16
	STMEA	rts!, {a1, a2, a3}

 ; first, the double-length product, returned in a3 & a4
 ; uses r0, a1 and a2 as workspace
	MOV	a3, #0
	MOV	a4, #0
	MOV	r0, #0
	CMPS	a2, #0
	RSBLT	a2, a2, #0	; abs b
	MOV	rb, a2
	CMPS	a1, #0
	RSBLT	a1, a1, #0	; abs a
muldiv0
	MOVS	a2, a2, LSR #1
	BCC	muldiv1
	ADDS	a4, a4, a1
	ADC	a3, a3, r0
muldiv1
	MOVS	a1, a1, ASL #1
	ADC	r0, r0, r0
	CMPS	a2, #0
	BNE	muldiv0

 ; now the 64*32 bit divide
 ; dividend in a3 and a4
 ; remainder ends up in a4; quotient in r0
 ; uses a1 and a2 to hold the (shifted) divisor;
 ;	w2 for the current bit in the quotient
	LDMEA	rts, {a2}
	CMPS	a2, #0
	BEQ	divideby0
	RSBLT	a2, a2, #0	; abs c
	MOV	rb, a2
	MOV	r0, #0
	MOV	a1, #0
	MOV	w2, #0
	MOV	r14, #1
muldiv2
	CMPS	a1, #&80000000
	BCS	muldiv3
	CMPS	a1, a3
	CMPEQS	a2, a4		; compare of [a1, a2] against [a3, a4]
	BCS	muldiv3
	MOVS	a2, a2, ASL #1
	MOV	a1, a1, ASL #1
	ADC	a1, a1, #0
	ADD	w2, w2, #1
	B	muldiv2

muldiv3
	CMPS	a1, a3
	CMPEQS	a2, a4
	BHI	muldiv4
	CMPS	w2, #31
	ADDLE	r0, r0, r14, ASL w2
	SUBS	a4, a4, a2
	SBC	a3, a3, a1
muldiv4
	MOVS	a1, a1, ASR #1
	MOV	a2, a2, RRX
	SUBS	w2, w2, #1
	BGE	muldiv3

 ; now all we need to do is sort out the signs.
	LDMEA	rts!, {a1, a2, a3}
	EOR	a2, a2, a1	; a2 has the sign of a*b: a3 is the sign of c
	MOV	a1, r0
	TEQS	a2, a3		; if a*b and c have opposite signs,
	RSBMI	a1, a1, #0	; negate the quotient
	CMPS	a2, #0		; and if the dividend was negative,
	RSBLT	a4, a4, #0	; negate the remainder
	STR	a4, [rg, #G_result2]
	LDMEA	rts!, {rb, rp, rl, pc}^

 GlobDef 54,GetVec

	ADD	r1, a1, #2	; actual number of words required
	CMPS	r1, #1
	BLE	gvfail

	LDR	r0, LocalDataP
	ADD	r0, r0, #O_freeHeapChain-4	; previous free chain entry
	LDR	r3, [r0, #4]			; free chain (BCPL address)
gv0	MOV	rb, r3, ASL #2
	LDMIA	rb, {r4, r5}
	CMPS	r4, #0
	BEQ	gvfail

 ; a free block has been found.  Amalgamate later blocks
	MOV	r2, r3		; start of free space (saved for later)
gv1	ADD	r3, r4, r3	; adjacent block above
	MOV	rb, r3, ASL #2
	LDMIA	rb, {r4, rb}
	CMPS	r4, #0
	MOVGT	r5, rb
	BGT	gv1		; this block is free too

 ; end of adjacent free blocks.
 ; r2 = start of free space
 ; r3 = end of free space (both BCPL addresses)
	SUB	r4, r3, r2	; amount free (words)
	CMPS	r4, r1		; compare against request
	MOV	rb, r2, ASL #2
	STMLTIA rb, {r4, r5}	; not enough - rewrite length and next
	MOVLT	r0, rb		; new previous
	MOVLT	r3, r5
	BLT	gv0 ; not enough

	SUB	r4, r4, r1
	CMPS	r4, #1		; don't bother with single-word blocks
				; (they're unallocatable anyhow)
	ADDGT	r3, r2, r1	; if not exact fit, free remainder
	STRGT	r3, [r0, #4]
	MOVGT	r3, r3, ASL #2
	STMGTIA r3, {r4, r5}

	STRLE	r5, [r0, #4]
	ADDLE	r1, r1, r4

	RSB	r1, r1, #0	; mark block allocated
	STR	r1, [rb]
	ADD	a1, r2, #1	; vector returned omits the header
	MOVS	pc, r14

gvfail	MOV	a1, #0
	MOVS	pc, r14

 GlobDef 55,FreeVec

	CMPS	a1, #0
	MOVLES	pc, r14
	TSTS	a1, #&ff000000
	BNE	FVError
	SUB	r1, a1, #1
	MOV	r2, r1, ASL #2
	LDR	r3, [r2]
	RSBS	r3, r3, #0
	BLE	FVError
	LDR	r0, LocalDataP
	ADD	r0, r0, #O_freeHeapChain-4	; previous free chain entry
FV1
	LDR	r4, [r0, #4]
	CMPS	r1, r4
	MOVGT	r0, r4, ASL #2
	BGT	FV1
	STR	r1, [r0, #4]
	STMIA	r2, {r3, r4}
	MOVS	pc, r14

FVError
	ADR	a1, FVErrMess
	B	Call_Fault
FVErrMess
	=	13,"FreeVec error"
	ALIGN	4


 GlobDef 41,Level

	MOV	a1, rp
	MOVS	pc, r14

 GlobDef 42,LongJump
 ; longjump(stack, lab)

	CMPS	rp, a1
	MOVEQ	pc, a2		; filter out silly case of local longjump
	MOV	w1, rp
	; must chain down stack to find rl
	; (stored in the linkage for the frame above)
lj1	LDR	w2, [w1, #frrp]
	CMPS	w2, w1
	BEQ	LongJumpError
	CMPS	w2, a1
	MOVNE	w1, w2
	BNE	lj1
	LDR	rl, [w1, #frrl] ; no need to load rb
	MOV	rts, w1
	MOV	rp, a1
	MOV	pc, a2

LongJumpError
	MOV	a3, a1
	ADR	a1, LongJumpErrMess
	B	Call_Fault

LongJumpErrMess
	=	51,"Destination frame %n for LongJump not in the stack",10
	ALIGN	4

 GlobDef 43,Aptovec
 ; aptovec (proc, vec ub)
 ; Wants its own frame so that RTS gets reset on return
 ; note: needs replacement for downward-growing stacks

	STMEA	rts!, {r14, rb, rl, rp}
	SUB	rp, rts, #16
	MOV	rb, r1
	MOV	a1, rts, LSR #2 	 ; vector (BCPL) address
	ADD	rts, rts, a2, ASL #2
	ADD	rts, rts, #4		; increment tos by vector size
	BL	CallGlob
	MOV	rts, rp
	LDMFD	rp, {pc, rb, rl, rp}^

 GlobDef 15,GetByte
 ; getbyte(vec, offset)

	LDRB	a1, [a2, a1, ASL #2]
	MOVS	pc, r14

 GlobDef 14,PutByte
 ; putbyte(vec, offset, value)

	STRB	a3, [a2, a1, ASL #2]
	MOVS	pc, r14

 GlobDef 37,GBytes
 ; gbytes(ba,  size)

	MOV	r0, a1
	MOV	a1, #0
gb1	LDRB	a3, [r0], #+1
	ADD	a1, a3, a1, ASL #8
	SUBS	a2, a2, #1
	BGT	gb1
	MOVS	pc, r14

 GlobDef 38,PBytes
 ; pbytes(ba,  size,  data)

	ADD	a1, a1, a2
pb1	STRB	a3, [a1, #-1]!
	MOV	a3, a3, LSR #8
	SUBS	a2, a2, #1
	BGT	pb1
	MOVS	pc, r14

 GlobDef 140,MoveWords
; movewords(direction, length, from, to)
;  direction = R1, length = R2, from = R3, to = R4
; from and to are BCPL addresses
	MOV	a4,	a4, ASL #2
	MOV	a3,	a3, ASL #2
mw1
	LDR	r0,	[a3], r1, ASL #2
	STR	r0,	[a4], r1, ASL #2
	SUBS	a2,	a2,	#1
	BGT	mw1
	MOVS	pc,	r14

 GlobDef 141,FillWords
; wordfill(base, length, value)
; Initialise !base to base!(length-1) to value.
; base is a BCPL address.

	MOV	a1,	a1,ASL #2
wf1
	STR	a3,	[a1],#+4
	SUBS	a2,	a2,	#1
	BGT	wf1
	MOVS	pc,	r14

; *** co-routine management stuff
;

 GlobDef 52,CoWait
; CoWait(cptr)

	STMEA	rts!, {rb, rl, rp, r14} ; proper entry sequence
	SUB	rp, rts, #16
	STMEA	rts!, {a1}
	LDR	a2, [rg, #G_stackBase]
	MOV	a2, a2, ASL #2
	LDR	a3, [a2, #cb_caller]
	CMN	a3, #1
	BEQ	CoError 		; the root coroutine can't wait

	STR	a3, [rg, #G_stackBase]
	MOV	a4, #0
	STR	a4, [a2, #cb_caller]
	STR	rp, [a2, #cb_resume_rp]
	MOV	a3, a3, ASL #2
	LDR	rts, [a3, #cb_resume_rp]
	LDMED	rts, {rl, rp, pc}^


 GlobDef 48,CreateCo
; CreateCo(function, stacksize)

	STMEA	rts!, {rb, rl, rp, r14} ; proper entry sequence
	SUB	rp, rts, #16
	STMEA	rts!, {a1, a2}
	MOV	a1, a2			; acquire the stack
	LDR	rb, [rg, #G_GetVec]
	BL	CallGlob

	CMPS	a1, #0
	BEQ	CoError

	LDMEA	rts!, {r4, r14} 	; get this function's arguments back
	ADD	r14, a1, r14		; (BCPL) stack end
	MOV	a2, a1, ASL #2		 ; (hw) stack base
	LDR	rb, [rg, #G_stackBase]	; callers (BCPL) stack base
	MOV	a3, rb, ASL #2
	LDR	w2, [a3, #cb_next]	; chain new coroutine after creator
	STR	a1, [a3, #cb_next]
	STMEA	a2, {w2, rb, r14}	; sets cb_next: cb_caller: cb_stackend
	STR	r4, [a2, #cb_fn]
	STR	rp, [a3, #cb_resume_rp]
	STR	a1, [rg, #G_stackBase]
	ADD	rp, a2, #cb_real_stack
CreateCo2
	MOV	rts, rp
	LDR	rb, [rg, #G_CoWait]
	BL	CallGlob
	LDR	rb, [rp, #cb_fn-cb_real_stack]
	BL	CallGlob
	B	CreateCo2


 GlobDef 49,DeleteCo
; successcode := DeleteCo(cptr)

	STMEA	rts!, {rb, rl, rp, r14} ; proper entry sequence
	SUB	rp, rts, #16
	STMEA	rts!, {a1}
	MOV	a2, a1, ASL #2
	LDR	a3, [a2, #cb_caller]
	CMPS	a3, #0
	BNE	CoError 		; can't - it's still active

	LDR	a3, [rg, #G_stackBase]	; down the caller chain to the root
DeleteCo1
	MOV	a4, a3, ASL #2
	LDR	a4, [a4, #cb_caller]
	CMN	a4, #1
	BNE	DeleteCo1

; a3 is now the root coroutine
; Search starting from it for the target coroutine
	MOV	r0, #0
DeleteCo2
	MOV	a4, a3
	LDR	a3, [r0, a3, ASL #2]
	CMPS	a3, #0
	BEQ	CoError 		; not found - end of chain
	CMPS	a1, a3
	BNE	DeleteCo2

	LDR	a2, [r0, a1, ASL #2]
	STR	a2, [r0, a4, ASL #2]	 ; unlink the target coroutine
	LDR	rb, [rg, #G_FreeVec]	; relinquish its stack
	BL	CallGlob
	MOV	rts, rp
	LDMED	rts, {rl, rp, pc}^


 GlobDef 50,CallCo
; CallCo(cptr, arg)

	STMEA	rts!, {rb, rl, rp, r14} ; proper entry sequence
	SUB	rp, rts, #16
	STMEA	rts!, {a1, a2}
	MOV	a3, a1, ASL #2
	LDR	a4, [a3, #cb_caller]
	CMPS	a4, #0
	BNE	CoError 		; already active

	LDR	rb, [rg, #G_stackBase]
	STR	rb, [a3, #cb_caller]
	MOV	rb, rb, ASL #2

CoEnter
 ; enter coroutine a1.	a3 is hw version of a1.
 ; rb is hw address of current coroutine
	STR	a1, [rg, #G_stackBase]
	STR	rp, [rb, #cb_resume_rp]
	LDR	rts, [a3, #cb_resume_rp]
	MOV	a1, a2
	LDMED	rts, {rl, rp, pc}^


 GlobDef 51,ResumeCo
; ResumeCo(cptr, arg)

	STMEA	rts!, {rb, rl, rp, r14} ; proper entry sequence
	SUB	rp, rts, #16
	STMEA	rts!, {a1, a2}
	LDR	rb, [rg, #G_stackBase]
	CMPS	rb, a1
	BEQ	ResumeCo1		; its the current coroutine
	MOV	a3, a1, ASL #2
	LDR	a4, [a3, #cb_caller]
	BNE	CoError 		; target is already active
	MOV	rb, rb, ASL #2
	LDR	a4, [rb, #cb_caller]
	CMN	a4, #1
	BEQ	CoError 		; caller is root
	STR	a4, [a3, #cb_caller]	; activate target
	MOV	a4, #0
	STR	a4, [rb, #cb_caller]	; and deactivate current
	B	CoEnter

ResumeCo1
	MOV	a1, a2
	MOV	rts, rp
	LDMED	rts, {rl, rp, pc}^


CoError
	ADR	a1, CoErrMess
Call_Fault
	MOV	a1, a1, LSR #2
	LDR	rb, [rg, #G_Fault]
	BL	CallGlob
	B	WindUp

CoErrMess
	=	16,"Coroutine error",10
	ALIGN	4

	LTORG

 [ aof
	EndModule
	AREA	|BCPL$$Data|
 ]

localData
	= "VERN"
	= LibraryMinorVersion
	= LibraryMajorVersion
	ALIGN 4

	MACRO
$Label	Variable $Size
	LCLA	Tempa
 [ "$Size"=""
Tempa	SETA	1
 |
Tempa	SETA	$Size
 ]
O_$Label *	.-localData
$Label	%	&$Tempa*4
	MEND

regDump 		Variable	16

errorBuffer		Variable
errorNumber		Variable
errorString		Variable	20

oldAbortHandlers	Variable	4

oldCallBackRegisters	Variable
oldCallBackHandler	Variable

oldErrorHandler 	Variable
oldErrorBuffer		Variable
oldEscapeHandler	Variable
oldEventHandler 	Variable

myAbortHandlers 	Variable	4
beingDebugged		Variable

eventHandlers		Variable	11*3
			&	 -2
endEventHandlers	Variable	0

freeHeapChain		Variable

cliEnvSave		Variable	4
cliR1ToR13Save		Variable	13
cliStatus		Variable

 [ :LNOT:aof
       EndModule
 ]
 END
00000000  3b 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |;***************|
00000010  2a 2a 2a 2a 2d 2a 2d 20  4d 6f 64 65 3a 20 41 73  |****-*- Mode: As|
00000020  73 65 6d 62 6c 65 72 20  2d 2a 2d 2a 2a 2a 2a 2a  |sembler -*-*****|
00000030  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
00000040  2a 2a 2a 2a 2a 2a 2a 0a  3b 2a 20 20 54 69 74 6c  |*******.;*  Titl|
00000050  65 3a 09 42 43 50 4c 20  73 79 73 74 65 6d 20 6c  |e:.BCPL system l|
00000060  69 62 72 61 72 79 09 09  09 09 20 20 20 20 20 20  |ibrary....      |
00000070  2a 0a 3b 2a 20 20 41 75  74 68 6f 72 3a 09 48 61  |*.;*  Author:.Ha|
00000080  72 72 79 20 4d 65 65 6b  69 6e 67 73 09 09 09 09  |rry Meekings....|
00000090  09 20 20 20 20 20 20 2a  0a 3b 2a 20 20 4c 61 73  |.      *.;*  Las|
000000a0  74 65 64 69 74 3a 09 32  30 20 4e 6f 76 20 38 39  |tedit:.20 Nov 89|
000000b0  20 31 36 3a 34 32 3a 34  34 20 62 79 20 48 61 72  | 16:42:44 by Har|
000000c0  72 79 20 4d 65 65 6b 69  6e 67 73 09 09 20 20 20  |ry Meekings..   |
000000d0  20 20 20 2a 0a 3b 2a 09  09 43 6f 70 79 72 69 67  |   *.;*..Copyrig|
000000e0  68 74 20 28 63 29 20 31  39 38 36 20 62 79 20 41  |ht (c) 1986 by A|
000000f0  63 6f 72 6e 20 43 6f 6d  70 75 74 65 72 73 20 4c  |corn Computers L|
00000100  74 64 09 20 20 20 20 20  20 2a 0a 3b 2a 2a 2a 2a  |td.      *.;****|
00000110  2a 2a 2a 2a 2a 2a 2a 2a  2a 2a 2a 2a 2a 2a 2a 2a  |****************|
*
00000150  2a 2a 0a 0a 3b 20 54 68  69 73 20 69 73 20 74 68  |**..; This is th|
00000160  65 20 73 6f 75 72 63 65  20 6f 66 20 74 68 65 20  |e source of the |
00000170  6d 61 69 6e 20 61 73 73  65 6d 62 6c 65 72 20 70  |main assembler p|
00000180  61 72 74 20 6f 66 20 74  68 65 20 42 43 50 4c 20  |art of the BCPL |
00000190  6c 69 62 72 61 72 79 2e  20 20 49 74 0a 3b 20 69  |library.  It.; i|
000001a0  73 20 6c 69 6e 6b 65 64  20 74 6f 20 62 79 20 74  |s linked to by t|
000001b0  68 65 20 66 69 6c 65 73  20 77 68 69 63 68 20 61  |he files which a|
000001c0  72 65 20 75 73 65 64 20  74 6f 20 6d 61 6b 65 20  |re used to make |
000001d0  76 61 72 69 6f 75 73 20  76 65 72 73 69 6f 6e 73  |various versions|
000001e0  20 6f 66 20 74 68 65 0a  3b 20 6c 69 62 72 61 72  | of the.; librar|
000001f0  79 2c 20 6e 61 6d 65 6c  79 20 20 4d 43 4c 69 62  |y, namely  MCLib|
00000200  41 52 20 20 74 6f 20 6d  61 6b 65 20 74 68 65 20  |AR  to make the |
00000210  27 6e 6f 72 6d 61 6c 27  20 76 65 72 73 69 6f 6e  |'normal' version|
00000220  0a 3b 09 09 20 20 20 4d  43 4c 69 62 41 20 20 20  |.;..   MCLibA   |
00000230  74 6f 20 6d 61 6b 65 20  74 68 65 20 61 6f 66 20  |to make the aof |
00000240  76 65 72 73 69 6f 6e 0a  3b 09 09 20 20 20 4d 43  |version.;..   MC|
00000250  4c 69 62 4c 52 20 20 74  6f 20 6d 61 6b 65 20 74  |LibLR  to make t|
00000260  68 65 20 4c 69 73 70 20  76 65 72 73 69 6f 6e 2e  |he Lisp version.|
00000270  0a 3b 20 44 6f 20 4e 4f  54 20 74 72 79 20 61 73  |.; Do NOT try as|
00000280  73 65 6d 62 6c 69 6e 67  20 74 68 69 73 20 66 69  |sembling this fi|
00000290  6c 65 20 6f 6e 20 69 74  73 20 6f 77 6e 2e 0a 0a  |le on its own...|
000002a0  4c 69 62 72 61 72 79 4d  61 6a 6f 72 56 65 72 73  |LibraryMajorVers|
000002b0  69 6f 6e 20 2a 20 31 0a  4c 69 62 72 61 72 79 4d  |ion * 1.LibraryM|
000002c0  69 6e 6f 72 56 65 72 73  69 6f 6e 20 2a 20 38 0a  |inorVersion * 8.|
000002d0  0a 72 31 09 09 52 4e 09  31 0a 72 32 09 09 52 4e  |.r1..RN.1.r2..RN|
000002e0  09 32 0a 72 33 09 09 52  4e 09 33 0a 72 34 09 09  |.2.r3..RN.3.r4..|
000002f0  52 4e 09 34 0a 72 35 09  09 52 4e 09 35 0a 72 36  |RN.4.r5..RN.5.r6|
00000300  09 09 52 4e 09 36 0a 72  37 09 09 52 4e 09 37 0a  |..RN.6.r7..RN.7.|
00000310  72 31 33 09 09 52 4e 09  31 33 0a 72 31 31 09 09  |r13..RN.13.r11..|
00000320  52 4e 09 31 31 0a 72 31  32 09 09 52 4e 09 31 32  |RN.11.r12..RN.12|
00000330  0a 0a 09 09 47 45 54 20  24 2e 41 4c 69 62 2e 48  |....GET $.ALib.H|
00000340  65 61 64 65 72 73 2e 42  72 61 7a 69 6c 0a 09 09  |eaders.Brazil...|
00000350  47 45 54 20 24 2e 41 4c  69 62 2e 48 65 61 64 65  |GET $.ALib.Heade|
00000360  72 73 2e 45 72 72 6f 72  73 0a 0a 3b 20 63 6f 2d  |rs.Errors..; co-|
00000370  72 6f 75 74 69 6e 65 20  73 74 75 66 66 20 6b 65  |routine stuff ke|
00000380  70 74 20 61 74 20 74 68  65 20 62 61 73 65 20 6f  |pt at the base o|
00000390  66 20 61 20 73 74 61 63  6b 0a 0a 63 62 5f 6e 65  |f a stack..cb_ne|
000003a0  78 74 20 09 2a 09 30 2a  34 2a 53 74 61 63 6b 44  |xt .*.0*4*StackD|
000003b0  69 72 6e 0a 63 62 5f 63  61 6c 6c 65 72 09 2a 09  |irn.cb_caller.*.|
000003c0  31 2a 34 2a 53 74 61 63  6b 44 69 72 6e 0a 63 62  |1*4*StackDirn.cb|
000003d0  5f 73 74 61 63 6b 65 6e  64 09 2a 09 32 2a 34 2a  |_stackend.*.2*4*|
000003e0  53 74 61 63 6b 44 69 72  6e 0a 63 62 5f 72 65 73  |StackDirn.cb_res|
000003f0  75 6d 65 5f 72 70 09 2a  09 34 2a 34 2a 53 74 61  |ume_rp.*.4*4*Sta|
00000400  63 6b 44 69 72 6e 0a 63  62 5f 66 6e 09 09 2a 09  |ckDirn.cb_fn..*.|
00000410  35 2a 34 2a 53 74 61 63  6b 44 69 72 6e 0a 63 62  |5*4*StackDirn.cb|
00000420  5f 72 65 61 6c 5f 73 74  61 63 6b 09 2a 09 36 2a  |_real_stack.*.6*|
00000430  34 2a 53 74 61 63 6b 44  69 72 6e 0a 0a 53 74 61  |4*StackDirn..Sta|
00000440  72 74 09 09 47 6c 6f 62  4e 6f 09 31 0a 68 6f 73  |rt..GlobNo.1.hos|
00000450  74 50 72 6f 63 65 73 73  6f 72 09 47 6c 6f 62 4e  |tProcessor.GlobN|
00000460  6f 09 32 0a 72 65 73 75  6c 74 32 20 09 47 6c 6f  |o.2.result2 .Glo|
00000470  62 4e 6f 09 31 33 0a 6c  69 6e 65 42 75 66 66 09  |bNo.13.lineBuff.|
00000480  47 6c 6f 62 4e 6f 09 31  37 0a 63 69 73 09 09 47  |GlobNo.17.cis..G|
00000490  6c 6f 62 4e 6f 09 33 31  0a 63 6f 73 09 09 47 6c  |lobNo.31.cos..Gl|
000004a0  6f 62 4e 6f 09 33 32 0a  72 65 74 75 72 6e 43 6f  |obNo.32.returnCo|
000004b0  64 65 09 47 6c 6f 62 4e  6f 09 33 39 0a 73 74 61  |de.GlobNo.39.sta|
000004c0  63 6b 42 61 73 65 09 47  6c 6f 62 4e 6f 09 34 30  |ckBase.GlobNo.40|
000004d0  0a 62 6c 6f 63 6b 4c 69  73 74 09 47 6c 6f 62 4e  |.blockList.GlobN|
000004e0  6f 09 35 37 0a 72 61 6e  64 6f 6d 53 74 61 74 65  |o.57.randomState|
000004f0  09 47 6c 6f 62 4e 6f 09  38 39 0a 6c 6f 61 64 50  |.GlobNo.89.loadP|
00000500  6f 69 6e 74 09 47 6c 6f  62 4e 6f 09 31 34 32 0a  |oint.GlobNo.142.|
00000510  76 64 75 53 74 72 65 61  6d 09 47 6c 6f 62 4e 6f  |vduStream.GlobNo|
00000520  09 31 34 34 0a 65 72 72  6f 72 53 74 72 65 61 6d  |.144.errorStream|
00000530  09 47 6c 6f 62 4e 6f 09  31 34 35 0a 73 74 72 65  |.GlobNo.145.stre|
00000540  61 6d 43 68 61 69 6e 09  47 6c 6f 62 4e 6f 09 31  |amChain.GlobNo.1|
00000550  34 36 0a 74 6f 70 4f 66  53 74 6f 72 65 09 47 6c  |46.topOfStore.Gl|
00000560  6f 62 4e 6f 09 31 34 38  0a 0a 42 69 6e 52 64 43  |obNo.148..BinRdC|
00000570  68 20 09 47 6c 6f 62 4e  6f 09 34 34 0a 42 69 6e  |h .GlobNo.44.Bin|
00000580  57 72 43 68 20 09 47 6c  6f 62 4e 6f 09 34 35 0a  |WrCh .GlobNo.45.|
00000590  41 62 6f 72 74 09 09 47  6c 6f 62 4e 6f 09 36 33  |Abort..GlobNo.63|
000005a0  0a 46 61 75 6c 74 09 09  47 6c 6f 62 4e 6f 09 39  |.Fault..GlobNo.9|
000005b0  35 0a 4c 69 62 49 6e 69  74 49 4f 09 47 6c 6f 62  |5.LibInitIO.Glob|
000005c0  4e 6f 09 31 31 31 0a 4c  69 62 54 65 72 6d 69 6e  |No.111.LibTermin|
000005d0  61 74 65 49 4f 09 47 6c  6f 62 4e 6f 09 31 34 33  |ateIO.GlobNo.143|
000005e0  0a 0a 20 5b 20 61 6f 66  0a 09 41 52 45 41 09 7c  |.. [ aof..AREA.||
000005f0  42 43 50 4c 24 24 43 6f  64 66 7c 2c 20 43 4f 44  |BCPL$$Codf|, COD|
00000600  45 2c 20 52 45 41 44 4f  4e 4c 59 0a 09 3b 20 74  |E, READONLY..; t|
00000610  6f 20 66 6f 6c 6c 6f 77  20 6a 75 73 74 20 61 66  |o follow just af|
00000620  74 65 72 20 74 68 65 20  62 63 70 6c 20 63 6f 64  |ter the bcpl cod|
00000630  65 2e 0a 09 26 09 31 30  30 32 0a 0a 3b 20 53 74  |e...&.1002..; St|
00000640  61 6e 64 61 72 64 20 42  43 50 4c 20 68 65 61 64  |andard BCPL head|
00000650  65 72 20 2e 2e 2e 0a 09  4d 6f 64 75 6c 65 09 53  |er .....Module.S|
00000660  79 73 4c 69 62 2c 22 32  32 20 46 65 62 20 38 38  |ysLib,"22 Feb 88|
00000670  20 31 33 3a 33 37 3a 31  36 22 0a 20 7c 0a 43 6f  | 13:37:16". |.Co|
00000680  64 65 53 74 61 72 74 0a  09 42 09 4c 69 62 72 61  |deStart..B.Libra|
00000690  72 79 49 6e 69 74 0a 0a  3b 20 53 74 61 6e 64 61  |ryInit..; Standa|
000006a0  72 64 20 42 43 50 4c 20  68 65 61 64 65 72 20 2e  |rd BCPL header .|
000006b0  2e 2e 0a 09 4d 6f 64 75  6c 65 09 53 79 73 4c 69  |....Module.SysLi|
000006c0  62 2c 22 32 32 20 46 65  62 20 38 38 20 31 33 3a  |b,"22 Feb 88 13:|
000006d0  33 37 3a 31 36 22 0a 20  5d 0a 0a 4c 6f 63 61 6c  |37:16". ]..Local|
000006e0  44 61 74 61 50 0a 09 41  64 64 72 65 73 73 20 6c  |DataP..Address l|
000006f0  6f 63 61 6c 44 61 74 61  0a 09 26 09 2d 31 0a 09  |ocalData..&.-1..|
00000700  3d 09 37 2c 20 22 49 6e  69 74 69 61 6c 22 0a 0a  |=.7, "Initial"..|
00000710  20 5b 20 3a 4c 4e 4f 54  3a 61 6f 66 0a 72 65 6c  | [ :LNOT:aof.rel|
00000720  6f 63 61 74 65 64 0a 09  41 64 64 72 65 73 73 20  |ocated..Address |
00000730  53 74 61 72 74 09 3b 20  74 68 69 73 20 74 65 6c  |Start.; this tel|
00000740  6c 73 20 6d 65 20 77 68  65 74 68 65 72 20 77 65  |ls me whether we|
00000750  20 61 72 65 20 62 65 69  6e 67 20 72 65 72 75 6e  | are being rerun|
00000760  0a 09 09 09 3b 20 28 69  66 20 73 6f 2c 20 69 74  |....; (if so, it|
00000770  20 68 61 73 20 74 68 65  20 62 61 73 65 20 6f 66  | has the base of|
00000780  20 74 68 69 73 20 73 65  63 74 69 6f 6e 20 61 64  | this section ad|
00000790  64 65 64 29 0a 20 5d 0a  20 5b 20 6c 69 73 70 6d  |ded). ]. [ lispm|
000007a0  6f 64 65 3d 31 0a 20 3b  20 74 68 65 73 65 20 74  |ode=1. ; these t|
000007b0  68 69 6e 67 73 20 28 77  68 69 63 68 20 61 72 65  |hings (which are|
000007c0  20 61 20 74 61 62 6c 65  20 6f 66 20 61 64 64 72  | a table of addr|
000007d0  65 73 73 65 73 20 74 6f  20 67 6f 20 74 6f 0a 20  |esses to go to. |
000007e0  3b 20 6f 6e 20 64 65 72  65 66 65 72 65 6e 63 65  |; on dereference|
000007f0  20 65 72 72 6f 72 73 29  20 67 65 74 20 63 6f 70  | errors) get cop|
00000800  69 65 64 20 6f 6e 20 73  74 61 72 74 75 70 20 74  |ied on startup t|
00000810  6f 20 73 69 74 20 61 74  0a 20 3b 20 73 6d 61 6c  |o sit at. ; smal|
00000820  6c 20 6e 65 67 61 74 69  76 65 20 6f 66 66 73 65  |l negative offse|
00000830  74 73 20 66 72 6f 6d 20  52 47 2e 0a 58 63 61 72  |ts from RG..Xcar|
00000840  5f 69 6e 69 74 0a 09 41  64 64 72 65 73 73 20 78  |_init..Address x|
00000850  72 70 6c 61 63 77 32 5f  61 34 0a 09 41 64 64 72  |rplacw2_a4..Addr|
00000860  65 73 73 20 78 72 70 6c  61 63 77 32 5f 61 31 0a  |ess xrplacw2_a1.|
00000870  09 41 64 64 72 65 73 73  20 78 72 70 6c 61 63 77  |.Address xrplacw|
00000880  32 5f 61 32 0a 09 41 64  64 72 65 73 73 20 78 72  |2_a2..Address xr|
00000890  70 6c 61 63 77 32 5f 61  33 0a 09 41 64 64 72 65  |placw2_a3..Addre|
000008a0  73 73 20 78 72 70 6c 61  63 77 32 5f 77 31 0a 09  |ss xrplacw2_w1..|
000008b0  41 64 64 72 65 73 73 20  78 72 70 6c 61 63 77 32  |Address xrplacw2|
000008c0  5f 77 32 0a 0a 09 41 64  64 72 65 73 73 20 78 72  |_w2...Address xr|
000008d0  70 6c 61 63 77 31 5f 61  34 0a 09 41 64 64 72 65  |placw1_a4..Addre|
000008e0  73 73 20 78 72 70 6c 61  63 77 31 5f 61 31 0a 09  |ss xrplacw1_a1..|
000008f0  41 64 64 72 65 73 73 20  78 72 70 6c 61 63 77 31  |Address xrplacw1|
00000900  5f 61 32 0a 09 41 64 64  72 65 73 73 20 78 72 70  |_a2..Address xrp|
00000910  6c 61 63 77 31 5f 61 33  0a 09 41 64 64 72 65 73  |lacw1_a3..Addres|
00000920  73 20 78 72 70 6c 61 63  77 31 5f 77 31 0a 09 41  |s xrplacw1_w1..A|
00000930  64 64 72 65 73 73 20 78  72 70 6c 61 63 77 31 5f  |ddress xrplacw1_|
00000940  77 32 0a 0a 09 41 64 64  72 65 73 73 20 78 72 70  |w2...Address xrp|
00000950  6c 61 63 64 5f 61 34 0a  09 41 64 64 72 65 73 73  |lacd_a4..Address|
00000960  20 78 72 70 6c 61 63 64  5f 61 31 0a 09 41 64 64  | xrplacd_a1..Add|
00000970  72 65 73 73 20 78 72 70  6c 61 63 64 5f 61 32 0a  |ress xrplacd_a2.|
00000980  09 41 64 64 72 65 73 73  20 78 72 70 6c 61 63 64  |.Address xrplacd|
00000990  5f 61 33 0a 09 41 64 64  72 65 73 73 20 78 72 70  |_a3..Address xrp|
000009a0  6c 61 63 64 5f 77 31 0a  09 41 64 64 72 65 73 73  |lacd_w1..Address|
000009b0  20 78 72 70 6c 61 63 64  5f 77 32 0a 0a 09 41 64  | xrplacd_w2...Ad|
000009c0  64 72 65 73 73 20 78 72  70 6c 61 63 61 5f 61 34  |dress xrplaca_a4|
000009d0  0a 09 41 64 64 72 65 73  73 20 78 72 70 6c 61 63  |..Address xrplac|
000009e0  61 5f 61 31 0a 09 41 64  64 72 65 73 73 20 78 72  |a_a1..Address xr|
000009f0  70 6c 61 63 61 5f 61 32  0a 09 41 64 64 72 65 73  |placa_a2..Addres|
00000a00  73 20 78 72 70 6c 61 63  61 5f 61 33 0a 09 41 64  |s xrplaca_a3..Ad|
00000a10  64 72 65 73 73 20 78 72  70 6c 61 63 61 5f 77 31  |dress xrplaca_w1|
00000a20  0a 09 41 64 64 72 65 73  73 20 78 72 70 6c 61 63  |..Address xrplac|
00000a30  61 5f 77 32 0a 0a 09 41  64 64 72 65 73 73 20 78  |a_w2...Address x|
00000a40  63 64 72 5f 61 34 0a 09  41 64 64 72 65 73 73 20  |cdr_a4..Address |
00000a50  78 63 64 72 5f 61 31 0a  09 41 64 64 72 65 73 73  |xcdr_a1..Address|
00000a60  20 78 63 64 72 5f 61 32  0a 09 41 64 64 72 65 73  | xcdr_a2..Addres|
00000a70  73 20 78 63 64 72 5f 61  33 0a 09 41 64 64 72 65  |s xcdr_a3..Addre|
00000a80  73 73 20 78 63 64 72 5f  77 31 0a 09 41 64 64 72  |ss xcdr_w1..Addr|
00000a90  65 73 73 20 78 63 64 72  5f 77 32 0a 0a 09 41 64  |ess xcdr_w2...Ad|
00000aa0  64 72 65 73 73 20 78 63  61 72 5f 61 34 0a 09 41  |dress xcar_a4..A|
00000ab0  64 64 72 65 73 73 20 78  63 61 72 5f 61 31 0a 09  |ddress xcar_a1..|
00000ac0  41 64 64 72 65 73 73 20  78 63 61 72 5f 61 32 0a  |Address xcar_a2.|
00000ad0  09 41 64 64 72 65 73 73  20 78 63 61 72 5f 61 33  |.Address xcar_a3|
00000ae0  0a 09 41 64 64 72 65 73  73 20 78 63 61 72 5f 77  |..Address xcar_w|
00000af0  31 0a 09 41 64 64 72 65  73 73 20 78 63 61 72 5f  |1..Address xcar_|
00000b00  77 32 0a 58 63 61 72 5f  69 6e 69 74 5f 65 6e 64  |w2.Xcar_init_end|
00000b10  0a 20 5d 0a 0a 20 5b 20  61 6f 66 0a 09 45 4e 54  |. ].. [ aof..ENT|
00000b20  52 59 0a 20 5d 0a 4c 69  62 72 61 72 79 49 6e 69  |RY. ].LibraryIni|
00000b30  74 0a 20 3b 20 66 69 72  73 74 20 70 61 73 73 20  |t. ; first pass |
00000b40  74 68 72 6f 75 67 68 20  74 68 65 20 42 43 50 4c  |through the BCPL|
00000b50  20 73 65 63 74 69 6f 6e  73 20 70 72 65 73 65 6e  | sections presen|
00000b60  74 20 64 65 74 65 72 6d  69 6e 65 73 0a 20 3b 20  |t determines. ; |
00000b70  74 68 65 20 68 69 67 68  65 73 74 20 72 65 66 65  |the highest refe|
00000b80  72 65 6e 63 65 64 20 67  6c 6f 62 61 6c 2e 0a 20  |renced global.. |
00000b90  5b 20 61 6f 66 0a 09 4c  44 52 09 72 62 2c 20 3d  |[ aof..LDR.rb, =|
00000ba0  7c 42 43 50 4c 24 24 43  6f 64 65 24 24 4c 69 6d  ||BCPL$$Code$$Lim|
00000bb0  69 74 7c 0a 09 4c 44 52  09 72 31 2c 20 3d 7c 42  |it|..LDR.r1, =|B|
00000bc0  43 50 4c 24 24 43 6f 64  65 24 24 42 61 73 65 7c  |CPL$$Code$$Base||
00000bd0  0a 20 7c 0a 09 4c 44 52  09 72 62 2c 20 72 65 6c  |. |..LDR.rb, rel|
00000be0  6f 63 61 74 65 64 0a 09  41 44 52 09 72 31 2c 20  |ocated..ADR.r1, |
00000bf0  53 74 61 72 74 0a 20 5d  0a 09 4d 4f 56 09 72 35  |Start. ]..MOV.r5|
00000c00  2c 20 23 31 35 30 0a 09  4c 44 52 09 72 34 2c 20  |, #150..LDR.r4, |
00000c10  5b 72 31 2c 20 23 30 5d  09 3b 20 6d 61 67 69 63  |[r1, #0].; magic|
00000c20  20 63 6f 6e 73 74 61 6e  74 20 74 6f 20 69 64 65  | constant to ide|
00000c30  6e 74 69 66 79 20 42 43  50 4c 0a 6e 65 78 74 6d  |ntify BCPL.nextm|
00000c40  6f 64 75 6c 65 0a 09 4d  4f 56 09 72 36 2c 20 72  |odule..MOV.r6, r|
00000c50  31 0a 09 4c 44 4d 49 41  09 72 31 2c 20 7b 72 32  |1..LDMIA.r1, {r2|
00000c60  2c 20 72 33 7d 0a 09 43  4d 50 53 09 72 32 2c 20  |, r3}..CMPS.r2, |
00000c70  72 34 0a 09 42 4e 45 09  65 6e 64 69 6e 69 74 20  |r4..BNE.endinit |
00000c80  09 3b 20 6e 6f 74 20 42  43 50 4c 0a 20 5b 20 61  |.; not BCPL. [ a|
00000c90  6f 66 0a 09 43 4d 50 09  72 31 2c 20 72 62 0a 09  |of..CMP.r1, rb..|
00000ca0  42 47 45 09 65 6e 64 69  6e 69 74 0a 20 5d 0a 09  |BGE.endinit. ]..|
00000cb0  41 44 44 09 72 31 2c 20  72 33 2c 20 72 31 09 3b  |ADD.r1, r3, r1.;|
00000cc0  20 73 74 61 72 74 20 6f  66 20 67 6c 6f 62 61 6c  | start of global|
00000cd0  20 69 6e 69 74 69 61 6c  69 73 61 74 69 6f 6e 73  | initialisations|
00000ce0  0a 6e 65 78 74 69 6e 69  74 0a 09 4c 44 4d 46 44  |.nextinit..LDMFD|
00000cf0  09 72 31 21 2c 20 7b 72  32 2c 20 72 33 7d 0a 09  |.r1!, {r2, r3}..|
00000d00  43 4d 50 53 09 72 33 2c  20 23 30 0a 09 42 4e 45  |CMPS.r3, #0..BNE|
00000d10  09 6e 65 78 74 69 6e 69  74 0a 20 3b 20 74 68 61  |.nextinit. ; tha|
00000d20  74 27 73 20 74 68 61 74  20 6d 6f 64 75 6c 65 20  |t's that module |
00000d30  66 69 6e 69 73 68 65 64  0a 20 3b 20 4e 6f 77 20  |finished. ; Now |
00000d40  61 20 74 65 6d 70 6f 72  61 72 79 20 66 69 78 20  |a temporary fix |
00000d50  75 6e 74 69 6c 20 77 65  20 68 61 76 65 20 61 20  |until we have a |
00000d60  6c 69 6e 6b 61 67 65 20  65 64 69 74 6f 72 2e 0a  |linkage editor..|
00000d70  20 3b 20 41 74 20 74 68  65 20 65 6e 64 20 6f 66  | ; At the end of|
00000d80  20 65 61 63 68 20 63 6f  6d 70 69 6c 65 64 20 6d  | each compiled m|
00000d90  6f 64 75 6c 65 20 28 61  66 74 65 72 20 74 68 65  |odule (after the|
00000da0  20 67 6c 6f 62 61 6c 0a  20 3b 20 69 6e 69 74 69  | global. ; initi|
00000db0  61 6c 69 73 61 74 69 6f  6e 73 29 20 74 68 65 72  |alisations) ther|
00000dc0  65 20 69 73 20 61 20 74  61 62 6c 65 2c 20 73 74  |e is a table, st|
00000dd0  61 72 74 65 64 20 77 69  74 68 0a 20 3b 20 26 31  |arted with. ; &1|
00000de0  32 33 34 35 36 37 38 20  61 6e 64 20 74 65 72 6d  |2345678 and term|
00000df0  69 6e 61 74 65 64 20 77  69 74 68 20 26 38 37 36  |inated with &876|
00000e00  35 34 33 32 31 2c 20 6f  66 20 74 68 65 20 6f 66  |54321, of the of|
00000e10  66 73 65 74 73 0a 20 3b  20 69 6e 20 74 68 65 20  |fsets. ; in the |
00000e20  6d 6f 64 75 6c 65 20 77  68 69 63 68 20 72 65 71  |module which req|
00000e30  75 69 72 65 20 74 68 65  20 6d 6f 64 75 6c 65 20  |uire the module |
00000e40  62 61 73 65 20 61 64 64  69 6e 67 20 69 6e 2e 0a  |base adding in..|
00000e50  20 3b 20 54 68 69 73 20  6d 75 73 74 20 62 65 20  | ; This must be |
00000e60  64 6f 6e 65 20 69 6e 20  74 68 65 20 66 69 72 73  |done in the firs|
00000e70  74 20 70 61 73 73 2c 20  62 65 63 61 75 73 65 20  |t pass, because |
00000e80  67 6c 6f 62 61 6c 0a 20  3b 20 69 6e 69 74 69 61  |global. ; initia|
00000e90  6c 69 73 61 74 69 6f 6e  73 20 61 72 65 20 76 61  |lisations are va|
00000ea0  6c 75 65 73 20 77 68 69  63 68 20 6e 65 65 64 20  |lues which need |
00000eb0  72 65 6c 6f 63 61 74 69  6e 67 0a 09 43 4d 50 53  |relocating..CMPS|
00000ec0  09 72 32 2c 20 72 35 0a  09 4d 4f 56 47 45 09 72  |.r2, r5..MOVGE.r|
00000ed0  35 2c 20 72 32 0a 20 5b  20 3a 4c 4e 4f 54 3a 61  |5, r2. [ :LNOT:a|
00000ee0  6f 66 0a 09 4c 44 52 09  72 33 2c 20 5b 72 31 2c  |of..LDR.r3, [r1,|
00000ef0  20 23 30 5d 0a 09 4c 44  52 09 72 32 2c 20 72 65  | #0]..LDR.r2, re|
00000f00  6c 6f 63 73 74 61 72 74  0a 09 43 4d 50 53 09 72  |locstart..CMPS.r|
00000f10  32 2c 20 72 33 0a 09 42  4e 45 09 6e 65 78 74 6d  |2, r3..BNE.nextm|
00000f20  6f 64 75 6c 65 0a 09 4c  44 52 09 72 32 2c 20 72  |odule..LDR.r2, r|
00000f30  65 6c 6f 63 65 6e 64 0a  09 41 44 44 09 72 31 2c  |elocend..ADD.r1,|
00000f40  20 72 31 2c 20 23 34 0a  09 43 4d 50 53 09 72 62  | r1, #4..CMPS.rb|
00000f50  2c 20 23 30 09 09 3b 20  74 68 65 20 61 73 73 75  |, #0..; the assu|
00000f60  6d 70 74 69 6f 6e 20 69  73 0a 09 42 4e 45 09 64  |mption is..BNE.d|
00000f70  6f 6e 74 5f 72 65 6c 6f  63 61 74 65 09 3b 20 74  |ont_relocate.; t|
00000f80  68 61 74 20 77 65 20 61  72 65 20 62 65 69 6e 67  |hat we are being|
00000f90  20 72 65 2d 72 75 6e 0a  6e 78 31 0a 09 4c 44 4d  | re-run.nx1..LDM|
00000fa0  46 44 09 72 31 21 2c 20  7b 72 33 7d 0a 09 43 4d  |FD.r1!, {r3}..CM|
00000fb0  50 53 09 72 33 2c 20 72  32 0a 09 4c 44 52 4e 45  |PS.r3, r2..LDRNE|
00000fc0  09 72 30 2c 20 5b 72 33  2c 20 72 36 5d 0a 09 41  |.r0, [r3, r6]..A|
00000fd0  44 44 4e 45 09 72 30 2c  20 72 30 2c 20 72 36 0a  |DDNE.r0, r0, r6.|
00000fe0  09 53 54 52 4e 45 09 72  30 2c 20 5b 72 33 2c 20  |.STRNE.r0, [r3, |
00000ff0  72 36 5d 0a 09 42 4e 45  09 6e 78 31 0a 09 42 09  |r6]..BNE.nx1..B.|
00001000  6e 65 78 74 6d 6f 64 75  6c 65 0a 0a 64 6f 6e 74  |nextmodule..dont|
00001010  5f 72 65 6c 6f 63 61 74  65 0a 09 4c 44 4d 46 44  |_relocate..LDMFD|
00001020  09 72 31 21 2c 20 7b 72  33 7d 0a 09 43 4d 50 53  |.r1!, {r3}..CMPS|
00001030  09 72 33 2c 20 72 32 0a  09 42 4e 45 09 64 6f 6e  |.r3, r2..BNE.don|
00001040  74 5f 72 65 6c 6f 63 61  74 65 0a 20 5d 0a 09 42  |t_relocate. ]..B|
00001050  09 6e 65 78 74 6d 6f 64  75 6c 65 0a 0a 65 6e 64  |.nextmodule..end|
00001060  69 6e 69 74 0a 20 3b 20  4e 6f 77 20 72 31 20 69  |init. ; Now r1 i|
00001070  73 20 74 68 65 20 65 6e  64 20 6f 66 20 63 6f 64  |s the end of cod|
00001080  65 2c 20 61 6e 64 20 72  35 2b 31 20 74 68 65 20  |e, and r5+1 the |
00001090  6e 75 6d 62 65 72 20 6f  66 0a 20 3b 20 67 6c 6f  |number of. ; glo|
000010a0  62 61 6c 73 20 72 65 71  75 69 72 65 64 2e 20 20  |bals required.  |
000010b0  54 68 65 20 67 6c 6f 62  61 6c 20 76 65 63 74 6f  |The global vecto|
000010c0  72 20 67 65 74 73 20 61  6c 6c 6f 63 61 74 65 64  |r gets allocated|
000010d0  0a 20 3b 20 61 74 20 72  31 2b 36 34 2c 20 6c 65  |. ; at r1+64, le|
000010e0  61 76 69 6e 67 20 73 6f  6d 65 20 77 6f 72 6b 73  |aving some works|
000010f0  70 61 63 65 20 6c 6f 63  61 74 69 6f 6e 73 20 62  |pace locations b|
00001100  65 6c 6f 77 20 72 67 2e  0a 20 3b 20 54 68 65 20  |elow rg.. ; The |
00001110  73 74 61 63 6b 20 74 68  65 6e 20 67 6f 65 73 20  |stack then goes |
00001120  69 6d 6d 65 64 69 61 74  65 6c 79 20 61 62 6f 76  |immediately abov|
00001130  65 20 74 68 65 20 67 6c  6f 62 61 6c 20 76 65 63  |e the global vec|
00001140  74 6f 72 2e 0a 20 5b 20  61 6f 66 0a 09 4c 44 52  |tor.. [ aof..LDR|
00001150  09 72 31 2c 20 3d 7c 49  6d 61 67 65 24 24 44 61  |.r1, =|Image$$Da|
00001160  74 61 4c 69 6d 69 74 7c  0a 20 5d 0a 09 41 44 44  |taLimit|. ]..ADD|
00001170  09 72 67 2c 20 72 31 2c  20 23 36 34 0a 20 5b 20  |.rg, r1, #64. [ |
00001180  6c 69 73 70 6d 6f 64 65  3d 31 0a 09 41 44 44 09  |lispmode=1..ADD.|
00001190  72 67 2c 20 72 67 2c 20  23 58 63 61 72 5f 69 6e  |rg, rg, #Xcar_in|
000011a0  69 74 5f 65 6e 64 2d 58  63 61 72 5f 69 6e 69 74  |it_end-Xcar_init|
000011b0  0a 09 41 44 52 09 72 32  2c 20 58 63 61 72 5f 69  |..ADR.r2, Xcar_i|
000011c0  6e 69 74 0a 09 41 44 52  09 72 33 2c 20 58 63 61  |nit..ADR.r3, Xca|
000011d0  72 5f 69 6e 69 74 5f 65  6e 64 0a 58 63 61 72 5f  |r_init_end.Xcar_|
000011e0  6c 6f 6f 70 0a 09 4c 44  52 09 72 30 2c 20 5b 72  |loop..LDR.r0, [r|
000011f0  32 5d 2c 23 2b 34 0a 09  53 54 52 09 72 30 2c 20  |2],#+4..STR.r0, |
00001200  5b 72 31 2c 23 2b 34 5d  21 0a 09 43 4d 50 53 09  |[r1,#+4]!..CMPS.|
00001210  72 32 2c 20 72 33 0a 09  42 4e 45 09 58 63 61 72  |r2, r3..BNE.Xcar|
00001220  5f 6c 6f 6f 70 0a 20 5d  0a 09 41 44 44 09 72 70  |_loop. ]..ADD.rp|
00001230  2c 20 72 67 2c 20 72 35  2c 20 41 53 4c 20 23 32  |, rg, r5, ASL #2|
00001240  0a 09 41 44 44 09 72 70  2c 20 72 70 2c 20 23 34  |..ADD.rp, rp, #4|
00001250  0a 09 53 54 52 09 72 35  2c 20 5b 72 67 2c 20 23  |..STR.r5, [rg, #|
00001260  30 5d 09 3b 20 67 6c 6f  62 61 6c 20 30 20 3d 20  |0].; global 0 = |
00001270  6d 61 78 20 67 6c 6f 62  61 6c 0a 63 6c 65 61 72  |max global.clear|
00001280  0a 09 4d 4f 56 09 72 36  2c 20 23 26 61 65 30 30  |..MOV.r6, #&ae00|
00001290  30 30 30 30 0a 09 41 44  44 09 72 36 2c 20 72 36  |0000..ADD.r6, r6|
000012a0  2c 20 23 26 39 35 30 30  30 30 0a 09 41 44 44 09  |, #&950000..ADD.|
000012b0  72 36 2c 20 72 36 2c 20  72 35 2c 20 41 53 4c 20  |r6, r6, r5, ASL |
000012c0  23 32 0a 09 53 54 52 09  72 36 2c 20 5b 72 67 2c  |#2..STR.r6, [rg,|
000012d0  20 72 35 2c 20 41 53 4c  20 23 32 5d 0a 09 53 55  | r5, ASL #2]..SU|
000012e0  42 53 09 72 35 2c 20 72  35 2c 20 23 31 0a 09 42  |BS.r5, r5, #1..B|
000012f0  4e 45 09 63 6c 65 61 72  0a 0a 20 3b 20 73 65 63  |NE.clear.. ; sec|
00001300  6f 6e 64 20 70 61 73 73  20 74 68 72 6f 75 67 68  |ond pass through|
00001310  20 42 43 50 4c 20 63 6f  64 65 2c 20 66 69 6c 6c  | BCPL code, fill|
00001320  69 6e 67 20 69 6e 20 67  6c 6f 62 61 6c 0a 20 3b  |ing in global. ;|
00001330  20 69 6e 69 74 69 61 6c  69 73 61 74 69 6f 6e 73  | initialisations|
00001340  2e 0a 0a 20 5b 20 61 6f  66 0a 09 4c 44 52 09 72  |... [ aof..LDR.r|
00001350  31 2c 20 3d 7c 42 43 50  4c 24 24 43 6f 64 65 24  |1, =|BCPL$$Code$|
00001360  24 42 61 73 65 7c 0a 20  7c 0a 09 41 44 52 09 72  |$Base|. |..ADR.r|
00001370  31 2c 20 53 74 61 72 74  0a 20 5d 0a 6e 65 78 74  |1, Start. ].next|
00001380  6d 32 0a 09 4c 44 4d 46  44 09 72 31 2c 20 7b 72  |m2..LDMFD.r1, {r|
00001390  32 2c 20 72 33 7d 0a 09  43 4d 50 53 09 72 32 2c  |2, r3}..CMPS.r2,|
000013a0  20 72 34 0a 09 42 4e 45  09 65 6e 64 69 32 09 09  | r4..BNE.endi2..|
000013b0  3b 20 6e 6f 74 20 42 43  50 4c 0a 20 5b 20 61 6f  |; not BCPL. [ ao|
000013c0  66 0a 09 43 4d 50 09 72  31 2c 20 72 62 0a 09 42  |f..CMP.r1, rb..B|
000013d0  47 45 09 65 6e 64 69 32  0a 20 5d 0a 09 41 44 44  |GE.endi2. ]..ADD|
000013e0  09 72 31 2c 20 72 33 2c  20 72 31 09 3b 20 73 74  |.r1, r3, r1.; st|
000013f0  61 72 74 20 6f 66 20 69  6e 69 74 69 61 6c 69 73  |art of initialis|
00001400  61 74 69 6f 6e 73 0a 6e  65 78 74 69 32 0a 09 4c  |ations.nexti2..L|
00001410  44 4d 46 44 09 72 31 21  2c 20 7b 72 32 2c 20 72  |DMFD.r1!, {r2, r|
00001420  33 7d 09 3b 20 6e 65 78  74 20 28 67 6e 6f 2c 20  |3}.; next (gno, |
00001430  61 64 64 72 29 20 70 61  69 72 0a 09 43 4d 50 53  |addr) pair..CMPS|
00001440  09 72 33 2c 20 23 30 0a  09 53 54 52 4e 45 09 72  |.r3, #0..STRNE.r|
00001450  33 2c 20 5b 72 67 2c 20  72 32 2c 20 41 53 4c 20  |3, [rg, r2, ASL |
00001460  23 32 5d 0a 09 42 4e 45  09 6e 65 78 74 69 32 0a  |#2]..BNE.nexti2.|
00001470  20 3b 20 74 68 61 74 27  73 20 74 68 61 74 20 6d  | ; that's that m|
00001480  6f 64 75 6c 65 20 66 69  6e 69 73 68 65 64 2e 0a  |odule finished..|
00001490  20 3b 20 74 65 6d 70 6f  72 61 72 79 20 66 69 78  | ; temporary fix|
000014a0  20 61 67 61 69 6e 20 2d  20 73 74 65 70 20 6f 76  | again - step ov|
000014b0  65 72 20 74 68 65 20 72  65 6c 6f 63 61 74 69 6f  |er the relocatio|
000014c0  6e 20 77 6f 72 64 73 2e  0a 20 5b 20 3a 4c 4e 4f  |n words.. [ :LNO|
000014d0  54 3a 61 6f 66 0a 09 4c  44 52 09 72 33 2c 20 5b  |T:aof..LDR.r3, [|
000014e0  72 31 2c 20 23 30 5d 0a  09 4c 44 52 09 72 32 2c  |r1, #0]..LDR.r2,|
000014f0  20 72 65 6c 6f 63 73 74  61 72 74 0a 09 43 4d 50  | relocstart..CMP|
00001500  53 09 72 32 2c 20 72 33  0a 09 42 4e 45 09 6e 65  |S.r2, r3..BNE.ne|
00001510  78 74 6d 32 0a 09 4c 44  52 09 72 32 2c 20 72 65  |xtm2..LDR.r2, re|
00001520  6c 6f 63 65 6e 64 0a 6e  78 32 09 4c 44 4d 46 44  |locend.nx2.LDMFD|
00001530  09 72 31 21 2c 20 7b 72  33 7d 0a 09 43 4d 50 53  |.r1!, {r3}..CMPS|
00001540  09 72 33 2c 20 72 32 0a  09 42 4e 45 09 6e 78 32  |.r3, r2..BNE.nx2|
00001550  0a 20 5d 0a 09 42 09 6e  65 78 74 6d 32 0a 65 6e  |. ]..B.nextm2.en|
00001560  64 69 32 0a 0a 3b 20 49  20 68 61 76 65 20 66 6f  |di2..; I have fo|
00001570  72 20 74 68 65 20 6d 6f  6d 65 6e 74 20 61 62 61  |r the moment aba|
00001580  6e 64 6f 6e 65 64 20 68  65 72 65 20 74 68 65 20  |ndoned here the |
00001590  70 72 65 74 65 6e 63 65  20 6f 66 20 73 75 70 70  |pretence of supp|
000015a0  6f 72 74 0a 3b 20 66 6f  72 20 64 6f 77 6e 77 61  |ort.; for downwa|
000015b0  72 64 2d 67 72 6f 77 69  6e 67 20 73 74 61 63 6b  |rd-growing stack|
000015c0  73 0a 09 4c 44 52 09 72  6c 2c 20 4c 6f 63 61 6c  |s..LDR.rl, Local|
000015d0  44 61 74 61 50 0a 09 53  57 49 09 47 65 74 45 6e  |DataP..SWI.GetEn|
000015e0  76 09 09 09 3b 20 74 6f  70 20 6f 66 20 73 74 6f  |v...; top of sto|
000015f0  72 65 20 2b 20 31 20 69  6e 20 72 31 0a 09 53 54  |re + 1 in r1..ST|
00001600  52 09 72 31 2c 20 5b 72  67 2c 20 23 47 5f 74 6f  |R.r1, [rg, #G_to|
00001610  70 4f 66 53 74 6f 72 65  5d 0a 0a 09 4d 4f 56 09  |pOfStore]...MOV.|
00001620  72 30 2c 20 72 70 2c 20  4c 53 52 20 23 32 0a 09  |r0, rp, LSR #2..|
00001630  53 54 52 09 72 30 2c 20  5b 72 67 2c 20 23 47 5f  |STR.r0, [rg, #G_|
00001640  62 6c 6f 63 6b 4c 69 73  74 5d 0a 09 4d 4f 56 09  |blockList]..MOV.|
00001650  72 32 2c 20 23 52 6f 6f  74 53 74 61 63 6b 53 69  |r2, #RootStackSi|
00001660  7a 65 09 20 3b 20 73 69  6d 75 6c 61 74 65 20 61  |ze. ; simulate a|
00001670  20 47 65 74 56 65 63 0a  09 52 53 42 09 72 32 2c  | GetVec..RSB.r2,|
00001680  20 72 32 2c 20 23 30 0a  09 53 54 52 09 72 32 2c  | r2, #0..STR.r2,|
00001690  20 5b 72 70 5d 0a 09 53  55 42 09 72 33 2c 20 72  | [rp]..SUB.r3, r|
000016a0  70 2c 20 72 32 2c 20 41  53 4c 20 23 32 09 20 3b  |p, r2, ASL #2. ;|
000016b0  20 73 74 61 63 6b 20 74  6f 70 20 2b 34 20 28 61  | stack top +4 (a|
000016c0  20 68 77 20 61 64 64 72  65 73 73 29 0a 20 5b 20  | hw address). [ |
000016d0  53 74 61 63 6b 44 69 72  6e 3d 31 0a 09 41 44 44  |StackDirn=1..ADD|
000016e0  09 72 70 2c 20 72 70 2c  20 23 34 0a 20 7c 0a 09  |.rp, rp, #4. |..|
000016f0  4d 4f 56 09 72 30 2c 20  72 33 0a 09 53 55 42 09  |MOV.r0, r3..SUB.|
00001700  72 70 2c 20 72 33 2c 20  23 34 0a 09 4d 4f 56 09  |rp, r3, #4..MOV.|
00001710  72 33 2c 20 72 30 0a 20  5d 0a 09 4d 4f 56 09 72  |r3, r0. ]..MOV.r|
00001720  30 2c 20 72 70 2c 20 4c  53 52 20 23 32 0a 09 53  |0, rp, LSR #2..S|
00001730  54 52 09 72 30 2c 20 5b  72 67 2c 20 23 47 5f 73  |TR.r0, [rg, #G_s|
00001740  74 61 63 6b 42 61 73 65  5d 0a 09 4d 4f 56 09 72  |tackBase]..MOV.r|
00001750  30 2c 20 23 30 09 09 3b  20 63 6f 2d 72 6f 75 74  |0, #0..; co-rout|
00001760  69 6e 65 20 73 74 75 66  66 20 3a 20 6e 65 78 74  |ine stuff : next|
00001770  0a 09 4d 56 4e 09 72 32  2c 20 23 30 09 09 3b 20  |..MVN.r2, #0..; |
00001780  63 61 6c 6c 65 72 3d 2d  31 20 3d 3e 20 72 6f 6f  |caller=-1 => roo|
00001790  74 0a 09 4d 4f 56 09 72  34 2c 20 72 33 2c 20 4c  |t..MOV.r4, r3, L|
000017a0  53 52 20 23 32 09 3b 20  73 74 61 63 6b 65 6e 64  |SR #2.; stackend|
000017b0  20 28 61 73 20 42 43 50  4c 20 61 64 64 72 65 73  | (as BCPL addres|
000017c0  73 29 0a 09 53 55 42 09  72 34 2c 20 72 34 2c 20  |s)..SUB.r4, r4, |
000017d0  23 31 0a 20 5b 20 53 74  61 63 6b 44 69 72 6e 3d  |#1. [ StackDirn=|
000017e0  31 0a 09 53 54 4d 49 41  09 72 70 2c 20 7b 72 30  |1..STMIA.rp, {r0|
000017f0  2c 20 72 32 2c 20 72 34  7d 0a 20 7c 0a 09 53 54  |, r2, r4}. |..ST|
00001800  4d 44 41 09 72 70 2c 20  7b 72 30 2c 20 72 32 2c  |MDA.rp, {r0, r2,|
00001810  20 72 34 7d 0a 20 5d 0a  09 4d 56 4e 09 72 32 2c  | r4}. ]..MVN.r2,|
00001820  20 23 30 0a 09 53 54 52  09 72 32 2c 20 5b 72 70  | #0..STR.r2, [rp|
00001830  2c 20 23 63 62 5f 66 6e  5d 0a 09 41 44 44 09 72  |, #cb_fn]..ADD.r|
00001840  70 2c 20 72 70 2c 20 23  63 62 5f 72 65 61 6c 5f  |p, rp, #cb_real_|
00001850  73 74 61 63 6b 0a 09 4d  4f 56 09 72 74 73 2c 20  |stack..MOV.rts, |
00001860  72 70 0a 0a 09 53 55 42  09 72 32 2c 20 72 31 2c  |rp...SUB.r2, r1,|
00001870  20 23 38 09 3b 20 68 69  67 68 65 73 74 20 28 68  | #8.; highest (h|
00001880  77 29 20 61 64 64 72 65  73 73 20 69 6e 20 68 65  |w) address in he|
00001890  61 70 0a 09 53 55 42 09  72 31 2c 20 72 32 2c 20  |ap..SUB.r1, r2, |
000018a0  72 33 09 3b 20 66 72 65  65 20 68 65 61 70 20 73  |r3.; free heap s|
000018b0  69 7a 65 20 69 6e 20 62  79 74 65 73 0a 09 4d 4f  |ize in bytes..MO|
000018c0  56 09 72 31 2c 20 72 31  2c 20 4c 53 52 20 23 32  |V.r1, r1, LSR #2|
000018d0  09 3b 20 20 2e 2e 2e 2e  2e 2e 2e 2e 2e 2e 2e 09  |.;  ............|
000018e0  20 69 6e 20 42 43 50 4c  20 77 6f 72 64 73 0a 09  | in BCPL words..|
000018f0  4d 4f 56 09 72 30 2c 20  72 33 2c 20 4c 53 52 20  |MOV.r0, r3, LSR |
00001900  23 32 0a 09 53 54 52 09  72 30 2c 20 5b 72 6c 2c  |#2..STR.r0, [rl,|
00001910  20 23 4f 5f 66 72 65 65  48 65 61 70 43 68 61 69  | #O_freeHeapChai|
00001920  6e 5d 0a 09 53 54 52 09  72 31 2c 20 5b 72 33 5d  |n]..STR.r1, [r3]|
00001930  0a 09 4d 4f 56 09 72 34  2c 20 23 30 0a 09 53 54  |..MOV.r4, #0..ST|
00001940  52 09 72 34 2c 20 5b 72  33 2c 20 72 31 2c 20 41  |R.r4, [r3, r1, A|
00001950  53 4c 20 23 32 5d 0a 09  4d 4f 56 09 72 32 2c 20  |SL #2]..MOV.r2, |
00001960  72 32 2c 20 4c 53 52 20  23 32 0a 09 53 54 52 09  |r2, LSR #2..STR.|
00001970  72 32 2c 20 5b 72 33 2c  20 23 34 5d 09 3b 20 68  |r2, [r3, #4].; h|
00001980  65 61 70 20 66 72 65 65  20 63 68 61 69 6e 20 28  |eap free chain (|
00001990  42 43 50 4c 20 70 6f 69  6e 74 65 72 29 0a 09 53  |BCPL pointer)..S|
000019a0  54 52 09 72 34 2c 20 5b  72 67 2c 20 23 47 5f 6c  |TR.r4, [rg, #G_l|
000019b0  69 6e 65 42 75 66 66 5d  0a 09 53 54 52 09 72 34  |ineBuff]..STR.r4|
000019c0  2c 20 5b 72 67 2c 20 23  47 5f 73 74 72 65 61 6d  |, [rg, #G_stream|
000019d0  43 68 61 69 6e 5d 0a 09  4f 53 62 79 74 65 09 30  |Chain]..OSbyte.0|
000019e0  2c 20 31 09 09 3b 20 68  6f 73 74 20 4f 53 0a 09  |, 1..; host OS..|
000019f0  4d 4f 56 09 72 31 2c 20  72 31 2c 20 41 53 4c 20  |MOV.r1, r1, ASL |
00001a00  23 32 34 0a 09 41 44 44  09 72 31 2c 20 72 31 2c  |#24..ADD.r1, r1,|
00001a10  20 23 22 41 22 0a 09 53  54 52 09 72 31 2c 20 5b  | #"A"..STR.r1, [|
00001a20  72 67 2c 20 23 38 5d 0a  09 3b 20 46 69 6e 64 20  |rg, #8]..; Find |
00001a30  6f 75 74 20 77 68 65 72  65 20 74 68 65 20 61 62  |out where the ab|
00001a40  6f 72 74 20 68 61 6e 64  6c 65 72 73 20 63 75 72  |ort handlers cur|
00001a50  72 65 6e 74 6c 79 20 61  72 65 20 74 6f 20 64 65  |rently are to de|
00001a60  74 65 72 6d 69 6e 65 20  77 68 65 74 68 65 72 0a  |termine whether.|
00001a70  09 3b 20 74 68 65 79 20  73 68 6f 75 6c 64 20 62  |.; they should b|
00001a80  65 20 73 65 74 2e 20 20  49 66 20 74 68 65 69 72  |e set.  If their|
00001a90  20 74 6f 70 20 62 79 74  65 20 69 73 20 6e 6f 6e  | top byte is non|
00001aa0  2d 7a 65 72 6f 2c 20 74  68 65 6e 20 77 65 20 61  |-zero, then we a|
00001ab0  72 65 20 6e 6f 74 0a 09  3b 20 72 75 6e 6e 69 6e  |re not..; runnin|
00001ac0  67 20 75 6e 64 65 72 20  61 20 64 65 62 75 67 67  |g under a debugg|
00001ad0  65 72 2c 20 61 6e 64 20  73 68 6f 75 6c 64 20 69  |er, and should i|
00001ae0  6e 73 74 61 6c 6c 20 68  61 6e 64 6c 65 72 73 20  |nstall handlers |
00001af0  28 62 75 74 20 6f 6e 6c  79 20 69 66 20 77 65 0a  |(but only if we.|
00001b00  09 3b 20 68 61 76 65 20  61 6e 20 41 62 6f 72 74  |.; have an Abort|
00001b10  20 70 72 6f 63 65 64 75  72 65 29 2e 0a 09 4d 4f  | procedure)...MO|
00001b20  56 09 72 30 2c 20 23 30  0a 09 4d 4f 56 09 72 31  |V.r0, #0..MOV.r1|
00001b30  2c 20 23 30 0a 09 4d 4f  56 09 72 32 2c 20 23 30  |, #0..MOV.r2, #0|
00001b40  0a 09 4d 56 4e 09 72 33  2c 20 23 31 0a 09 4d 4f  |..MVN.r3, #1..MO|
00001b50  56 09 72 34 2c 20 23 30  0a 09 4d 4f 56 09 72 35  |V.r4, #0..MOV.r5|
00001b60  2c 20 23 30 0a 09 4d 4f  56 09 72 36 2c 20 23 30  |, #0..MOV.r6, #0|
00001b70  0a 09 4d 4f 56 09 72 37  2c 20 23 30 0a 09 53 57  |..MOV.r7, #0..SW|
00001b80  49 09 53 65 74 45 6e 76  0a 0a 09 4d 4f 56 09 72  |I.SetEnv...MOV.r|
00001b90  62 2c 20 23 30 0a 09 53  54 52 09 72 62 2c 20 5b  |b, #0..STR.rb, [|
00001ba0  72 67 2c 20 23 47 5f 72  65 74 75 72 6e 43 6f 64  |rg, #G_returnCod|
00001bb0  65 5d 0a 09 41 44 44 09  72 30 2c 20 72 6c 2c 20  |e]..ADD.r0, rl, |
00001bc0  23 4f 5f 6f 6c 64 41 62  6f 72 74 48 61 6e 64 6c  |#O_oldAbortHandl|
00001bd0  65 72 73 0a 09 53 54 4d  49 41 09 72 30 2c 20 7b  |ers..STMIA.r0, {|
00001be0  72 34 2d 72 37 7d 0a 09  41 44 44 09 72 30 2c 20  |r4-r7}..ADD.r0, |
00001bf0  72 6c 2c 20 23 4f 5f 6d  79 41 62 6f 72 74 48 61  |rl, #O_myAbortHa|
00001c00  6e 64 6c 65 72 73 0a 09  53 54 4d 49 41 09 72 30  |ndlers..STMIA.r0|
00001c10  2c 20 7b 72 34 2d 72 37  7d 0a 09 4c 44 52 09 72  |, {r4-r7}..LDR.r|
00001c20  30 2c 20 5b 72 67 2c 20  23 47 5f 41 62 6f 72 74  |0, [rg, #G_Abort|
00001c30  5d 20 3b 20 73 65 74 20  61 6e 20 61 62 6f 72 74  |] ; set an abort|
00001c40  20 68 61 6e 64 6c 65 72  20 6f 6e 6c 79 20 69 66  | handler only if|
00001c50  20 74 68 65 72 65 27 73  0a 09 4d 4f 56 09 72 31  | there's..MOV.r1|
00001c60  2c 20 23 26 61 65 30 30  09 20 20 20 3b 20 61 20  |, #&ae00.   ; a |
00001c70  42 43 50 4c 20 70 72 6f  63 65 64 75 72 65 20 66  |BCPL procedure f|
00001c80  6f 72 20 69 74 20 74 6f  20 63 61 6c 6c 0a 09 41  |or it to call..A|
00001c90  44 44 09 72 31 2c 20 72  31 2c 20 23 26 39 35 0a  |DD.r1, r1, #&95.|
00001ca0  09 43 4d 50 09 72 31 2c  20 72 30 2c 20 4c 53 52  |.CMP.r1, r0, LSR|
00001cb0  20 23 31 36 0a 09 42 45  51 09 4c 65 61 76 65 41  | #16..BEQ.LeaveA|
00001cc0  62 6f 72 74 48 61 6e 64  6c 65 72 73 0a 09 4d 4f  |bortHandlers..MO|
00001cd0  56 09 72 30 2c 20 72 34  2c 20 4c 53 52 20 23 32  |V.r0, r4, LSR #2|
00001ce0  34 0a 09 43 4d 50 09 72  30 2c 20 23 30 0a 20 42  |4..CMP.r0, #0. B|
00001cf0  20 4c 65 61 76 65 41 62  6f 72 74 48 61 6e 64 6c  | LeaveAbortHandl|
00001d00  65 72 73 0a 3b 09 20 42  45 51 09 20 4c 65 61 76  |ers.;. BEQ. Leav|
00001d10  65 41 62 6f 72 74 48 61  6e 64 6c 65 72 73 20 3b  |eAbortHandlers ;|
00001d20  20 6e 6f 6e 2d 64 65 66  61 75 6c 74 0a 0a 09 41  | non-default...A|
00001d30  44 52 09 72 34 2c 20 75  6e 64 65 66 09 20 20 20  |DR.r4, undef.   |
00001d40  3b 20 61 62 6f 72 74 20  68 61 6e 64 6c 65 72 73  |; abort handlers|
00001d50  0a 09 41 44 52 09 72 35  2c 20 70 72 65 66 0a 09  |..ADR.r5, pref..|
00001d60  41 44 52 09 72 36 2c 20  64 61 74 61 61 62 0a 09  |ADR.r6, dataab..|
00001d70  41 44 52 09 72 37 2c 20  61 64 64 72 65 78 0a 09  |ADR.r7, addrex..|
00001d80  41 44 44 09 72 30 2c 20  72 6c 2c 20 23 4f 5f 6d  |ADD.r0, rl, #O_m|
00001d90  79 41 62 6f 72 74 48 61  6e 64 6c 65 72 73 0a 09  |yAbortHandlers..|
00001da0  53 54 4d 49 41 09 72 30  2c 20 7b 72 34 2d 72 37  |STMIA.r0, {r4-r7|
00001db0  7d 0a 09 4d 4f 56 09 72  30 2c 20 23 30 0a 09 4d  |}..MOV.r0, #0..M|
00001dc0  4f 56 09 72 31 2c 20 23  30 0a 09 53 57 49 09 53  |OV.r1, #0..SWI.S|
00001dd0  65 74 45 6e 76 0a 09 4d  4f 56 09 72 62 2c 20 23  |etEnv..MOV.rb, #|
00001de0  31 0a 0a 4c 65 61 76 65  41 62 6f 72 74 48 61 6e  |1..LeaveAbortHan|
00001df0  64 6c 65 72 73 0a 09 53  54 52 09 72 62 2c 20 5b  |dlers..STR.rb, [|
00001e00  72 6c 2c 20 23 4f 5f 62  65 69 6e 67 44 65 62 75  |rl, #O_beingDebu|
00001e10  67 67 65 64 5d 0a 09 4d  4f 56 09 72 30 2c 20 23  |gged]..MOV.r0, #|
00001e20  2d 32 0a 09 53 54 52 09  72 30 2c 20 5b 72 6c 2c  |-2..STR.r0, [rl,|
00001e30  20 23 4f 5f 65 76 65 6e  74 48 61 6e 64 6c 65 72  | #O_eventHandler|
00001e40  73 5d 0a 0a 09 41 44 44  09 72 30 2c 20 72 6c 2c  |s]...ADD.r0, rl,|
00001e50  20 23 4f 5f 72 65 67 44  75 6d 70 0a 09 41 44 52  | #O_regDump..ADR|
00001e60  09 72 31 2c 20 43 61 6c  6c 42 61 63 6b 48 61 6e  |.r1, CallBackHan|
00001e70  64 6c 65 72 0a 09 53 57  49 09 43 61 6c 6c 42 61  |dler..SWI.CallBa|
00001e80  63 6b 0a 09 41 44 44 09  72 32 2c 20 72 6c 2c 20  |ck..ADD.r2, rl, |
00001e90  23 4f 5f 6f 6c 64 43 61  6c 6c 42 61 63 6b 52 65  |#O_oldCallBackRe|
00001ea0  67 69 73 74 65 72 73 0a  09 53 54 4d 49 41 09 72  |gisters..STMIA.r|
00001eb0  32 2c 20 7b 72 30 2c 20  72 31 7d 0a 0a 09 4d 4f  |2, {r0, r1}...MO|
00001ec0  56 09 72 30 2c 20 23 30  0a 09 53 54 52 09 72 30  |V.r0, #0..STR.r0|
00001ed0  2c 20 5b 72 6c 2c 20 23  4f 5f 65 72 72 6f 72 53  |, [rl, #O_errorS|
00001ee0  74 72 69 6e 67 5d 0a 09  41 44 52 09 72 30 2c 20  |tring]..ADR.r0, |
00001ef0  45 72 72 6f 72 48 61 6e  64 6c 65 72 0a 09 41 44  |ErrorHandler..AD|
00001f00  44 09 72 31 2c 20 72 6c  2c 20 23 4f 5f 65 72 72  |D.r1, rl, #O_err|
00001f10  6f 72 42 75 66 66 65 72  0a 09 41 44 52 09 72 32  |orBuffer..ADR.r2|
00001f20  2c 20 45 73 63 61 70 65  48 61 6e 64 6c 65 72 0a  |, EscapeHandler.|
00001f30  09 41 44 52 09 72 33 2c  20 45 76 65 6e 74 48 61  |.ADR.r3, EventHa|
00001f40  6e 64 6c 65 72 0a 09 53  57 49 09 43 6f 6e 74 72  |ndler..SWI.Contr|
00001f50  6f 6c 0a 09 41 44 44 09  72 34 2c 20 72 6c 2c 20  |ol..ADD.r4, rl, |
00001f60  23 4f 5f 6f 6c 64 45 72  72 6f 72 48 61 6e 64 6c  |#O_oldErrorHandl|
00001f70  65 72 0a 09 53 54 4d 49  41 09 72 34 2c 20 7b 72  |er..STMIA.r4, {r|
00001f80  30 2d 72 33 7d 0a 0a 09  3b 20 54 6f 20 6b 65 65  |0-r3}...; To kee|
00001f90  70 20 41 72 74 68 75 72  20 68 61 70 70 79 2c 20  |p Arthur happy, |
00001fa0  6d 61 6b 65 20 73 75 72  65 20 63 61 6c 6c 62 61  |make sure callba|
00001fb0  63 6b 20 69 73 20 61 6c  77 61 79 73 20 75 73 65  |ck is always use|
00001fc0  64 20 66 6f 72 0a 09 3b  20 74 68 65 20 61 63 6b  |d for..; the ack|
00001fd0  6e 6f 77 6c 65 64 67 65  6d 65 6e 74 20 6f 66 20  |nowledgement of |
00001fe0  65 73 63 61 70 65 20 65  76 65 6e 74 73 0a 09 4d  |escape events..M|
00001ff0  4f 56 09 72 30 2c 20 23  39 0a 09 4d 4f 56 09 72  |OV.r0, #9..MOV.r|
00002000  31 2c 20 23 30 0a 09 4d  4f 56 09 72 32 2c 20 23  |1, #0..MOV.r2, #|
00002010  2d 31 0a 09 53 57 49 09  36 34 0a 0a 20 5b 20 61  |-1..SWI.64.. [ a|
00002020  6f 66 0a 09 4c 44 52 09  72 30 2c 20 3d 7c 42 43  |of..LDR.r0, =|BC|
00002030  50 4c 24 24 43 6f 64 65  24 24 42 61 73 65 7c 0a  |PL$$Code$$Base|.|
00002040  20 7c 0a 09 41 44 52 09  72 30 2c 20 53 74 61 72  | |..ADR.r0, Star|
00002050  74 0a 20 5d 0a 09 4d 4f  56 09 72 30 2c 20 72 30  |t. ]..MOV.r0, r0|
00002060  2c 20 4c 53 52 20 23 32  0a 09 53 54 52 09 72 30  |, LSR #2..STR.r0|
00002070  2c 20 5b 72 67 2c 20 23  47 5f 6c 6f 61 64 50 6f  |, [rg, #G_loadPo|
00002080  69 6e 74 5d 0a 09 4c 44  52 09 72 67 62 2c 20 47  |int]..LDR.rgb, G|
00002090  6c 6f 62 73 50 0a 09 41  44 44 09 72 67 62 2c 20  |lobsP..ADD.rgb, |
000020a0  72 67 62 2c 20 23 26 34  30 30 30 30 30 30 30 20  |rgb, #&40000000 |
000020b0  20 3b 20 74 68 61 74 20  69 73 20 74 68 65 20 5a  | ; that is the Z|
000020c0  20 50 53 52 20 62 69 74  0a 09 4c 44 52 09 72 62  | PSR bit..LDR.rb|
000020d0  2c 20 5b 72 67 2c 20 23  47 5f 4c 69 62 49 6e 69  |, [rg, #G_LibIni|
000020e0  74 49 4f 5d 0a 09 42 4c  09 43 61 6c 6c 47 6c 6f  |tIO]..BL.CallGlo|
000020f0  62 0a 0a 09 3b 20 72 65  73 74 20 6f 66 20 63 6f  |b...; rest of co|
00002100  6d 6d 61 6e 64 20 6c 69  6e 65 20 67 6f 65 73 20  |mmand line goes |
00002110  69 6e 74 6f 20 74 68 65  20 74 74 79 20 62 75 66  |into the tty buf|
00002120  66 65 72 0a 09 53 57 49  09 45 6e 74 65 72 53 56  |fer..SWI.EnterSV|
00002130  43 0a 09 53 57 49 09 47  65 74 45 6e 76 0a 09 4c  |C..SWI.GetEnv..L|
00002140  44 52 09 72 32 2c 20 5b  72 67 2c 20 23 47 5f 6c  |DR.r2, [rg, #G_l|
00002150  69 6e 65 42 75 66 66 5d  0a 09 4d 4f 56 09 72 32  |ineBuff]..MOV.r2|
00002160  2c 20 72 32 2c 20 41 53  4c 20 23 32 0a 09 4d 4f  |, r2, ASL #2..MO|
00002170  56 09 72 34 2c 20 72 32  0a 09 41 44 44 09 72 32  |V.r4, r2..ADD.r2|
00002180  2c 20 72 32 2c 20 23 33  09 3b 20 72 65 61 6c 20  |, r2, #3.; real |
00002190  62 75 66 66 65 72 20 73  74 61 72 74 0a 09 4c 44  |buffer start..LD|
000021a0  52 42 09 72 62 2c 20 5b  72 34 2c 20 23 30 5d 09  |RB.rb, [r4, #0].|
000021b0  3b 20 73 69 7a 65 20 6f  66 20 62 75 66 66 65 72  |; size of buffer|
000021c0  0a 09 41 44 44 09 72 62  2c 20 72 32 2c 20 72 62  |..ADD.rb, r2, rb|
000021d0  09 3b 20 70 6f 69 6e 74  65 72 20 74 6f 20 65 6e  |.; pointer to en|
000021e0  64 0a 0a 63 6c 31 09 43  4d 50 53 09 72 32 2c 20  |d..cl1.CMPS.r2, |
000021f0  72 62 0a 09 42 47 45 09  63 6c 33 0a 09 4c 44 52  |rb..BGE.cl3..LDR|
00002200  42 09 72 35 2c 20 5b 72  30 5d 2c 20 23 31 09 3b  |B.r5, [r0], #1.;|
00002210  20 63 6f 70 79 20 6f 76  65 72 0a 09 53 54 52 42  | copy over..STRB|
00002220  09 72 35 2c 20 5b 72 32  5d 2c 20 23 31 0a 09 43  |.r5, [r2], #1..C|
00002230  4d 50 53 09 72 35 2c 20  23 30 0a 09 42 4e 45 09  |MPS.r5, #0..BNE.|
00002240  63 6c 31 0a 0a 63 6c 33  09 4d 4f 56 09 72 35 2c  |cl1..cl3.MOV.r5,|
00002250  20 23 31 30 20 09 3b 20  70 75 74 20 69 6e 20 74  | #10 .; put in t|
00002260  65 72 6d 69 6e 61 74 69  6e 67 20 6e 65 77 6c 69  |erminating newli|
00002270  6e 65 0a 09 53 54 52 42  09 72 35 2c 20 5b 72 32  |ne..STRB.r5, [r2|
00002280  2c 20 23 2d 31 5d 0a 09  41 44 44 09 72 31 2c 20  |, #-1]..ADD.r1, |
00002290  72 34 2c 20 23 33 09 3b  20 6c 6f 6f 6b 20 66 6f  |r4, #3.; look fo|
000022a0  72 20 66 69 72 73 74 20  73 70 61 63 65 0a 0a 63  |r first space..c|
000022b0  6c 32 09 4c 44 52 42 09  72 35 2c 20 5b 72 31 5d  |l2.LDRB.r5, [r1]|
000022c0  2c 20 23 31 0a 09 43 4d  50 53 09 72 35 2c 20 23  |, #1..CMPS.r5, #|
000022d0  22 20 22 0a 09 43 4d 50  4e 45 53 09 72 35 2c 20  |" "..CMPNES.r5, |
000022e0  23 31 30 0a 09 42 4e 45  09 63 6c 32 0a 0a 09 43  |#10..BNE.cl2...C|
000022f0  4d 50 53 09 72 35 2c 20  23 31 30 20 09 3b 20 69  |MPS.r5, #10 .; i|
00002300  66 20 77 65 20 66 6f 75  6e 64 20 61 20 6e 65 77  |f we found a new|
00002310  6c 69 6e 65 20 28 69 65  20 6e 6f 20 61 72 67 73  |line (ie no args|
00002320  29 0a 09 53 55 42 45 51  09 72 31 2c 20 72 31 2c  |)..SUBEQ.r1, r1,|
00002330  20 23 31 09 3b 20 6c 65  61 76 65 20 69 74 20 66  | #1.; leave it f|
00002340  6f 72 20 74 68 65 20 64  65 63 6f 64 65 72 0a 09  |or the decoder..|
00002350  53 55 42 09 72 32 2c 20  72 32 2c 20 72 31 09 3b  |SUB.r2, r2, r1.;|
00002360  20 6c 65 6e 67 74 68 20  6f 66 20 72 65 6d 61 69  | length of remai|
00002370  6e 64 65 72 0a 09 53 54  52 42 09 72 32 2c 20 5b  |nder..STRB.r2, [|
00002380  72 34 2c 20 23 32 5d 0a  09 53 55 42 09 72 31 2c  |r4, #2]..SUB.r1,|
00002390  20 72 31 2c 20 72 34 0a  09 53 55 42 09 72 31 2c  | r1, r4..SUB.r1,|
000023a0  20 72 31 2c 20 23 33 09  3b 20 6f 66 66 73 65 74  | r1, #3.; offset|
000023b0  20 6f 66 20 6e 65 78 74  20 63 68 61 72 0a 09 53  | of next char..S|
000023c0  54 52 42 09 72 31 2c 20  5b 72 34 2c 20 23 31 5d  |TRB.r1, [r4, #1]|
000023d0  0a 09 54 45 51 50 09 70  63 2c 20 23 30 0a 0a 09  |..TEQP.pc, #0...|
000023e0  4c 44 52 09 72 62 2c 20  5b 72 67 2c 20 23 47 5f  |LDR.rb, [rg, #G_|
000023f0  53 74 61 72 74 5d 0a 09  42 4c 09 43 61 6c 6c 47  |Start]..BL.CallG|
00002400  6c 6f 62 0a 0a 57 69 6e  64 55 70 0a 09 4d 4f 56  |lob..WindUp..MOV|
00002410  09 72 74 73 2c 20 72 70  0a 09 4c 44 52 09 72 62  |.rts, rp..LDR.rb|
00002420  2c 20 5b 72 67 2c 20 23  47 5f 4c 69 62 54 65 72  |, [rg, #G_LibTer|
00002430  6d 69 6e 61 74 65 49 4f  5d 0a 09 42 4c 09 43 61  |minateIO]..BL.Ca|
00002440  6c 6c 47 6c 6f 62 0a 0a  09 4c 44 52 09 72 6c 2c  |llGlob...LDR.rl,|
00002450  20 4c 6f 63 61 6c 44 61  74 61 50 0a 09 41 44 44  | LocalDataP..ADD|
00002460  09 72 30 2c 20 72 6c 2c  20 23 4f 5f 6f 6c 64 41  |.r0, rl, #O_oldA|
00002470  62 6f 72 74 48 61 6e 64  6c 65 72 73 0a 09 4c 44  |bortHandlers..LD|
00002480  4d 49 41 09 72 30 2c 20  7b 72 34 20 2d 20 72 37  |MIA.r0, {r4 - r7|
00002490  7d 0a 09 4d 4f 56 09 72  30 2c 20 23 30 0a 09 4d  |}..MOV.r0, #0..M|
000024a0  4f 56 09 72 31 2c 20 23  30 0a 09 4d 4f 56 09 72  |OV.r1, #0..MOV.r|
000024b0  32 2c 20 23 30 0a 09 4d  56 4e 09 72 33 2c 20 23  |2, #0..MVN.r3, #|
000024c0  31 0a 09 53 57 49 09 53  65 74 45 6e 76 0a 0a 09  |1..SWI.SetEnv...|
000024d0  41 44 44 09 72 30 2c 20  72 6c 2c 20 23 4f 5f 6f  |ADD.r0, rl, #O_o|
000024e0  6c 64 43 61 6c 6c 42 61  63 6b 52 65 67 69 73 74  |ldCallBackRegist|
000024f0  65 72 73 0a 09 4c 44 4d  49 41 09 72 30 2c 20 7b  |ers..LDMIA.r0, {|
00002500  72 30 2c 20 72 31 7d 0a  09 53 57 49 09 43 61 6c  |r0, r1}..SWI.Cal|
00002510  6c 42 61 63 6b 0a 0a 09  41 44 44 09 72 30 2c 20  |lBack...ADD.r0, |
00002520  72 6c 2c 20 23 4f 5f 6f  6c 64 45 72 72 6f 72 48  |rl, #O_oldErrorH|
00002530  61 6e 64 6c 65 72 0a 09  4c 44 4d 49 41 09 72 30  |andler..LDMIA.r0|
00002540  2c 20 7b 72 30 2d 72 33  7d 0a 09 53 57 49 09 43  |, {r0-r3}..SWI.C|
00002550  6f 6e 74 72 6f 6c 0a 0a  09 4c 44 52 09 72 32 2c  |ontrol...LDR.r2,|
00002560  20 5b 72 67 2c 20 23 47  5f 72 65 74 75 72 6e 43  | [rg, #G_returnC|
00002570  6f 64 65 5d 0a 09 43 4d  50 09 72 32 2c 20 23 30  |ode]..CMP.r2, #0|
00002580  0a 09 4c 44 52 4e 45 09  72 31 2c 20 41 42 45 58  |..LDRNE.r1, ABEX|
00002590  53 74 72 69 6e 67 0a 09  53 57 49 09 45 78 69 74  |String..SWI.Exit|
000025a0  0a 0a 41 42 45 58 53 74  72 69 6e 67 0a 09 3d 09  |..ABEXString..=.|
000025b0  22 41 42 45 58 22 0a 0a  09 4c 54 4f 52 47 0a 47  |"ABEX"...LTORG.G|
000025c0  6c 6f 62 73 50 0a 09 41  64 64 72 65 73 73 20 47  |lobsP..Address G|
000025d0  6c 6f 62 73 0a 0a 09 26  09 2d 31 0a 09 3d 09 37  |lobs...&.-1..=.7|
000025e0  2c 20 22 45 72 72 48 61  6e 64 22 0a 0a 45 72 72  |, "ErrHand"..Err|
000025f0  6f 72 48 61 6e 64 6c 65  72 0a 09 53 57 49 09 45  |orHandler..SWI.E|
00002600  6e 74 65 72 53 56 43 0a  09 53 54 4d 46 44 09 72  |nterSVC..STMFD.r|
00002610  31 33 21 2c 20 7b 72 30  7d 0a 09 4c 44 52 09 72  |13!, {r0}..LDR.r|
00002620  31 34 2c 20 4c 6f 63 61  6c 44 61 74 61 50 0a 09  |14, LocalDataP..|
00002630  4c 44 52 09 72 30 2c 20  5b 72 31 34 2c 20 23 4f  |LDR.r0, [r14, #O|
00002640  5f 65 72 72 6f 72 4e 75  6d 62 65 72 5d 0a 09 54  |_errorNumber]..T|
00002650  53 54 09 72 30 2c 20 23  26 38 30 30 30 30 30 30  |ST.r0, #&8000000|
00002660  30 0a 09 4c 44 52 45 51  09 72 31 34 2c 20 5b 72  |0..LDREQ.r14, [r|
00002670  31 34 2c 20 23 4f 5f 65  72 72 6f 72 42 75 66 66  |14, #O_errorBuff|
00002680  65 72 5d 0a 09 52 53 42  45 51 09 72 30 2c 20 72  |er]..RSBEQ.r0, r|
00002690  30 2c 20 23 30 0a 09 41  44 44 45 51 09 72 31 33  |0, #0..ADDEQ.r13|
000026a0  2c 20 72 31 33 2c 20 23  34 0a 09 4f 52 52 45 51  |, r13, #4..ORREQ|
000026b0  53 09 70 63 2c 20 72 31  34 2c 20 23 4f 76 65 72  |S.pc, r14, #Over|
000026c0  66 6c 6f 77 42 69 74 0a  0a 3b 20 46 61 74 61 6c  |flowBit..; Fatal|
000026d0  20 65 72 72 6f 72 20 28  65 67 20 46 50 20 66 61  | error (eg FP fa|
000026e0  75 6c 74 20 6f 72 20 62  72 61 6e 63 68 20 74 68  |ult or branch th|
000026f0  72 6f 75 67 68 20 7a 65  72 6f 29 0a 09 4c 44 52  |rough zero)..LDR|
00002700  09 72 30 2c 20 5b 72 31  34 2c 20 23 4f 5f 62 65  |.r0, [r14, #O_be|
00002710  69 6e 67 44 65 62 75 67  67 65 64 5d 0a 09 43 4d  |ingDebugged]..CM|
00002720  50 09 72 30 2c 20 23 30  0a 09 42 4e 45 09 45 6e  |P.r0, #0..BNE.En|
00002730  74 65 72 41 62 6f 72 74  0a 09 4c 44 4d 46 44 09  |terAbort..LDMFD.|
00002740  72 31 33 21 2c 20 7b 72  30 7d 0a 09 53 54 4d 46  |r13!, {r0}..STMF|
00002750  44 09 72 31 33 2c 20 7b  72 30 2c 20 72 31 2c 20  |D.r13, {r0, r1, |
00002760  72 32 7d 0a 09 4c 44 52  09 72 30 2c 20 5b 72 31  |r2}..LDR.r0, [r1|
00002770  34 2c 20 23 4f 5f 6f 6c  64 45 72 72 6f 72 42 75  |4, #O_oldErrorBu|
00002780  66 66 65 72 5d 0a 09 4c  44 52 09 72 31 2c 20 5b  |ffer]..LDR.r1, [|
00002790  72 31 34 2c 20 23 4f 5f  65 72 72 6f 72 42 75 66  |r14, #O_errorBuf|
000027a0  66 65 72 5d 0a 09 53 54  52 09 72 31 2c 20 5b 72  |fer]..STR.r1, [r|
000027b0  30 5d 2c 20 23 2b 34 0a  09 4c 44 52 09 72 31 2c  |0], #+4..LDR.r1,|
000027c0  20 5b 72 31 34 2c 20 23  4f 5f 65 72 72 6f 72 4e  | [r14, #O_errorN|
000027d0  75 6d 62 65 72 5d 0a 09  53 54 52 09 72 31 2c 20  |umber]..STR.r1, |
000027e0  5b 72 30 5d 2c 20 23 2b  34 0a 09 41 44 44 09 72  |[r0], #+4..ADD.r|
000027f0  32 2c 20 72 31 34 2c 20  23 4f 5f 65 72 72 6f 72  |2, r14, #O_error|
00002800  53 74 72 69 6e 67 0a 30  31 09 4c 44 52 42 09 72  |String.01.LDRB.r|
00002810  31 2c 20 5b 72 32 5d 2c  20 23 2b 31 0a 09 53 54  |1, [r2], #+1..ST|
00002820  52 42 09 72 31 2c 20 5b  72 30 5d 2c 20 23 2b 31  |RB.r1, [r0], #+1|
00002830  0a 09 43 4d 50 09 72 31  2c 20 23 30 0a 09 42 4e  |..CMP.r1, #0..BN|
00002840  45 09 25 42 30 31 0a 09  4c 44 4d 46 44 09 72 31  |E.%B01..LDMFD.r1|
00002850  33 21 2c 20 7b 72 30 2c  20 72 31 2c 20 72 32 7d  |3!, {r0, r1, r2}|
00002860  0a 09 4c 44 52 09 70 63  2c 20 5b 72 31 34 2c 20  |..LDR.pc, [r14, |
00002870  23 4f 5f 6f 6c 64 45 72  72 6f 72 48 61 6e 64 6c  |#O_oldErrorHandl|
00002880  65 72 5d 0a 0a 45 6e 74  65 72 41 62 6f 72 74 0a  |er]..EnterAbort.|
00002890  09 41 44 44 09 72 30 2c  20 72 31 34 2c 20 23 4f  |.ADD.r0, r14, #O|
000028a0  5f 72 65 67 44 75 6d 70  0a 09 53 54 4d 49 42 09  |_regDump..STMIB.|
000028b0  72 30 2c 20 7b 72 31 2d  72 31 34 7d 5e 0a 09 4c  |r0, {r1-r14}^..L|
000028c0  44 4d 46 44 09 72 31 33  21 2c 20 7b 72 30 7d 0a  |DMFD.r13!, {r0}.|
000028d0  09 53 54 52 09 72 30 2c  20 5b 72 31 34 2c 20 23  |.STR.r0, [r14, #|
000028e0  4f 5f 72 65 67 44 75 6d  70 5d 0a 09 4c 44 52 09  |O_regDump]..LDR.|
000028f0  72 31 2c 20 5b 72 31 34  2c 20 23 4f 5f 65 72 72  |r1, [r14, #O_err|
00002900  6f 72 4e 75 6d 62 65 72  5d 0a 09 4c 44 52 09 72  |orNumber]..LDR.r|
00002910  32 2c 20 5b 72 31 34 2c  20 23 4f 5f 65 72 72 6f  |2, [r14, #O_erro|
00002920  72 42 75 66 66 65 72 5d  0a 09 42 09 61 62 6f 72  |rBuffer]..B.abor|
00002930  74 65 64 43 61 6c 6c 41  62 6f 72 74 0a 0a 45 73  |tedCallAbort..Es|
00002940  63 61 70 65 48 61 6e 64  6c 65 72 09 3b 20 6d 61  |capeHandler.; ma|
00002950  6b 65 20 74 68 69 73 20  6c 6f 6f 6b 20 73 6f 6d  |ke this look som|
00002960  65 77 68 61 74 20 6c 69  6b 65 20 61 6e 20 65 76  |ewhat like an ev|
00002970  65 6e 74 0a 09 54 53 54  53 09 72 31 31 2c 20 23  |ent..TSTS.r11, #|
00002980  26 34 30 0a 09 4d 4f 56  45 51 09 70 63 2c 20 72  |&40..MOVEQ.pc, r|
00002990  31 34 20 09 3b 20 69 67  6e 6f 72 65 20 66 6c 61  |14 .; ignore fla|
000029a0  67 20 67 6f 69 6e 67 20  61 77 61 79 0a 09 53 54  |g going away..ST|
000029b0  4d 46 44 09 72 31 33 21  2c 20 7b 72 30 2c 20 72  |MFD.r13!, {r0, r|
000029c0  31 2c 20 72 32 2c 20 72  31 34 7d 0a 09 43 4d 50  |1, r2, r14}..CMP|
000029d0  53 09 72 31 32 2c 20 23  30 20 09 3b 20 69 66 20  |S.r12, #0 .; if |
000029e0  69 74 20 69 73 20 73 61  66 65 20 74 6f 20 64 6f  |it is safe to do|
000029f0  20 73 6f 20 6e 6f 77 0a  09 4d 4f 56 45 51 09 72  | so now..MOVEQ.r|
00002a00  30 2c 20 23 26 37 65 09  3b 20 61 63 6b 6e 6f 77  |0, #&7e.; acknow|
00002a10  6c 65 64 67 65 20 74 68  65 20 65 73 63 61 70 65  |ledge the escape|
00002a20  0a 09 53 57 49 45 51 09  42 79 74 65 09 09 3b 20  |..SWIEQ.Byte..; |
00002a30  28 6f 74 68 65 72 77 69  73 65 20 68 61 76 65 20  |(otherwise have |
00002a40  74 6f 20 77 61 69 74 20  75 6e 74 69 6c 20 63 61  |to wait until ca|
00002a50  6c 6c 62 61 63 6b 29 0a  09 4d 4f 56 09 72 30 2c  |llback)..MOV.r0,|
00002a60  20 23 2d 31 0a 09 4d 4f  56 09 72 31 2c 20 72 31  | #-1..MOV.r1, r1|
00002a70  31 0a 09 42 4c 09 45 76  65 6e 74 48 61 6e 64 6c  |1..BL.EventHandl|
00002a80  65 72 0a 09 4c 44 4d 46  44 09 72 31 33 21 2c 20  |er..LDMFD.r13!, |
00002a90  7b 72 30 2c 20 72 31 2c  20 72 32 2c 20 72 31 34  |{r0, r1, r2, r14|
00002aa0  7d 0a 09 43 4d 50 53 09  72 31 32 2c 20 23 30 0a  |}..CMPS.r12, #0.|
00002ab0  09 4d 4f 56 4e 45 09 72  31 32 2c 20 23 31 0a 09  |.MOVNE.r12, #1..|
00002ac0  4d 4f 56 09 70 63 2c 20  72 31 34 0a 0a 09 26 09  |MOV.pc, r14...&.|
00002ad0  2d 31 0a 09 3d 09 37 2c  20 22 45 76 48 61 6e 64  |-1..=.7, "EvHand|
00002ae0  6c 22 0a 0a 45 76 65 6e  74 48 61 6e 64 6c 65 72  |l"..EventHandler|
00002af0  0a 0a 09 4c 44 52 09 72  31 31 2c 20 4c 6f 63 61  |...LDR.r11, Loca|
00002b00  6c 44 61 74 61 50 0a 09  41 44 44 09 72 31 31 2c  |lDataP..ADD.r11,|
00002b10  20 72 31 31 2c 20 23 4f  5f 65 76 65 6e 74 48 61  | r11, #O_eventHa|
00002b20  6e 64 6c 65 72 73 0a 09  53 54 4d 46 44 09 72 31  |ndlers..STMFD.r1|
00002b30  33 21 2c 20 7b 72 31 7d  0a 30 31 09 4c 44 52 09  |3!, {r1}.01.LDR.|
00002b40  72 31 2c 20 5b 72 31 31  5d 2c 20 23 2b 31 32 0a  |r1, [r11], #+12.|
00002b50  09 43 4d 50 09 72 31 2c  20 72 30 0a 09 43 4d 50  |.CMP.r1, r0..CMP|
00002b60  4e 45 09 72 31 2c 20 23  2d 32 0a 09 42 4e 45 09  |NE.r1, #-2..BNE.|
00002b70  25 42 30 31 0a 09 43 4d  50 09 72 31 2c 20 23 2d  |%B01..CMP.r1, #-|
00002b80  32 0a 09 4c 44 4d 46 44  09 72 31 33 21 2c 20 7b  |2..LDMFD.r13!, {|
00002b90  72 31 7d 0a 09 4c 44 52  45 51 09 72 31 31 2c 20  |r1}..LDREQ.r11, |
00002ba0  4c 6f 63 61 6c 44 61 74  61 50 0a 09 4c 44 52 45  |LocalDataP..LDRE|
00002bb0  51 09 70 63 2c 20 5b 72  31 31 2c 20 23 4f 5f 6f  |Q.pc, [r11, #O_o|
00002bc0  6c 64 45 76 65 6e 74 48  61 6e 64 6c 65 72 5d 0a  |ldEventHandler].|
00002bd0  09 4c 44 52 09 70 63 2c  20 5b 72 31 31 2c 20 23  |.LDR.pc, [r11, #|
00002be0  2d 38 5d 0a 0a 75 70 64  61 74 65 5f 66 6c 61 67  |-8]..update_flag|
00002bf0  0a 09 4c 44 52 09 72 31  31 2c 20 5b 72 31 31 2c  |..LDR.r11, [r11,|
00002c00  20 23 2d 34 5d 0a 09 4d  4f 56 09 72 30 2c 20 72  | #-4]..MOV.r0, r|
00002c10  30 2c 20 41 53 4c 20 23  31 36 0a 09 4f 52 52 09  |0, ASL #16..ORR.|
00002c20  72 30 2c 20 72 30 2c 20  72 31 2c 20 41 53 4c 20  |r0, r0, r1, ASL |
00002c30  23 38 0a 09 4f 52 52 09  72 30 2c 20 72 30 2c 20  |#8..ORR.r0, r0, |
00002c40  72 32 0a 09 4f 52 52 09  72 30 2c 20 72 30 2c 20  |r2..ORR.r0, r0, |
00002c50  23 26 38 30 30 30 30 30  30 30 0a 09 53 54 52 09  |#&80000000..STR.|
00002c60  72 30 2c 20 5b 72 31 31  5d 0a 72 65 74 75 72 6e  |r0, [r11].return|
00002c70  5f 63 6f 64 65 0a 09 4d  4f 56 09 70 63 2c 20 72  |_code..MOV.pc, r|
00002c80  31 34 0a 0a 62 75 66 66  65 72 5f 65 76 65 6e 74  |14..buffer_event|
00002c90  73 0a 09 4c 44 52 09 72  31 31 2c 20 5b 72 31 31  |s..LDR.r11, [r11|
00002ca0  2c 20 23 2d 34 5d 0a 09  4d 4f 56 09 72 30 2c 20  |, #-4]..MOV.r0, |
00002cb0  72 30 2c 20 41 53 4c 20  23 31 36 0a 09 4f 52 52  |r0, ASL #16..ORR|
00002cc0  09 72 30 2c 20 72 30 2c  20 72 31 2c 20 41 53 4c  |.r0, r0, r1, ASL|
00002cd0  20 23 38 0a 09 4f 52 52  09 72 30 2c 20 72 30 2c  | #8..ORR.r0, r0,|
00002ce0  20 72 32 0a 09 4c 44 4d  49 41 09 72 31 31 21 2c  | r2..LDMIA.r11!,|
00002cf0  20 7b 72 31 2c 20 72 32  2c 20 72 31 32 7d 0a 09  | {r1, r2, r12}..|
00002d00  53 54 52 09 72 30 2c 20  5b 72 31 32 2c 20 72 31  |STR.r0, [r12, r1|
00002d10  2c 20 41 53 4c 20 23 32  5d 0a 09 41 44 44 09 72  |, ASL #2]..ADD.r|
00002d20  31 2c 20 72 31 2c 20 23  31 0a 09 43 4d 50 53 09  |1, r1, #1..CMPS.|
00002d30  72 31 2c 20 72 31 32 0a  09 4d 4f 56 45 51 09 72  |r1, r12..MOVEQ.r|
00002d40  31 2c 20 23 30 0a 09 43  4d 50 53 09 72 31 2c 20  |1, #0..CMPS.r1, |
00002d50  72 32 0a 09 53 54 52 4e  45 09 72 31 2c 20 5b 72  |r2..STRNE.r1, [r|
00002d60  31 31 2c 20 23 2d 31 32  5d 0a 09 4d 4f 56 09 72  |11, #-12]..MOV.r|
00002d70  31 32 2c 20 23 30 20 09  09 3b 20 64 6f 6e 27 74  |12, #0 ..; don't|
00002d80  20 77 61 6e 74 20 63 61  6c 6c 62 61 63 6b 0a 09  | want callback..|
00002d90  4d 4f 56 09 70 63 2c 20  72 31 34 0a 0a 09 26 09  |MOV.pc, r14...&.|
00002da0  2d 31 0a 09 3d 09 37 2c  20 22 43 42 48 61 6e 64  |-1..=.7, "CBHand|
00002db0  6c 22 0a 0a 43 61 6c 6c  42 61 63 6b 48 61 6e 64  |l"..CallBackHand|
00002dc0  6c 65 72 0a 09 3b 20 61  74 20 74 68 65 20 6d 6f  |ler..; at the mo|
00002dd0  6d 65 6e 74 2c 20 74 68  69 73 20 69 73 20 6f 6e  |ment, this is on|
00002de0  6c 79 20 65 76 65 72 20  63 61 6c 6c 65 64 20 61  |ly ever called a|
00002df0  66 74 65 72 20 61 6e 20  65 73 63 61 70 65 0a 09  |fter an escape..|
00002e00  3b 20 75 70 64 61 74 65  20 65 76 65 6e 74 2e 20  |; update event. |
00002e10  20 57 68 65 6e 20 49 20  77 6f 72 6b 20 6f 75 74  | When I work out|
00002e20  20 61 6e 20 69 6e 74 65  72 66 61 63 65 2c 20 49  | an interface, I|
00002e30  20 73 68 6f 75 6c 64 20  62 65 0a 09 3b 20 70 72  | should be..; pr|
00002e40  65 70 61 72 65 64 20 74  6f 20 63 61 6c 6c 20 61  |epared to call a|
00002e50  20 75 73 65 72 20 70 72  6f 63 65 64 75 72 65 20  | user procedure |
00002e60  28 6f 66 20 77 68 69 63  68 20 74 68 65 72 65 20  |(of which there |
00002e70  6d 61 79 20 6f 66 0a 09  3b 20 63 6f 75 72 73 65  |may of..; course|
00002e80  20 62 65 20 6d 61 6e 79  29 0a 0a 09 4c 44 52 09  | be many)...LDR.|
00002e90  72 31 32 2c 20 4c 6f 63  61 6c 44 61 74 61 50 0a  |r12, LocalDataP.|
00002ea0  09 4c 44 52 09 72 31 34  2c 20 5b 72 31 32 2c 20  |.LDR.r14, [r12, |
00002eb0  23 4f 5f 72 65 67 44 75  6d 70 2b 36 30 5d 20 20  |#O_regDump+60]  |
00002ec0  3b 20 75 73 65 72 27 73  20 70 63 20 76 61 6c 75  |; user's pc valu|
00002ed0  65 0a 09 3b 20 70 72 6f  63 65 65 64 20 77 69 74  |e..; proceed wit|
00002ee0  68 20 74 68 65 20 63 61  6c 6c 62 61 63 6b 20 6f  |h the callback o|
00002ef0  6e 6c 79 20 69 66 20 74  68 65 20 53 56 43 20 77  |nly if the SVC w|
00002f00  65 20 77 65 72 65 20 69  6e 20 77 61 73 20 63 61  |e were in was ca|
00002f10  6c 6c 65 64 0a 09 3b 20  66 72 6f 6d 20 75 73 65  |lled..; from use|
00002f20  72 20 6d 6f 64 65 0a 09  54 53 54 53 09 72 31 34  |r mode..TSTS.r14|
00002f30  2c 20 23 33 0a 09 42 45  51 09 45 73 63 43 61 6c  |, #3..BEQ.EscCal|
00002f40  6c 42 61 63 6b 32 0a 0a  09 3b 20 4f 74 68 65 72  |lBack2...; Other|
00002f50  77 69 73 65 2c 20 72 65  69 6e 73 74 61 74 65 20  |wise, reinstate |
00002f60  74 68 65 20 63 61 6c 6c  62 61 63 6b 20 66 6c 61  |the callback fla|
00002f70  67 20 61 6e 64 20 72 65  73 75 6d 65 20 74 68 65  |g and resume the|
00002f80  20 53 56 43 2e 0a 09 3b  20 45 76 65 6e 74 75 61  | SVC...; Eventua|
00002f90  6c 6c 79 2c 20 77 65 20  77 69 6c 6c 20 67 65 74  |lly, we will get|
00002fa0  20 63 61 6c 6c 65 64 20  62 61 63 6b 20 6f 6e 20  | called back on |
00002fb0  61 20 72 65 74 75 72 6e  20 74 6f 20 75 73 65 72  |a return to user|
00002fc0  20 6d 6f 64 65 2e 0a 09  4d 4f 56 09 72 31 2c 20  | mode...MOV.r1, |
00002fd0  72 31 34 0a 09 53 57 49  09 53 65 74 43 61 6c 6c  |r14..SWI.SetCall|
00002fe0  42 61 63 6b 0a 09 4d 4f  56 09 72 31 34 2c 20 72  |Back..MOV.r14, r|
00002ff0  31 0a 09 4c 44 4d 49 41  09 72 30 2c 20 7b 72 30  |1..LDMIA.r0, {r0|
00003000  20 2d 20 72 31 32 7d 0a  09 4d 4f 56 53 09 70 63  | - r12}..MOVS.pc|
00003010  2c 20 72 31 34 0a 0a 45  73 63 43 61 6c 6c 42 61  |, r14..EscCallBa|
00003020  63 6b 32 0a 09 54 45 51  50 09 70 63 2c 20 23 30  |ck2..TEQP.pc, #0|
00003030  0a 09 4f 53 62 79 74 65  09 26 37 65 09 09 3b 20  |..OSbyte.&7e..; |
00003040  61 63 6b 6e 6f 77 6c 65  64 67 65 20 74 68 65 20  |acknowledge the |
00003050  65 73 63 61 70 65 0a 09  41 44 44 09 72 30 2c 20  |escape..ADD.r0, |
00003060  72 31 32 2c 20 23 4f 5f  72 65 67 44 75 6d 70 0a  |r12, #O_regDump.|
00003070  09 4c 44 4d 49 41 09 72  30 2c 20 7b 72 30 2d 70  |.LDMIA.r0, {r0-p|
00003080  63 7d 5e 0a 0a 20 47 6c  6f 62 44 65 66 20 31 31  |c}^.. GlobDef 11|
00003090  32 2c 53 65 74 45 76 65  6e 74 48 61 6e 64 6c 65  |2,SetEventHandle|
000030a0  72 0a 0a 09 4c 44 52 09  72 62 2c 20 4c 6f 63 61  |r...LDR.rb, Loca|
000030b0  6c 44 61 74 61 50 0a 09  41 44 44 09 77 32 2c 20  |lDataP..ADD.w2, |
000030c0  72 62 2c 20 23 4f 5f 65  76 65 6e 74 48 61 6e 64  |rb, #O_eventHand|
000030d0  6c 65 72 73 0a 30 31 09  4c 44 52 09 72 30 2c 20  |lers.01.LDR.r0, |
000030e0  5b 77 32 5d 2c 20 23 2b  31 32 0a 09 43 4d 50 09  |[w2], #+12..CMP.|
000030f0  72 30 2c 20 61 31 0a 09  43 4d 50 4e 45 09 72 30  |r0, a1..CMPNE.r0|
00003100  2c 20 23 2d 32 0a 09 42  4e 45 09 25 42 30 31 0a  |, #-2..BNE.%B01.|
00003110  0a 09 43 4d 50 53 09 61  33 2c 20 23 65 76 5f 69  |..CMPS.a3, #ev_i|
00003120  67 6e 6f 72 65 0a 09 42  45 51 09 52 65 6d 6f 76  |gnore..BEQ.Remov|
00003130  65 48 61 6e 64 6c 65 72  0a 0a 09 41 44 44 09 77  |eHandler...ADD.w|
00003140  31 2c 20 72 62 2c 20 23  4f 5f 65 6e 64 45 76 65  |1, rb, #O_endEve|
00003150  6e 74 48 61 6e 64 6c 65  72 73 0a 09 43 4d 50 09  |ntHandlers..CMP.|
00003160  77 32 2c 20 77 31 0a 09  4d 4f 56 47 54 09 61 31  |w2, w1..MOVGT.a1|
00003170  2c 20 23 2d 31 0a 09 4d  4f 56 47 54 53 09 70 63  |, #-1..MOVGTS.pc|
00003180  2c 20 72 31 34 0a 0a 09  4d 4f 56 09 77 31 2c 20  |, r14...MOV.w1, |
00003190  61 32 2c 20 41 53 4c 20  23 32 0a 09 43 4d 50 09  |a2, ASL #2..CMP.|
000031a0  61 33 2c 20 23 65 76 5f  73 65 74 5f 66 6c 61 67  |a3, #ev_set_flag|
000031b0  0a 09 41 44 52 45 51 09  61 32 2c 20 75 70 64 61  |..ADREQ.a2, upda|
000031c0  74 65 5f 66 6c 61 67 0a  09 43 4d 50 09 61 33 2c  |te_flag..CMP.a3,|
000031d0  20 23 65 76 5f 62 75 66  66 65 72 0a 09 41 44 52  | #ev_buffer..ADR|
000031e0  45 51 09 61 32 2c 20 62  75 66 66 65 72 5f 65 76  |EQ.a2, buffer_ev|
000031f0  65 6e 74 73 0a 09 53 54  4d 44 42 09 77 32 2c 20  |ents..STMDB.w2, |
00003200  7b 61 31 2c 20 61 32 2c  20 77 31 7d 0a 09 43 4d  |{a1, a2, w1}..CM|
00003210  50 09 72 30 2c 20 23 2d  32 0a 09 53 54 52 45 51  |P.r0, #-2..STREQ|
00003220  09 72 30 2c 20 5b 77 32  5d 0a 09 4d 4f 56 53 09  |.r0, [w2]..MOVS.|
00003230  70 63 2c 20 72 31 34 0a  0a 0a 52 65 6d 6f 76 65  |pc, r14...Remove|
00003240  48 61 6e 64 6c 65 72 0a  09 43 4d 50 09 72 30 2c  |Handler..CMP.r0,|
00003250  20 23 2d 32 0a 09 4d 4f  56 45 51 53 09 70 63 2c  | #-2..MOVEQS.pc,|
00003260  20 72 31 34 0a 30 31 09  4c 44 4d 49 41 09 77 32  | r14.01.LDMIA.w2|
00003270  2c 20 7b 61 31 2d 61 33  7d 0a 09 53 54 4d 44 42  |, {a1-a3}..STMDB|
00003280  09 77 32 2c 20 7b 61 31  2d 61 33 7d 0a 09 41 44  |.w2, {a1-a3}..AD|
00003290  44 09 77 31 2c 20 77 31  2c 20 23 31 32 0a 09 43  |D.w1, w1, #12..C|
000032a0  4d 50 09 61 31 2c 20 23  2d 32 0a 09 42 4e 45 09  |MP.a1, #-2..BNE.|
000032b0  25 42 30 31 0a 09 4d 4f  56 53 09 70 63 2c 20 72  |%B01..MOVS.pc, r|
000032c0  31 34 0a 0a 0a 75 6e 64  65 66 09 53 54 4d 46 44  |14...undef.STMFD|
000032d0  09 72 31 33 21 2c 20 7b  72 31 34 7d 0a 09 4d 4f  |.r13!, {r14}..MO|
000032e0  56 09 72 31 34 2c 20 23  45 72 72 6f 72 5f 49 6c  |V.r14, #Error_Il|
000032f0  6c 65 67 61 6c 49 6e 73  74 72 75 63 74 69 6f 6e  |legalInstruction|
00003300  0a 09 42 09 61 62 6f 72  74 65 64 0a 0a 70 72 65  |..B.aborted..pre|
00003310  66 09 53 54 4d 46 44 09  72 31 33 21 2c 20 7b 72  |f.STMFD.r13!, {r|
00003320  31 34 7d 0a 09 4d 4f 56  09 72 31 34 2c 20 23 45  |14}..MOV.r14, #E|
00003330  72 72 6f 72 5f 50 72 65  66 65 74 63 68 41 62 6f  |rror_PrefetchAbo|
00003340  72 74 0a 09 42 09 61 62  6f 72 74 65 64 0a 0a 64  |rt..B.aborted..d|
00003350  61 74 61 61 62 09 53 54  4d 46 44 09 72 31 33 21  |ataab.STMFD.r13!|
00003360  2c 20 7b 72 31 34 7d 0a  09 4d 4f 56 09 72 31 34  |, {r14}..MOV.r14|
00003370  2c 20 23 45 72 72 6f 72  5f 44 61 74 61 41 62 6f  |, #Error_DataAbo|
00003380  72 74 0a 09 42 09 61 62  6f 72 74 65 64 0a 0a 61  |rt..B.aborted..a|
00003390  64 64 72 65 78 09 53 54  4d 46 44 09 72 31 33 21  |ddrex.STMFD.r13!|
000033a0  2c 20 7b 72 31 34 7d 0a  09 4d 4f 56 09 72 31 34  |, {r14}..MOV.r14|
000033b0  2c 20 23 45 72 72 6f 72  5f 41 64 64 72 65 73 73  |, #Error_Address|
000033c0  45 78 63 65 70 74 69 6f  6e 0a 09 42 09 61 62 6f  |Exception..B.abo|
000033d0  72 74 65 64 0a 0a 61 62  6f 72 74 65 64 0a 3b 20  |rted..aborted.; |
000033e0  65 6e 74 72 79 20 68 65  72 65 20 69 6e 20 53 56  |entry here in SV|
000033f0  43 20 6d 6f 64 65 2c 20  20 72 31 34 20 73 65 74  |C mode,  r14 set|
00003400  20 74 6f 20 74 68 65 20  74 79 70 65 20 6f 66 20  | to the type of |
00003410  61 62 6f 72 74 0a 3b 20  61 6c 6c 20 75 73 65 72  |abort.; all user|
00003420  20 72 65 67 69 73 74 65  72 73 20 61 72 65 20 61  | registers are a|
00003430  73 20 61 74 20 74 68 65  20 74 69 6d 65 20 6f 66  |s at the time of|
00003440  20 74 68 65 20 61 62 6f  72 74 2e 0a 3b 20 57 65  | the abort..; We|
00003450  20 66 61 62 72 69 63 61  74 65 20 61 20 63 61 6c  | fabricate a cal|
00003460  6c 20 66 72 6f 6d 20 74  68 65 20 70 6f 69 6e 74  |l from the point|
00003470  20 6f 66 20 74 68 65 20  65 72 72 6f 72 20 74 6f  | of the error to|
00003480  20 41 42 4f 52 54 2c 0a  3b 20 6c 69 66 74 69 6e  | ABORT,.; liftin|
00003490  67 20 74 68 65 20 73 74  61 63 6b 20 61 20 62 69  |g the stack a bi|
000034a0  74 20 74 6f 20 61 6c 6c  6f 77 20 66 6f 72 20 64  |t to allow for d|
000034b0  65 61 74 68 20 61 74 20  75 6e 66 6f 72 74 75 6e  |eath at unfortun|
000034c0  61 74 65 0a 3b 20 74 69  6d 65 73 2e 20 20 57 65  |ate.; times.  We|
000034d0  20 61 73 73 75 6d 65 20  74 68 61 74 20 72 70 20  | assume that rp |
000034e0  61 6e 64 20 72 67 20 68  61 76 65 20 6e 6f 74 20  |and rg have not |
000034f0  62 65 65 6e 20 74 6f 6f  20 62 61 64 6c 79 20 73  |been too badly s|
00003500  61 76 61 67 65 64 2e 0a  09 53 54 4d 46 44 09 72  |avaged...STMFD.r|
00003510  31 33 21 2c 20 7b 72 31  34 7d 0a 09 4c 44 52 09  |13!, {r14}..LDR.|
00003520  72 31 34 2c 20 4c 6f 63  61 6c 44 61 74 61 50 0a  |r14, LocalDataP.|
00003530  09 41 44 44 09 72 31 34  2c 20 72 31 34 2c 20 23  |.ADD.r14, r14, #|
00003540  4f 5f 72 65 67 44 75 6d  70 0a 09 53 54 4d 49 41  |O_regDump..STMIA|
00003550  09 72 31 34 2c 20 7b 72  30 2d 72 31 34 7d 5e 0a  |.r14, {r0-r14}^.|
00003560  09 4c 44 4d 46 44 09 72  31 33 21 2c 20 7b 72 31  |.LDMFD.r13!, {r1|
00003570  2c 20 72 32 7d 0a 61 62  6f 72 74 65 64 43 61 6c  |, r2}.abortedCal|
00003580  6c 41 62 6f 72 74 0a 09  54 53 54 50 09 70 63 2c  |lAbort..TSTP.pc,|
00003590  20 23 30 09 09 09 3b 20  62 61 63 6b 20 74 6f 20  | #0...; back to |
000035a0  75 73 65 72 20 6d 6f 64  65 0a 09 4c 44 52 09 72  |user mode..LDR.r|
000035b0  67 62 2c 20 47 6c 6f 62  73 50 09 09 3b 20 69 6e  |gb, GlobsP..; in|
000035c0  20 63 61 73 65 20 64 65  73 74 72 6f 79 65 64 0a  | case destroyed.|
000035d0  09 41 44 44 09 72 67 62  2c 20 72 67 62 2c 20 23  |.ADD.rgb, rgb, #|
000035e0  26 34 30 30 30 30 30 30  30 09 3b 20 28 74 68 61  |&40000000.; (tha|
000035f0  74 20 69 73 20 74 68 65  20 5a 20 50 53 52 20 62  |t is the Z PSR b|
00003600  69 74 29 0a 09 41 44 44  09 72 74 73 2c 20 72 70  |it)..ADD.rts, rp|
00003610  2c 20 23 32 30 30 09 09  3b 20 69 67 6e 6f 72 65  |, #200..; ignore|
00003620  20 77 68 61 74 20 69 74  20 77 61 73 20 28 3f 29  | what it was (?)|
00003630  0a 09 4c 44 52 09 72 62  2c 20 5b 72 67 2c 20 23  |..LDR.rb, [rg, #|
00003640  47 5f 41 62 6f 72 74 5d  0a 09 4d 4f 56 09 72 31  |G_Abort]..MOV.r1|
00003650  34 2c 20 72 32 20 09 09  3b 20 74 68 65 20 70 6c  |4, r2 ..; the pl|
00003660  61 63 65 20 6f 66 20 74  68 65 20 66 61 75 6c 74  |ace of the fault|
00003670  20 28 75 6e 61 64 6a 75  73 74 65 64 29 0a 09 4d  | (unadjusted)..M|
00003680  4f 56 09 70 63 2c 20 72  62 0a 0a 20 47 6c 6f 62  |OV.pc, rb.. Glob|
00003690  44 65 66 20 33 35 2c 53  74 6f 70 0a 0a 09 53 54  |Def 35,Stop...ST|
000036a0  52 09 61 31 2c 20 5b 72  67 2c 20 23 47 5f 72 65  |R.a1, [rg, #G_re|
000036b0  74 75 72 6e 43 6f 64 65  5d 0a 09 4c 44 52 09 61  |turnCode]..LDR.a|
000036c0  33 2c 20 5b 72 67 2c 20  23 47 5f 73 74 61 63 6b  |3, [rg, #G_stack|
000036d0  42 61 73 65 5d 0a 09 4d  4f 56 09 61 33 2c 20 61  |Base]..MOV.a3, a|
000036e0  33 2c 20 41 53 4c 20 23  32 0a 09 4c 44 52 09 61  |3, ASL #2..LDR.a|
000036f0  32 2c 20 5b 61 33 2c 20  23 63 62 5f 63 61 6c 6c  |2, [a3, #cb_call|
00003700  65 72 5d 0a 09 41 44 44  09 72 70 2c 20 61 33 2c  |er]..ADD.rp, a3,|
00003710  20 23 63 62 5f 72 65 61  6c 5f 73 74 61 63 6b 0a  | #cb_real_stack.|
00003720  09 43 4d 4e 09 61 32 2c  20 23 31 09 09 3b 20 69  |.CMN.a2, #1..; i|
00003730  66 20 63 75 72 72 65 6e  74 20 63 6f 72 6f 75 74  |f current corout|
00003740  69 6e 65 20 69 73 20 72  6f 6f 74 2c 0a 09 42 45  |ine is root,..BE|
00003750  51 09 57 69 6e 64 55 70  09 09 3b 20 74 65 72 6d  |Q.WindUp..; term|
00003760  69 6e 61 74 65 20 63 6f  6d 70 6c 65 74 65 6c 79  |inate completely|
00003770  0a 09 42 09 43 72 65 61  74 65 43 6f 32 0a 0a 20  |..B.CreateCo2.. |
00003780  47 6c 6f 62 44 65 66 20  31 30 31 2c 4f 53 43 4c  |GlobDef 101,OSCL|
00003790  49 0a 0a 20 3b 20 6f 73  63 6c 69 20 63 6f 6d 6d  |I.. ; oscli comm|
000037a0  61 6e 64 0a 20 3b 20 63  6f 6d 6d 61 6e 64 20 69  |and. ; command i|
000037b0  73 20 61 20 42 43 50 4c  20 73 74 72 69 6e 67 20  |s a BCPL string |
000037c0  28 73 6f 20 6e 65 65 64  73 20 63 6f 6e 76 65 72  |(so needs conver|
000037d0  73 69 6f 6e 29 0a 20 3b  20 52 65 74 75 72 6e 73  |sion). ; Returns|
000037e0  20 46 61 6c 73 65 20 69  66 20 74 68 65 20 63 6f  | False if the co|
000037f0  6d 6d 61 6e 64 20 66 61  69 6c 73 2c 20 54 72 75  |mmand fails, Tru|
00003800  65 20 6f 74 68 65 72 77  69 73 65 0a 20 3b 20 49  |e otherwise. ; I|
00003810  66 20 74 68 65 20 62 61  73 65 20 6f 66 20 74 68  |f the base of th|
00003820  69 73 20 70 72 6f 67 72  61 6d 20 69 73 20 6e 6f  |is program is no|
00003830  74 20 31 30 30 30 2c 20  74 68 65 6e 20 69 74 0a  |t 1000, then it.|
00003840  20 3b 20 74 72 69 65 73  20 74 6f 20 72 75 6e 20  | ; tries to run |
00003850  74 68 65 20 63 6f 6d 6d  61 6e 64 20 61 73 20 61  |the command as a|
00003860  20 73 75 62 2d 70 72 6f  67 72 61 6d 2e 0a 0a 09  | sub-program....|
00003870  53 54 4d 45 41 09 72 74  73 21 2c 20 7b 72 31 34  |STMEA.rts!, {r14|
00003880  7d 0a 09 4d 4f 56 09 72  31 2c 20 61 31 2c 20 41  |}..MOV.r1, a1, A|
00003890  53 4c 20 23 32 0a 09 4d  4f 56 09 72 32 2c 20 23  |SL #2..MOV.r2, #|
000038a0  30 0a 09 42 4c 09 63 72  74 65 72 6d 0a 09 4c 44  |0..BL.crterm..LD|
000038b0  52 09 72 30 2c 20 3d 42  61 73 65 41 64 64 72 65  |R.r0, =BaseAddre|
000038c0  73 73 2a 32 0a 09 53 55  42 53 09 72 35 2c 20 70  |ss*2..SUBS.r5, p|
000038d0  63 2c 20 72 30 0a 09 4d  4f 56 09 72 30 2c 20 72  |c, r0..MOV.r0, r|
000038e0  31 0a 09 42 4c 45 09 6f  73 63 6c 69 5f 6e 6f 5f  |1..BLE.oscli_no_|
000038f0  73 75 62 70 0a 0a 6f 73  63 6c 69 78 09 53 54 4d  |subp..osclix.STM|
00003900  45 41 09 72 74 73 21 2c  20 7b 72 30 2c 20 72 32  |EA.rts!, {r0, r2|
00003910  20 2d 20 72 34 2c 20 72  36 2c 20 72 37 2c 20 72  | - r4, r6, r7, r|
00003920  67 7d 0a 0a 09 41 44 52  09 72 30 2c 20 6f 73 63  |g}...ADR.r0, osc|
00003930  6c 69 5f 65 78 69 74 0a  09 41 44 44 09 72 31 2c  |li_exit..ADD.r1,|
00003940  20 72 35 2c 20 23 42 61  73 65 41 64 64 72 65 73  | r5, #BaseAddres|
00003950  73 09 3b 20 6e 65 77 20  6d 65 6d 6f 72 79 20 6c  |s.; new memory l|
00003960  69 6d 69 74 0a 09 4d 4f  56 09 72 32 2c 20 23 30  |imit..MOV.r2, #0|
00003970  09 09 09 3b 20 6e 6f 20  63 68 61 6e 67 65 20 74  |...; no change t|
00003980  6f 20 72 65 61 6c 20 6d  65 6d 6f 72 79 20 65 6e  |o real memory en|
00003990  64 0a 09 4d 56 4e 09 72  33 2c 20 23 31 09 09 09  |d..MVN.r3, #1...|
000039a0  3b 09 20 20 20 20 6f 72  20 6c 6f 63 61 6c 20 62  |;.    or local b|
000039b0  75 66 66 65 72 69 6e 67  0a 09 4c 44 52 09 72 31  |uffering..LDR.r1|
000039c0  34 2c 20 4c 6f 63 61 6c  44 61 74 61 50 20 09 3b  |4, LocalDataP .;|
000039d0  20 72 65 73 65 74 20 61  62 6f 72 74 20 68 61 6e  | reset abort han|
000039e0  64 6c 65 72 73 20 74 6f  20 69 6e 69 74 69 61 6c  |dlers to initial|
000039f0  20 73 65 74 0a 09 41 44  44 09 72 34 2c 20 72 31  | set..ADD.r4, r1|
00003a00  34 2c 20 23 4f 5f 6f 6c  64 41 62 6f 72 74 48 61  |4, #O_oldAbortHa|
00003a10  6e 64 6c 65 72 73 0a 09  4c 44 4d 49 41 09 72 34  |ndlers..LDMIA.r4|
00003a20  2c 20 7b 72 34 2d 72 37  7d 0a 09 53 57 49 09 53  |, {r4-r7}..SWI.S|
00003a30  65 74 45 6e 76 0a 0a 09  41 44 44 09 72 35 2c 20  |etEnv...ADD.r5, |
00003a40  72 31 34 2c 20 23 4f 5f  63 6c 69 45 6e 76 53 61  |r14, #O_cliEnvSa|
00003a50  76 65 0a 09 53 54 4d 49  41 09 72 35 21 2c 20 7b  |ve..STMIA.r5!, {|
00003a60  72 30 20 2d 20 72 33 7d  0a 09 4c 44 4d 45 41 09  |r0 - r3}..LDMEA.|
00003a70  72 74 73 21 2c 20 7b 72  36 2c 20 72 37 2c 20 72  |rts!, {r6, r7, r|
00003a80  67 7d 0a 0a 09 41 44 44  09 72 30 2c 20 72 31 34  |g}...ADD.r0, r14|
00003a90  2c 20 23 4f 5f 6f 6c 64  43 61 6c 6c 42 61 63 6b  |, #O_oldCallBack|
00003aa0  52 65 67 69 73 74 65 72  73 0a 09 4c 44 4d 49 41  |Registers..LDMIA|
00003ab0  09 72 30 2c 20 7b 72 30  2c 20 72 31 7d 0a 09 53  |.r0, {r0, r1}..S|
00003ac0  57 49 09 43 61 6c 6c 42  61 63 6b 0a 0a 09 4d 4f  |WI.CallBack...MO|
00003ad0  56 09 72 31 2c 20 23 30  09 09 3b 20 6c 65 61 76  |V.r1, #0..; leav|
00003ae0  65 20 74 68 65 20 65 72  72 6f 72 20 62 75 66 66  |e the error buff|
00003af0  65 72 0a 09 41 44 52 09  72 30 2c 20 45 72 72 6f  |er..ADR.r0, Erro|
00003b00  72 49 6e 43 4c 49 09 3b  20 61 6e 64 20 69 6e 73  |rInCLI.; and ins|
00003b10  65 72 74 20 61 20 6e 65  77 20 65 72 72 6f 72 20  |ert a new error |
00003b20  68 61 6e 64 6c 65 72 0a  09 4c 44 52 09 72 32 2c  |handler..LDR.r2,|
00003b30  20 5b 72 31 34 2c 20 23  4f 5f 6f 6c 64 45 73 63  | [r14, #O_oldEsc|
00003b40  61 70 65 48 61 6e 64 6c  65 72 5d 0a 09 4d 4f 56  |apeHandler]..MOV|
00003b50  09 72 33 2c 20 23 30 09  09 3b 20 6c 65 61 76 65  |.r3, #0..; leave|
00003b60  20 6d 79 20 65 76 65 6e  74 20 68 61 6e 64 6c 65  | my event handle|
00003b70  72 20 69 6e 0a 09 53 57  49 09 43 6f 6e 74 72 6f  |r in..SWI.Contro|
00003b80  6c 0a 0a 09 4c 44 4d 45  41 09 72 74 73 21 2c 20  |l...LDMEA.rts!, |
00003b90  7b 72 30 2c 20 72 32 20  2d 20 72 34 7d 0a 09 53  |{r0, r2 - r4}..S|
00003ba0  54 4d 49 41 09 72 35 21  2c 20 7b 72 31 20 2d 20  |TMIA.r5!, {r1 - |
00003bb0  72 31 33 7d 0a 09 53 57  49 09 43 4c 49 0a 09 4d  |r13}..SWI.CLI..M|
00003bc0  4f 56 56 43 09 72 30 2c  20 23 2d 31 0a 09 4d 4f  |OVVC.r0, #-1..MO|
00003bd0  56 56 53 09 72 30 2c 20  23 30 0a 09 42 09 6f 73  |VVS.r0, #0..B.os|
00003be0  63 6c 69 5f 65 78 69 74  5f 32 0a 0a 6f 73 63 6c  |cli_exit_2..oscl|
00003bf0  69 5f 65 78 69 74 0a 09  4d 4f 56 09 72 30 2c 20  |i_exit..MOV.r0, |
00003c00  23 2d 31 0a 6f 73 63 6c  69 5f 65 78 69 74 5f 32  |#-1.oscli_exit_2|
00003c10  0a 09 54 53 54 50 09 70  63 2c 20 23 30 0a 09 4c  |..TSTP.pc, #0..L|
00003c20  44 52 09 72 31 34 2c 20  4c 6f 63 61 6c 44 61 74  |DR.r14, LocalDat|
00003c30  61 50 0a 09 53 54 52 09  72 30 2c 20 5b 72 31 34  |aP..STR.r0, [r14|
00003c40  2c 20 23 4f 5f 63 6c 69  53 74 61 74 75 73 5d 0a  |, #O_cliStatus].|
00003c50  09 41 44 44 09 72 35 2c  20 72 31 34 2c 20 23 4f  |.ADD.r5, r14, #O|
00003c60  5f 63 6c 69 52 31 54 6f  52 31 33 53 61 76 65 0a  |_cliR1ToR13Save.|
00003c70  09 4c 44 4d 49 41 09 72  35 2c 20 7b 72 31 20 2d  |.LDMIA.r5, {r1 -|
00003c80  20 72 31 33 7d 0a 09 53  54 4d 45 41 09 72 74 73  | r13}..STMEA.rts|
00003c90  21 2c 20 7b 72 32 20 2d  20 72 34 2c 20 72 36 2c  |!, {r2 - r4, r6,|
00003ca0  20 72 37 7d 0a 0a 09 41  44 44 09 72 35 2c 20 72  | r7}...ADD.r5, r|
00003cb0  31 34 2c 20 23 4f 5f 63  6c 69 45 6e 76 53 61 76  |14, #O_cliEnvSav|
00003cc0  65 0a 09 4c 44 4d 49 41  09 72 35 21 2c 20 7b 72  |e..LDMIA.r5!, {r|
00003cd0  30 20 2d 20 72 33 7d 0a  09 41 44 44 09 72 34 2c  |0 - r3}..ADD.r4,|
00003ce0  20 72 31 34 2c 20 23 4f  5f 6d 79 41 62 6f 72 74  | r14, #O_myAbort|
00003cf0  48 61 6e 64 6c 65 72 73  0a 09 4c 44 4d 49 41 09  |Handlers..LDMIA.|
00003d00  72 34 2c 20 7b 72 34 20  2d 20 72 37 7d 0a 09 53  |r4, {r4 - r7}..S|
00003d10  57 49 09 53 65 74 45 6e  76 0a 0a 09 41 44 44 09  |WI.SetEnv...ADD.|
00003d20  72 30 2c 20 72 31 34 2c  20 23 4f 5f 72 65 67 44  |r0, r14, #O_regD|
00003d30  75 6d 70 0a 09 41 44 52  09 72 31 2c 20 43 61 6c  |ump..ADR.r1, Cal|
00003d40  6c 42 61 63 6b 48 61 6e  64 6c 65 72 0a 09 53 57  |lBackHandler..SW|
00003d50  49 09 43 61 6c 6c 42 61  63 6b 0a 0a 09 41 44 52  |I.CallBack...ADR|
00003d60  09 72 30 2c 20 45 72 72  6f 72 48 61 6e 64 6c 65  |.r0, ErrorHandle|
00003d70  72 0a 09 41 44 44 09 72  31 2c 20 72 31 34 2c 20  |r..ADD.r1, r14, |
00003d80  23 4f 5f 65 72 72 6f 72  42 75 66 66 65 72 0a 09  |#O_errorBuffer..|
00003d90  41 44 52 09 72 32 2c 20  45 73 63 61 70 65 48 61  |ADR.r2, EscapeHa|
00003da0  6e 64 6c 65 72 0a 09 41  44 52 09 72 33 2c 20 45  |ndler..ADR.r3, E|
00003db0  76 65 6e 74 48 61 6e 64  6c 65 72 0a 09 53 57 49  |ventHandler..SWI|
00003dc0  09 43 6f 6e 74 72 6f 6c  0a 0a 09 3b 20 54 6f 20  |.Control...; To |
00003dd0  6b 65 65 70 20 41 72 74  68 75 72 20 68 61 70 70  |keep Arthur happ|
00003de0  79 2c 20 6d 61 6b 65 20  73 75 72 65 20 63 61 6c  |y, make sure cal|
00003df0  6c 62 61 63 6b 20 69 73  20 61 6c 77 61 79 73 20  |lback is always |
00003e00  75 73 65 64 20 66 6f 72  0a 09 3b 20 74 68 65 20  |used for..; the |
00003e10  61 63 6b 6e 6f 77 6c 65  64 67 65 6d 65 6e 74 20  |acknowledgement |
00003e20  6f 66 20 65 73 63 61 70  65 20 65 76 65 6e 74 73  |of escape events|
00003e30  0a 09 4d 4f 56 09 72 30  2c 20 23 39 0a 09 4d 4f  |..MOV.r0, #9..MO|
00003e40  56 09 72 31 2c 20 23 30  0a 09 4d 4f 56 09 72 32  |V.r1, #0..MOV.r2|
00003e50  2c 20 23 2d 31 0a 09 53  57 49 09 36 34 0a 0a 09  |, #-1..SWI.64...|
00003e60  4c 44 4d 45 41 09 72 74  73 21 2c 20 7b 72 32 20  |LDMEA.rts!, {r2 |
00003e70  2d 20 72 34 2c 20 72 36  2c 20 72 37 7d 0a 09 4c  |- r4, r6, r7}..L|
00003e80  44 52 09 72 30 2c 20 5b  72 31 34 2c 20 23 4f 5f  |DR.r0, [r14, #O_|
00003e90  63 6c 69 53 74 61 74 75  73 5d 0a 09 42 09 61 66  |cliStatus]..B.af|
00003ea0  74 65 72 6f 73 66 0a 0a  6f 73 63 6c 69 5f 6e 6f  |terosf..oscli_no|
00003eb0  5f 73 75 62 70 0a 09 53  57 49 09 43 4c 49 0a 09  |_subp..SWI.CLI..|
00003ec0  4d 4f 56 56 43 09 72 30  2c 20 23 2d 31 0a 09 4d  |MOVVC.r0, #-1..M|
00003ed0  4f 56 56 53 09 72 30 2c  20 23 30 0a 09 42 09 61  |OVVS.r0, #0..B.a|
00003ee0  66 74 65 72 6f 73 66 0a  0a 45 72 72 6f 72 49 6e  |fterosf..ErrorIn|
00003ef0  43 4c 49 0a 09 4d 4f 56  09 72 30 2c 20 23 30 0a  |CLI..MOV.r0, #0.|
00003f00  09 42 09 6f 73 63 6c 69  5f 65 78 69 74 5f 32 0a  |.B.oscli_exit_2.|
00003f10  0a 09 26 09 2d 31 0a 09  3d 09 37 2c 20 22 43 61  |..&.-1..=.7, "Ca|
00003f20  6c 6c 20 20 20 22 0a 0a  43 61 6c 6c 47 6c 6f 62  |ll   "..CallGlob|
00003f30  0a 09 4d 4f 56 09 70 63  2c 20 72 62 0a 0a 72 65  |..MOV.pc, rb..re|
00003f40  6c 6f 63 73 74 61 72 74  20 26 20 26 31 32 33 34  |locstart & &1234|
00003f50  35 36 37 38 0a 72 65 6c  6f 63 65 6e 64 20 26 20  |5678.relocend & |
00003f60  26 38 37 36 35 34 33 32  31 0a 0a 20 5b 20 6c 69  |&87654321.. [ li|
00003f70  73 70 6d 6f 64 65 3d 31  0a 4c 69 73 70 45 6e 74  |spmode=1.LispEnt|
00003f80  72 79 43 6f 75 6e 74 0a  3b 20 66 69 78 65 64 20  |ryCount.; fixed |
00003f90  6f 66 66 73 65 74 09 2d  26 20 20 66 72 6f 6d 20  |offset.-&  from |
00003fa0  47 6c 6f 62 73 0a 20 3b  20 70 72 6f 66 69 6c 65  |Globs. ; profile|
00003fb0  20 63 6f 75 6e 74 73 20  6f 66 20 70 72 6f 63 65  | counts of proce|
00003fc0  64 75 72 65 20 65 6e 74  72 79 2e 0a 20 3b 20 63  |dure entry.. ; c|
00003fd0  61 6c 6c 65 64 20 62 79  20 20 6a 75 6d 70 20 20  |alled by  jump  |
00003fe0  61 73 20 66 69 72 73 74  20 69 6e 73 74 72 75 63  |as first instruc|
00003ff0  74 69 6f 6e 20 6f 66 20  66 75 6e 63 74 69 6f 6e  |tion of function|
00004000  0a 20 3b 20 66 6f 6c 6c  6f 77 65 64 20 62 79 20  |. ; followed by |
00004010  66 75 6c 6c 2d 77 6f 72  64 20 63 6f 75 6e 74 20  |full-word count |
00004020  74 6f 20 69 6e 63 72 65  6d 65 6e 74 2e 0a 20 3b  |to increment.. ;|
00004030  20 4e 6f 20 72 65 67 69  73 74 65 72 73 20 68 61  | No registers ha|
00004040  76 65 20 62 65 65 6e 20  73 61 76 65 64 3a 20 74  |ve been saved: t|
00004050  68 69 73 20 72 6f 75 74  69 6e 65 20 64 6f 65 73  |his routine does|
00004060  0a 20 3b 20 74 68 61 74  2e 20 20 52 65 74 75 72  |. ; that.  Retur|
00004070  6e 20 69 73 20 74 6f 09  72 62 2b 38 20 20 28 69  |n is to.rb+8  (i|
00004080  65 20 74 68 65 20 69 6e  73 74 72 75 63 74 69 6f  |e the instructio|
00004090  6e 20 61 66 74 65 72 0a  20 3b 20 74 68 65 20 63  |n after. ; the c|
000040a0  6f 75 6e 74 29 2e 0a 09  53 54 4d 45 41 09 72 74  |ount)...STMEA.rt|
000040b0  73 21 2c 20 7b 72 31 34  2c 20 72 62 2c 20 72 6c  |s!, {r14, rb, rl|
000040c0  2c 20 72 70 7d 0a 09 53  55 42 09 72 70 2c 20 72  |, rp}..SUB.rp, r|
000040d0  74 73 2c 20 23 31 36 0a  09 42 49 43 09 72 31 34  |ts, #16..BIC.r14|
000040e0  2c 20 72 62 2c 20 23 26  66 66 30 30 30 30 30 30  |, rb, #&ff000000|
000040f0  0a 09 4c 44 52 09 72 30  2c 20 5b 72 31 34 2c 20  |..LDR.r0, [r14, |
00004100  23 34 5d 0a 09 41 44 44  09 72 30 2c 20 72 30 2c  |#4]..ADD.r0, r0,|
00004110  20 23 31 0a 09 53 54 52  09 72 30 2c 20 5b 72 31  | #1..STR.r0, [r1|
00004120  34 2c 20 23 34 5d 0a 09  41 44 44 09 70 63 2c 20  |4, #4]..ADD.pc, |
00004130  72 62 2c 20 23 38 0a 0a  3b 20 42 6c 69 6e 6b 20  |rb, #8..; Blink |
00004140  61 6e 64 20 42 65 78 69  74 20 61 72 65 20 65 6e  |and Bexit are en|
00004150  74 72 79 20 61 6e 64 20  65 78 69 74 20 73 65 71  |try and exit seq|
00004160  75 65 6e 63 65 73 20 66  6f 72 20 73 6d 61 6c 6c  |uences for small|
00004170  0a 3b 20 73 75 62 72 6f  75 74 69 6e 65 73 20 63  |.; subroutines c|
00004180  72 65 61 74 65 64 20 62  79 20 74 68 65 20 62 6c  |reated by the bl|
00004190  6f 63 6b 20 63 6f 6d 70  69 6c 65 72 20 66 72 6f  |ock compiler fro|
000041a0  6d 20 73 70 6f 74 74 69  6e 67 0a 3b 20 69 64 65  |m spotting.; ide|
000041b0  6e 74 69 63 61 6c 20 70  69 65 63 65 73 20 6f 66  |ntical pieces of|
000041c0  20 63 6f 64 65 2e 20 20  54 68 65 20 73 75 62 72  | code.  The subr|
000041d0  6f 75 74 69 6e 65 73 20  70 72 65 73 75 6d 61 62  |outines presumab|
000041e0  6c 79 20 6d 61 79 0a 3b  20 6e 6f 74 20 64 6f 20  |ly may.; not do |
000041f0  6d 75 63 68 20 28 6e 6f  20 74 65 73 74 20 66 6f  |much (no test fo|
00004200  72 20 67 61 72 62 61 67  65 20 63 6f 6c 6c 65 63  |r garbage collec|
00004210  74 69 6f 6e 20 69 6e 20  74 68 65 20 63 61 6c 6c  |tion in the call|
00004220  0a 3b 20 73 65 71 75 65  6e 63 65 29 2e 20 20 54  |.; sequence).  T|
00004230  68 65 20 63 61 6c 6c 20  61 64 64 73 20 61 20 6c  |he call adds a l|
00004240  69 6e 6b 20 74 6f 20 74  68 65 20 74 6f 70 20 6f  |ink to the top o|
00004250  66 20 74 68 65 20 63 75  72 72 65 6e 74 0a 3b 20  |f the current.; |
00004260  73 74 61 63 6b 20 66 72  61 6d 65 20 28 6d 61 64  |stack frame (mad|
00004270  65 20 72 65 6c 61 74 69  76 65 20 74 6f 20 74 68  |e relative to th|
00004280  65 20 62 6c 6f 63 6b 20  62 61 73 65 20 73 6f 20  |e block base so |
00004290  67 61 72 62 61 67 65 0a  3b 20 63 6f 6c 6c 65 63  |garbage.; collec|
000042a0  74 69 6f 6e 20 6e 65 65  64 6e 27 74 20 77 6f 72  |tion needn't wor|
000042b0  72 79 20 61 62 6f 75 74  20 69 74 29 2e 20 20 4e  |ry about it).  N|
000042c0  6f 74 65 20 74 68 61 74  20 74 68 65 20 6c 69 6e  |ote that the lin|
000042d0  6b 20 68 61 73 0a 3b 20  69 74 73 20 74 6f 70 20  |k has.; its top |
000042e0  38 20 62 69 74 73 20 72  65 6d 6f 76 65 64 2c 20  |8 bits removed, |
000042f0  73 6f 20 63 61 6c 6c 73  20 6f 66 20 73 75 63 68  |so calls of such|
00004300  20 72 6f 75 74 69 6e 65  73 20 6d 75 73 74 20 62  | routines must b|
00004310  65 0a 3b 20 65 78 65 63  75 74 65 64 20 63 6f 6e  |e.; executed con|
00004320  64 69 74 69 6f 6e 61 6c  6c 79 20 6f 6e 6c 79 20  |ditionally only |
00004330  69 66 20 74 68 65 79 20  61 72 65 20 74 68 65 20  |if they are the |
00004340  6c 61 73 74 20 74 68 69  6e 67 73 20 74 68 61 74  |last things that|
00004350  0a 3b 20 61 72 65 2e 0a  3b 20 4f 6e 20 65 6e 74  |.; are..; On ent|
00004360  72 79 20 74 6f 20 62 6f  74 68 20 6f 66 20 74 68  |ry to both of th|
00004370  65 20 73 65 71 75 65 6e  63 65 73 2c 20 72 62 20  |e sequences, rb |
00004380  6d 75 73 74 20 62 65 20  6c 6f 61 64 65 64 20 77  |must be loaded w|
00004390  69 74 68 20 74 68 65 0a  3b 20 61 64 64 72 65 73  |ith the.; addres|
000043a0  73 20 6f 66 20 74 68 65  20 62 61 73 65 20 6f 66  |s of the base of|
000043b0  20 74 68 65 20 62 6c 6f  63 6b 2e 0a 0a 42 6c 69  | the block...Bli|
000043c0  6e 6b 09 42 49 43 09 77  32 2c 20 72 31 34 2c 20  |nk.BIC.w2, r14, |
000043d0  23 50 5f 6b 65 79 0a 09  4c 44 52 09 77 31 2c 20  |#P_key..LDR.w1, |
000043e0  5b 77 32 5d 2c 20 23 2b  34 0a 09 53 55 42 09 77  |[w2], #+4..SUB.w|
000043f0  32 2c 20 77 32 2c 20 72  62 0a 09 42 49 43 09 77  |2, w2, rb..BIC.w|
00004400  32 2c 20 77 32 2c 20 23  50 5f 6b 65 79 0a 09 53  |2, w2, #P_key..S|
00004410  54 4d 45 41 09 72 74 73  21 2c 20 7b 77 32 7d 0a  |TMEA.rts!, {w2}.|
00004420  09 41 44 44 09 70 63 2c  20 72 62 2c 20 77 31 0a  |.ADD.pc, rb, w1.|
00004430  0a 42 45 78 69 74 09 4c  44 4d 45 41 09 72 74 73  |.BExit.LDMEA.rts|
00004440  21 2c 20 7b 72 31 34 7d  0a 09 41 44 44 09 70 63  |!, {r14}..ADD.pc|
00004450  2c 20 72 31 34 2c 20 72  62 0a 0a 09 42 43 61 6c  |, r14, rb...BCal|
00004460  6c 09 30 0a 09 42 43 61  6c 6c 09 31 0a 09 42 43  |l.0..BCall.1..BC|
00004470  61 6c 6c 09 32 0a 09 42  43 61 6c 6c 09 33 0a 0a  |all.2..BCall.3..|
00004480  09 58 43 61 6c 6c 09 4e  0a 09 58 43 61 6c 6c 09  |.XCall.N..XCall.|
00004490  33 0a 09 58 43 61 6c 6c  09 32 0a 09 58 43 61 6c  |3..XCall.2..XCal|
000044a0  6c 09 31 0a 09 58 43 61  6c 6c 09 30 0a 0a 09 43  |l.1..XCall.0...C|
000044b0  61 6c 6c 4e 09 46 4e 0a  09 43 61 6c 6c 4e 09 4e  |allN.FN..CallN.N|
000044c0  0a 0a 09 43 61 6c 6c 09  46 0a 09 43 61 6c 6c 09  |...Call.F..Call.|
000044d0  4c 0a 09 43 61 6c 6c 09  33 0a 09 43 61 6c 6c 09  |L..Call.3..Call.|
000044e0  32 0a 09 43 61 6c 6c 09  31 0a 09 43 61 6c 6c 09  |2..Call.1..Call.|
000044f0  30 0a 20 5d 0a 0a 47 6c  6f 62 73 0a 09 42 09 57  |0. ]..Globs..B.W|
00004500  69 6e 64 55 70 0a 0a 20  5b 20 61 6f 66 0a 09 45  |indUp.. [ aof..E|
00004510  58 50 4f 52 54 09 7c 53  79 73 4c 69 62 2e 5f 4d  |XPORT.|SysLib._M|
00004520  75 6c 74 7c 0a 7c 53 79  73 4c 69 62 2e 5f 4d 75  |ult|.|SysLib._Mu|
00004530  6c 74 7c 0a 20 5d 0a 69  74 69 6d 65 73 0a 3b 20  |lt|. ].itimes.; |
00004540  66 69 78 65 64 20 6f 66  66 73 65 74 09 26 34 20  |fixed offset.&4 |
00004550  20 66 72 6f 6d 20 47 6c  6f 62 73 0a 20 3b 20 33  | from Globs. ; 3|
00004560  32 20 2a 20 33 32 20 62  69 74 20 6d 75 6c 74 69  |2 * 32 bit multi|
00004570  70 6c 79 20 2d 3e 20 33  32 20 62 69 74 73 3a 20  |ply -> 32 bits: |
00004580  6e 6f 20 6f 76 65 72 66  6c 6f 77 20 64 65 74 65  |no overflow dete|
00004590  63 74 69 6f 6e 0a 20 3b  20 61 72 67 75 6d 65 6e  |ction. ; argumen|
000045a0  74 73 20 69 6e 20 61 31  20 61 6e 64 20 61 32 3b  |ts in a1 and a2;|
000045b0  20 72 65 73 75 6c 74 20  69 6e 20 61 31 20 77 69  | result in a1 wi|
000045c0  74 68 20 61 32 20 64 65  73 74 72 6f 79 65 64 0a  |th a2 destroyed.|
000045d0  20 3b 20 6f 74 68 65 72  20 72 65 67 69 73 74 65  | ; other registe|
000045e0  72 73 20 70 72 65 73 65  72 76 65 64 0a 20 3b 20  |rs preserved. ; |
000045f0  75 73 65 73 20 67 6c 6f  62 61 6c 73 20 2d 31 20  |uses globals -1 |
00004600  26 20 2d 32 20 61 73 20  77 6f 72 6b 73 70 61 63  |& -2 as workspac|
00004610  65 0a 09 53 54 4d 44 42  09 72 67 2c 20 7b 77 31  |e..STMDB.rg, {w1|
00004620  2c 20 72 31 34 7d 0a 09  4d 4f 56 09 77 31 2c 20  |, r14}..MOV.w1, |
00004630  23 30 0a 09 4d 4f 56 53  09 72 31 34 2c 20 61 32  |#0..MOVS.r14, a2|
00004640  0a 09 52 53 42 4d 49 09  72 31 34 2c 20 72 31 34  |..RSBMI.r14, r14|
00004650  2c 20 23 30 0a 31 30 09  4d 4f 56 53 09 72 31 34  |, #0.10.MOVS.r14|
00004660  2c 20 72 31 34 2c 20 4c  53 52 20 23 31 0a 09 41  |, r14, LSR #1..A|
00004670  44 44 43 53 09 77 31 2c  20 77 31 2c 20 61 31 0a  |DDCS.w1, w1, a1.|
00004680  09 4d 4f 56 09 61 31 2c  20 61 31 2c 20 41 53 4c  |.MOV.a1, a1, ASL|
00004690  20 23 31 0a 09 42 4e 45  09 25 31 30 0a 09 4d 4f  | #1..BNE.%10..MO|
000046a0  56 09 61 31 2c 20 77 31  0a 09 54 45 51 53 09 61  |V.a1, w1..TEQS.a|
000046b0  32 2c 20 23 30 0a 09 52  53 42 4d 49 09 61 31 2c  |2, #0..RSBMI.a1,|
000046c0  20 61 31 2c 20 23 30 0a  09 4c 44 4d 44 42 09 72  | a1, #0..LDMDB.r|
000046d0  67 2c 20 7b 77 31 2c 20  70 63 7d 5e 0a 0a 20 5b  |g, {w1, pc}^.. [|
000046e0  20 61 6f 66 0a 09 45 58  50 4f 52 54 09 7c 53 79  | aof..EXPORT.|Sy|
000046f0  73 4c 69 62 2e 5f 51 75  6f 74 52 65 6d 7c 0a 7c  |sLib._QuotRem|.||
00004700  53 79 73 4c 69 62 2e 5f  51 75 6f 74 52 65 6d 7c  |SysLib._QuotRem||
00004710  0a 20 5d 0a 71 75 6f 74  72 65 6d 0a 3b 20 66 69  |. ].quotrem.; fi|
00004720  78 65 64 20 6f 66 66 73  65 74 09 26 33 34 20 20  |xed offset.&34  |
00004730  66 72 6f 6d 20 47 6c 6f  62 73 0a 20 3b 20 33 32  |from Globs. ; 32|
00004740  20 62 69 74 20 64 69 76  69 64 65 0a 20 3b 20 64  | bit divide. ; d|
00004750  69 76 69 64 65 6e 64 20  69 6e 20 61 31 2c 20 64  |ividend in a1, d|
00004760  69 76 69 73 6f 72 20 69  6e 20 61 32 0a 20 3b 20  |ivisor in a2. ; |
00004770  71 75 6f 74 69 65 6e 74  20 72 65 74 75 72 6e 65  |quotient returne|
00004780  64 20 69 6e 20 61 31 2c  20 72 65 6d 61 69 6e 64  |d in a1, remaind|
00004790  65 72 20 69 6e 20 61 32  0a 20 3b 20 6f 74 68 65  |er in a2. ; othe|
000047a0  72 20 72 65 67 69 73 74  65 72 73 20 70 72 65 73  |r registers pres|
000047b0  65 72 76 65 64 0a 20 3b  20 75 73 65 73 20 67 6c  |erved. ; uses gl|
000047c0  6f 62 61 6c 73 20 2d 31  20 74 6f 20 2d 34 20 69  |obals -1 to -4 i|
000047d0  6e 63 6c 75 73 69 76 65  20 61 73 20 77 6f 72 6b  |nclusive as work|
000047e0  73 70 61 63 65 0a 09 53  54 4d 44 42 09 72 67 2c  |space..STMDB.rg,|
000047f0  20 7b 61 33 2c 20 61 34  2c 20 77 32 2c 20 72 31  | {a3, a4, w2, r1|
00004800  34 7d 0a 09 4d 4f 56 53  09 72 31 34 2c 20 61 31  |4}..MOVS.r14, a1|
00004810  0a 09 52 53 42 4d 49 09  72 31 34 2c 20 72 31 34  |..RSBMI.r14, r14|
00004820  2c 20 23 30 0a 09 4d 4f  56 53 09 61 33 2c 20 61  |, #0..MOVS.a3, a|
00004830  32 0a 09 42 45 51 09 64  69 76 69 64 65 62 79 30  |2..BEQ.divideby0|
00004840  0a 09 52 53 42 4d 49 09  61 33 2c 20 61 33 2c 20  |..RSBMI.a3, a3, |
00004850  23 30 0a 09 4d 4f 56 09  61 34 2c 20 23 30 0a 09  |#0..MOV.a4, #0..|
00004860  4d 4f 56 09 77 32 2c 20  23 31 0a 31 31 09 43 4d  |MOV.w2, #1.11.CM|
00004870  50 53 09 61 33 2c 20 23  26 38 30 30 30 30 30 30  |PS.a3, #&8000000|
00004880  30 0a 09 43 4d 50 43 43  53 09 61 33 2c 20 72 31  |0..CMPCCS.a3, r1|
00004890  34 0a 09 4d 4f 56 43 43  09 61 33 2c 20 61 33 2c  |4..MOVCC.a3, a3,|
000048a0  20 41 53 4c 20 23 31 0a  09 4d 4f 56 43 43 09 77  | ASL #1..MOVCC.w|
000048b0  32 2c 20 77 32 2c 20 41  53 4c 20 23 31 0a 09 42  |2, w2, ASL #1..B|
000048c0  43 43 09 25 31 31 0a 0a  31 32 09 43 4d 50 53 09  |CC.%11..12.CMPS.|
000048d0  61 33 2c 20 72 31 34 0a  09 41 44 44 4c 53 09 61  |a3, r14..ADDLS.a|
000048e0  34 2c 20 61 34 2c 20 77  32 0a 09 53 55 42 4c 53  |4, a4, w2..SUBLS|
000048f0  09 72 31 34 2c 20 72 31  34 2c 20 61 33 0a 09 4d  |.r14, r14, a3..M|
00004900  4f 56 53 09 77 32 2c 20  77 32 2c 20 4c 53 52 20  |OVS.w2, w2, LSR |
00004910  23 31 0a 09 4d 4f 56 4e  45 09 61 33 2c 20 61 33  |#1..MOVNE.a3, a3|
00004920  2c 20 4c 53 52 20 23 31  0a 09 42 4e 45 09 25 31  |, LSR #1..BNE.%1|
00004930  32 0a 0a 09 54 45 51 53  09 61 31 2c 20 61 32 0a  |2...TEQS.a1, a2.|
00004940  09 52 53 42 4d 49 09 61  34 2c 20 61 34 2c 20 23  |.RSBMI.a4, a4, #|
00004950  30 0a 09 43 4d 50 53 09  61 31 2c 20 23 30 0a 09  |0..CMPS.a1, #0..|
00004960  4d 4f 56 09 61 32 2c 20  72 31 34 0a 09 52 53 42  |MOV.a2, r14..RSB|
00004970  4c 54 09 61 32 2c 20 61  32 2c 20 23 30 0a 09 4d  |LT.a2, a2, #0..M|
00004980  4f 56 09 61 31 2c 20 61  34 0a 09 4c 44 4d 44 42  |OV.a1, a4..LDMDB|
00004990  09 72 67 2c 20 7b 61 33  2c 20 61 34 2c 20 77 32  |.rg, {a3, a4, w2|
000049a0  2c 20 70 63 7d 5e 0a 09  4d 4f 56 4e 56 09 72 30  |, pc}^..MOVNV.r0|
000049b0  2c 20 72 30 0a 0a 65 6e  74 72 79 63 6f 75 6e 74  |, r0..entrycount|
000049c0  0a 3b 20 66 69 78 65 64  20 6f 66 66 73 65 74 09  |.; fixed offset.|
000049d0  26 61 30 20 20 66 72 6f  6d 20 47 6c 6f 62 73 0a  |&a0  from Globs.|
000049e0  20 3b 20 70 72 6f 66 69  6c 65 20 63 6f 75 6e 74  | ; profile count|
000049f0  73 20 6f 66 20 70 72 6f  63 65 64 75 72 65 20 65  |s of procedure e|
00004a00  6e 74 72 79 2e 0a 20 3b  20 63 61 6c 6c 65 64 20  |ntry.. ; called |
00004a10  62 79 20 20 6a 75 6d 70  20 20 61 73 20 66 69 72  |by  jump  as fir|
00004a20  73 74 20 69 6e 73 74 72  75 63 74 69 6f 6e 20 6f  |st instruction o|
00004a30  66 20 70 72 6f 63 65 64  75 72 65 2c 0a 20 3b 20  |f procedure,. ; |
00004a40  66 6f 6c 6c 6f 77 65 64  20 62 79 20 66 75 6c 6c  |followed by full|
00004a50  2d 77 6f 72 64 20 63 6f  75 6e 74 20 74 6f 20 69  |-word count to i|
00004a60  6e 63 72 65 6d 65 6e 74  2e 0a 20 3b 20 4e 6f 20  |ncrement.. ; No |
00004a70  72 65 67 69 73 74 65 72  73 20 68 61 76 65 20 62  |registers have b|
00004a80  65 65 6e 20 73 61 76 65  64 3a 20 74 68 69 73 20  |een saved: this |
00004a90  72 6f 75 74 69 6e 65 20  64 6f 65 73 0a 20 3b 20  |routine does. ; |
00004aa0  74 68 61 74 2e 20 20 52  65 74 75 72 6e 20 69 73  |that.  Return is|
00004ab0  20 74 6f 09 72 62 2b 38  20 20 28 69 65 20 74 68  | to.rb+8  (ie th|
00004ac0  65 20 69 6e 73 74 72 75  63 74 69 6f 6e 20 61 66  |e instruction af|
00004ad0  74 65 72 0a 20 3b 20 74  68 65 20 63 6f 75 6e 74  |ter. ; the count|
00004ae0  29 2e 0a 09 53 54 4d 45  41 09 72 74 73 21 2c 20  |)...STMEA.rts!, |
00004af0  7b 72 31 34 2c 20 72 62  2c 20 72 6c 2c 20 72 70  |{r14, rb, rl, rp|
00004b00  7d 0a 09 53 55 42 09 72  70 2c 20 72 74 73 2c 20  |}..SUB.rp, rts, |
00004b10  23 31 36 0a 09 4c 44 52  09 72 6c 2c 20 5b 72 62  |#16..LDR.rl, [rb|
00004b20  2c 20 23 2d 34 5d 09 09  3b 20 74 68 61 74 20 77  |, #-4]..; that w|
00004b30  61 73 20 74 68 65 20 73  74 61 6e 64 61 72 64 20  |as the standard |
00004b40  65 6e 74 72 79 20 73 65  71 75 65 6e 63 65 0a 09  |entry sequence..|
00004b50  4c 44 52 09 72 30 2c 20  5b 72 62 2c 20 23 34 5d  |LDR.r0, [rb, #4]|
00004b60  0a 09 41 44 44 09 72 30  2c 20 72 30 2c 20 23 31  |..ADD.r0, r0, #1|
00004b70  0a 09 53 54 52 09 72 30  2c 20 5b 72 62 2c 20 23  |..STR.r0, [rb, #|
00004b80  34 5d 0a 09 41 44 44 09  70 63 2c 20 72 62 2c 20  |4]..ADD.pc, rb, |
00004b90  23 38 0a 0a 20 5b 20 61  6f 66 0a 09 45 58 50 4f  |#8.. [ aof..EXPO|
00004ba0  52 54 09 7c 53 79 73 4c  69 62 2e 5f 43 6f 75 6e  |RT.|SysLib._Coun|
00004bb0  74 7c 0a 7c 53 79 73 4c  69 62 2e 5f 43 6f 75 6e  |t|.|SysLib._Coun|
00004bc0  74 7c 0a 20 5d 0a 63 6f  75 6e 74 0a 3b 20 66 69  |t|. ].count.; fi|
00004bd0  78 65 64 20 6f 66 66 73  65 74 09 26 62 63 20 20  |xed offset.&bc  |
00004be0  66 72 6f 6d 20 47 6c 6f  62 73 0a 20 3b 20 6f 74  |from Globs. ; ot|
00004bf0  68 65 72 20 70 72 6f 66  69 6c 65 20 63 6f 75 6e  |her profile coun|
00004c00  74 73 2e 20 20 43 61 6c  6c 65 64 20 62 79 20 62  |ts.  Called by b|
00004c10  72 61 6e 63 68 20 26 20  6c 69 6e 6b 2c 20 66 6f  |ranch & link, fo|
00004c20  6c 6c 6f 77 65 64 0a 20  3b 20 62 79 20 66 75 6c  |llowed. ; by ful|
00004c30  6c 2d 77 6f 72 64 20 63  6f 75 6e 74 2e 09 52 65  |l-word count..Re|
00004c40  74 75 72 6e 20 74 6f 20  20 6c 69 6e 6b 2b 34 2e  |turn to  link+4.|
00004c50  0a 20 3b 20 43 61 6e 27  74 20 75 73 65 20 6c 69  |. ; Can't use li|
00004c60  6e 6b 20 64 69 72 65 63  74 6c 79 20 74 6f 20 61  |nk directly to a|
00004c70  63 63 65 73 73 20 74 68  65 20 63 6f 75 6e 74 2c  |ccess the count,|
00004c80  20 63 6f 73 20 6f 66 20  50 53 52 2e 0a 20 3b 20  | cos of PSR.. ; |
00004c90  44 65 73 74 72 6f 79 73  20 6e 6f 20 72 65 67 69  |Destroys no regi|
00004ca0  73 74 65 72 73 0a 09 41  44 44 09 72 31 34 2c 20  |sters..ADD.r14, |
00004cb0  72 31 34 2c 20 23 34 0a  09 53 54 4d 44 42 09 72  |r14, #4..STMDB.r|
00004cc0  67 2c 20 7b 72 30 2c 20  72 31 34 7d 0a 09 42 49  |g, {r0, r14}..BI|
00004cd0  43 09 72 31 34 2c 20 72  31 34 2c 20 23 50 53 52  |C.r14, r14, #PSR|
00004ce0  42 69 74 73 0a 09 4c 44  52 09 72 30 2c 20 5b 77  |Bits..LDR.r0, [w|
00004cf0  32 2c 20 23 30 5d 0a 09  41 44 44 09 72 30 2c 20  |2, #0]..ADD.r0, |
00004d00  72 30 2c 20 23 31 0a 09  53 54 52 09 72 30 2c 20  |r0, #1..STR.r0, |
00004d10  5b 77 32 2c 20 23 30 5d  0a 09 4c 44 4d 44 42 09  |[w2, #0]..LDMDB.|
00004d20  72 67 2c 20 7b 72 30 2c  20 70 63 7d 5e 0a 0a 20  |rg, {r0, pc}^.. |
00004d30  5b 20 6c 69 73 70 6d 6f  64 65 3d 31 0a 20 3b 20  |[ lispmode=1. ; |
00004d40  69 74 20 69 73 20 63 61  72 65 66 75 6c 6c 79 20  |it is carefully |
00004d50  61 72 72 61 6e 67 65 64  20 74 68 61 74 20 65 61  |arranged that ea|
00004d60  63 68 20 6f 66 20 74 68  65 20 66 6f 6c 6c 6f 77  |ch of the follow|
00004d70  69 6e 67 20 65 6e 74 72  69 65 73 0a 20 3b 20 73  |ing entries. ; s|
00004d80  74 61 72 74 73 20 6f 6e  20 61 20 31 36 2d 62 79  |tarts on a 16-by|
00004d90  74 65 20 62 6f 75 6e 64  61 72 79 20 74 6f 20 65  |te boundary to e|
00004da0  6e 73 75 72 65 20 74 68  61 74 20 61 6c 6c 20 6f  |nsure that all o|
00004db0  66 20 74 68 65 6d 0a 20  3b 20 66 69 74 20 69 6e  |f them. ; fit in|
00004dc0  20 74 68 65 20 64 69 73  70 6c 61 63 65 6d 65 6e  | the displacemen|
00004dd0  74 20 66 69 65 6c 64 20  6f 66 20 61 20 66 6f 72  |t field of a for|
00004de0  6d 61 74 20 31 20 69 6e  73 74 72 75 63 74 69 6f  |mat 1 instructio|
00004df0  6e 0a 78 63 6f 6e 73 0a  3b 20 66 69 78 65 64 20  |n.xcons.; fixed |
00004e00  6f 66 66 73 65 74 09 26  64 38 20 20 66 72 6f 6d  |offset.&d8  from|
00004e10  20 47 6c 6f 62 73 0a 09  45 4f 52 09 61 31 2c 20  | Globs..EOR.a1, |
00004e20  61 31 2c 20 61 32 0a 09  45 4f 52 09 61 32 2c 20  |a1, a2..EOR.a2, |
00004e30  61 32 2c 20 61 31 0a 09  45 4f 52 09 61 31 2c 20  |a2, a1..EOR.a1, |
00004e40  61 31 2c 20 61 32 0a 09  42 09 63 6f 6e 73 0a 6e  |a1, a2..B.cons.n|
00004e50  63 6f 6e 73 0a 3b 20 66  69 78 65 64 20 6f 66 66  |cons.; fixed off|
00004e60  73 65 74 09 26 65 38 20  20 66 72 6f 6d 20 47 6c  |set.&e8  from Gl|
00004e70  6f 62 73 0a 09 4d 4f 56  09 61 32 2c 20 6e 69 6c  |obs..MOV.a2, nil|
00004e80  0a 63 6f 6e 73 0a 3b 20  66 69 78 65 64 20 6f 66  |.cons.; fixed of|
00004e90  66 73 65 74 09 26 65 63  20 20 66 72 6f 6d 20 47  |fset.&ec  from G|
00004ea0  6c 6f 62 73 0a 09 4c 44  52 09 77 31 2c 20 5b 72  |lobs..LDR.w1, [r|
00004eb0  67 2c 20 23 47 5f 66 72  69 6e 67 65 5d 0a 09 43  |g, #G_fringe]..C|
00004ec0  4d 50 53 09 77 31 2c 20  72 74 73 0a 09 42 4c 54  |MPS.w1, rts..BLT|
00004ed0  09 63 6f 6e 73 67 63 0a  09 41 44 44 09 77 31 2c  |.consgc..ADD.w1,|
00004ee0  20 77 31 2c 20 23 46 72  69 6e 67 65 47 61 70 0a  | w1, #FringeGap.|
00004ef0  09 53 54 4d 46 44 09 77  31 21 2c 20 7b 61 31 2c  |.STMFD.w1!, {a1,|
00004f00  20 61 32 7d 0a 09 41 44  44 09 61 31 2c 20 77 31  | a2}..ADD.a1, w1|
00004f10  2c 20 23 50 5f 70 61 69  72 0a 09 53 55 42 09 77  |, #P_pair..SUB.w|
00004f20  31 2c 20 77 31 2c 20 23  46 72 69 6e 67 65 47 61  |1, w1, #FringeGa|
00004f30  70 0a 09 53 54 52 09 77  31 2c 20 5b 72 67 2c 20  |p..STR.w1, [rg, |
00004f40  23 47 5f 66 72 69 6e 67  65 5d 0a 09 4d 4f 56 53  |#G_fringe]..MOVS|
00004f50  09 70 63 2c 20 72 31 34  0a 0a 66 62 69 6e 64 0a  |.pc, r14..fbind.|
00004f60  3b 20 66 69 78 65 64 20  6f 66 66 73 65 74 09 26  |; fixed offset.&|
00004f70  31 31 30 20 20 66 72 6f  6d 20 47 6c 6f 62 73 0a  |110  from Globs.|
00004f80  09 53 54 4d 45 41 09 72  74 73 21 2c 20 7b 61 32  |.STMEA.rts!, {a2|
00004f90  2c 20 61 33 2c 20 72 31  34 7d 0a 09 53 55 42 09  |, a3, r14}..SUB.|
00004fa0  61 32 2c 20 77 32 2c 20  6e 69 6c 0a 09 4c 44 52  |a2, w2, nil..LDR|
00004fb0  09 77 32 2c 20 5b 77 32  5d 0a 62 69 6e 64 78 0a  |.w2, [w2].bindx.|
00004fc0  09 42 49 43 09 77 32 2c  20 77 32 2c 20 23 50 5f  |.BIC.w2, w2, #P_|
00004fd0  6b 65 79 0a 09 4c 44 4d  46 44 09 77 32 2c 20 7b  |key..LDMFD.w2, {|
00004fe0  77 31 2c 20 77 32 7d 0a  09 42 49 43 09 77 31 2c  |w1, w2}..BIC.w1,|
00004ff0  20 77 31 2c 20 23 50 5f  6b 65 79 0a 09 4c 44 4d  | w1, #P_key..LDM|
00005000  46 44 09 77 31 2c 20 7b  61 33 2c 20 77 31 7d 0a  |FD.w1, {a3, w1}.|
00005010  09 42 49 43 09 61 33 2c  20 61 33 2c 20 23 50 5f  |.BIC.a3, a3, #P_|
00005020  6b 65 79 0a 09 4c 44 52  09 72 31 34 2c 20 5b 61  |key..LDR.r14, [a|
00005030  33 5d 0a 09 53 54 52 09  72 31 34 2c 20 5b 72 70  |3]..STR.r14, [rp|
00005040  2c 20 77 31 5d 0a 09 53  54 52 09 6e 69 6c 2c 20  |, w1]..STR.nil, |
00005050  5b 61 33 5d 0a 09 43 4d  50 53 09 77 32 2c 20 6e  |[a3]..CMPS.w2, n|
00005060  69 6c 0a 09 42 48 49 09  62 69 6e 64 78 0a 09 41  |il..BHI.bindx..A|
00005070  44 44 09 61 32 2c 20 61  32 2c 20 23 50 5f 69 64  |DD.a2, a2, #P_id|
00005080  2b 50 5f 73 70 69 64 0a  09 53 54 52 09 61 32 2c  |+P_spid..STR.a2,|
00005090  20 5b 72 70 2c 20 77 32  5d 0a 09 4c 44 4d 45 41  | [rp, w2]..LDMEA|
000050a0  09 72 74 73 21 2c 20 7b  61 32 2c 20 61 33 2c 20  |.rts!, {a2, a3, |
000050b0  70 63 7d 5e 0a 0a 6c 69  73 70 65 78 69 74 09 3b  |pc}^..lispexit.;|
000050c0  20 6f 75 74 20 6f 66 20  6c 69 6e 65 2c 20 74 6f  | out of line, to|
000050d0  20 62 65 20 62 72 61 6e  63 68 65 64 20 74 6f 20  | be branched to |
000050e0  62 79 20 63 6f 6e 64 69  74 69 6f 6e 61 6c 20 65  |by conditional e|
000050f0  78 69 74 73 0a 3b 20 66  69 78 65 64 20 6f 66 66  |xits.; fixed off|
00005100  73 65 74 09 26 31 35 30  20 20 66 72 6f 6d 20 47  |set.&150  from G|
00005110  6c 6f 62 73 0a 09 4d 4f  56 09 72 74 73 2c 20 72  |lobs..MOV.rts, r|
00005120  70 0a 09 4c 44 4d 49 42  09 72 74 73 2c 20 7b 72  |p..LDMIB.rts, {r|
00005130  70 2c 20 72 6c 2c 20 70  63 7d 5e 0a 0a 66 75 6e  |p, rl, pc}^..fun|
00005140  62 69 6e 64 0a 3b 20 66  69 78 65 64 20 6f 66 66  |bind.; fixed off|
00005150  73 65 74 09 26 31 35 38  20 20 66 72 6f 6d 20 47  |set.&158  from G|
00005160  6c 6f 62 73 0a 09 53 54  4d 45 41 09 72 74 73 21  |lobs..STMEA.rts!|
00005170  2c 20 7b 61 33 2c 20 72  31 34 7d 0a 75 62 69 6e  |, {a3, r14}.ubin|
00005180  64 78 0a 09 42 49 43 09  77 32 2c 20 77 32 2c 20  |dx..BIC.w2, w2, |
00005190  23 50 5f 6b 65 79 0a 09  4c 44 4d 46 44 09 77 32  |#P_key..LDMFD.w2|
000051a0  2c 20 7b 77 31 2c 20 77  32 7d 0a 09 42 49 43 09  |, {w1, w2}..BIC.|
000051b0  77 31 2c 20 77 31 2c 20  23 50 5f 6b 65 79 0a 09  |w1, w1, #P_key..|
000051c0  4c 44 4d 46 44 09 77 31  2c 20 7b 61 33 2c 20 77  |LDMFD.w1, {a3, w|
000051d0  31 7d 0a 09 42 49 43 09  61 33 2c 20 61 33 2c 20  |1}..BIC.a3, a3, |
000051e0  23 50 5f 6b 65 79 0a 09  4c 44 52 09 72 31 34 2c  |#P_key..LDR.r14,|
000051f0  20 5b 72 70 2c 20 77 31  5d 0a 09 53 54 52 09 72  | [rp, w1]..STR.r|
00005200  31 34 2c 20 5b 61 33 5d  0a 09 43 4d 50 53 09 77  |14, [a3]..CMPS.w|
00005210  32 2c 20 6e 69 6c 0a 09  42 48 49 09 75 62 69 6e  |2, nil..BHI.ubin|
00005220  64 78 0a 09 53 54 52 09  6e 69 6c 2c 20 5b 72 70  |dx..STR.nil, [rp|
00005230  2c 20 77 32 5d 0a 09 4c  44 4d 45 41 09 72 74 73  |, w2]..LDMEA.rts|
00005240  21 2c 20 7b 61 33 2c 20  70 63 7d 5e 0a 0a 61 64  |!, {a3, pc}^..ad|
00005250  64 32 0a 3b 20 66 69 78  65 64 20 6f 66 66 73 65  |d2.; fixed offse|
00005260  74 09 26 31 38 38 20 20  66 72 6f 6d 20 47 6c 6f  |t.&188  from Glo|
00005270  62 73 0a 09 54 53 54 53  09 61 31 2c 20 23 50 5f  |bs..TSTS.a1, #P_|
00005280  6e 75 6d 73 6b 0a 09 54  53 54 45 51 53 09 61 32  |numsk..TSTEQS.a2|
00005290  2c 20 23 50 5f 6e 75 6d  73 6b 0a 09 42 4e 45 09  |, #P_numsk..BNE.|
000052a0  61 64 64 32 78 0a 09 4d  4f 56 09 61 33 2c 20 61  |add2x..MOV.a3, a|
000052b0  31 2c 20 4c 53 4c 20 23  37 0a 09 41 44 44 53 09  |1, LSL #7..ADDS.|
000052c0  61 33 2c 20 61 33 2c 20  61 32 2c 20 4c 53 4c 20  |a3, a3, a2, LSL |
000052d0  23 37 0a 09 4d 4f 56 56  43 09 61 31 2c 20 61 33  |#7..MOVVC.a1, a3|
000052e0  2c 20 4c 53 52 20 23 37  0a 09 4d 4f 56 56 43 53  |, LSR #7..MOVVCS|
000052f0  09 70 63 2c 20 72 31 34  0a 61 64 64 32 78 0a 09  |.pc, r14.add2x..|
00005300  4c 44 52 09 72 62 2c 20  5b 72 67 2c 20 23 47 5f  |LDR.rb, [rg, #G_|
00005310  41 64 64 5d 0a 09 4d 4f  56 09 70 63 2c 20 72 62  |Add]..MOV.pc, rb|
00005320  0a 0a 64 69 66 66 32 0a  3b 20 66 69 78 65 64 20  |..diff2.; fixed |
00005330  6f 66 66 73 65 74 09 26  31 61 63 20 20 66 72 6f  |offset.&1ac  fro|
00005340  6d 20 47 6c 6f 62 73 0a  09 54 53 54 53 09 61 31  |m Globs..TSTS.a1|
00005350  2c 20 23 50 5f 6e 75 6d  73 6b 0a 09 54 53 54 45  |, #P_numsk..TSTE|
00005360  51 53 09 61 32 2c 20 23  50 5f 6e 75 6d 73 6b 0a  |QS.a2, #P_numsk.|
00005370  09 42 4e 45 09 64 69 66  66 32 78 0a 09 4d 4f 56  |.BNE.diff2x..MOV|
00005380  09 61 33 2c 20 61 31 2c  20 4c 53 4c 20 23 37 0a  |.a3, a1, LSL #7.|
00005390  09 53 55 42 53 09 61 33  2c 20 61 33 2c 20 61 32  |.SUBS.a3, a3, a2|
000053a0  2c 20 4c 53 4c 20 23 37  0a 09 4d 4f 56 56 43 09  |, LSL #7..MOVVC.|
000053b0  61 31 2c 20 61 33 2c 20  4c 53 52 20 23 37 0a 09  |a1, a3, LSR #7..|
000053c0  4d 4f 56 56 43 53 09 70  63 2c 20 72 31 34 0a 64  |MOVVCS.pc, r14.d|
000053d0  69 66 66 32 78 0a 09 4c  44 52 09 72 62 2c 20 5b  |iff2x..LDR.rb, [|
000053e0  72 67 2c 20 23 47 5f 44  69 66 66 65 72 65 6e 63  |rg, #G_Differenc|
000053f0  65 5d 0a 09 4d 4f 56 09  70 63 2c 20 72 62 0a 0a  |e]..MOV.pc, rb..|
00005400  73 75 62 31 0a 3b 20 66  69 78 65 64 20 6f 66 66  |sub1.; fixed off|
00005410  73 65 74 09 26 31 64 30  20 20 66 72 6f 6d 20 47  |set.&1d0  from G|
00005420  6c 6f 62 73 0a 09 54 53  54 53 09 61 31 2c 20 23  |lobs..TSTS.a1, #|
00005430  50 5f 6e 75 6d 73 6b 0a  09 42 4e 45 09 73 75 62  |P_numsk..BNE.sub|
00005440  31 78 0a 09 43 4d 50 53  09 61 31 2c 20 23 50 5f  |1x..CMPS.a1, #P_|
00005450  73 67 6e 62 74 0a 09 53  55 42 4e 45 09 61 31 2c  |sgnbt..SUBNE.a1,|
00005460  20 61 31 2c 20 23 31 0a  09 42 49 43 4e 45 09 61  | a1, #1..BICNE.a|
00005470  31 2c 20 61 31 2c 20 23  50 5f 6e 75 6d 73 6b 0a  |1, a1, #P_numsk.|
00005480  09 4d 4f 56 4e 45 53 09  70 63 2c 20 72 31 34 0a  |.MOVNES.pc, r14.|
00005490  73 75 62 31 78 0a 09 4c  44 52 09 72 62 2c 20 5b  |sub1x..LDR.rb, [|
000054a0  72 67 2c 20 23 47 5f 53  75 62 31 5d 0a 09 4d 4f  |rg, #G_Sub1]..MO|
000054b0  56 09 70 63 2c 20 72 62  0a 0a 61 64 64 31 0a 3b  |V.pc, rb..add1.;|
000054c0  20 66 69 78 65 64 20 6f  66 66 73 65 74 09 26 31  | fixed offset.&1|
000054d0  66 30 20 20 66 72 6f 6d  20 47 6c 6f 62 73 0a 09  |f0  from Globs..|
000054e0  54 53 54 53 09 61 31 2c  20 23 50 5f 6e 75 6d 73  |TSTS.a1, #P_nums|
000054f0  6b 0a 09 42 4e 45 09 61  64 64 31 78 0a 09 41 44  |k..BNE.add1x..AD|
00005500  44 09 61 32 2c 20 61 31  2c 20 23 31 0a 09 43 4d  |D.a2, a1, #1..CM|
00005510  50 53 09 61 32 2c 20 23  50 5f 73 67 6e 62 74 0a  |PS.a2, #P_sgnbt.|
00005520  09 42 49 43 4e 45 09 61  31 2c 20 61 32 2c 20 23  |.BICNE.a1, a2, #|
00005530  50 5f 6e 75 6d 73 6b 0a  09 4d 4f 56 4e 45 53 09  |P_numsk..MOVNES.|
00005540  70 63 2c 20 72 31 34 0a  61 64 64 31 78 0a 09 4c  |pc, r14.add1x..L|
00005550  44 52 09 72 62 2c 20 5b  72 67 2c 20 23 47 5f 41  |DR.rb, [rg, #G_A|
00005560  64 64 31 5d 0a 09 4d 4f  56 09 70 63 2c 20 72 62  |dd1]..MOV.pc, rb|
00005570  0a 0a 65 71 75 61 6c 0a  3b 20 66 69 78 65 64 20  |..equal.; fixed |
00005580  6f 66 66 73 65 74 09 26  32 31 30 20 20 66 72 6f  |offset.&210  fro|
00005590  6d 20 47 6c 6f 62 73 0a  09 43 4d 50 53 09 61 31  |m Globs..CMPS.a1|
000055a0  2c 20 61 32 0a 09 4c 44  52 45 51 09 61 31 2c 20  |, a2..LDREQ.a1, |
000055b0  5b 72 67 2c 20 23 47 5f  74 72 75 65 5d 0a 09 4d  |[rg, #G_true]..M|
000055c0  4f 56 45 51 53 09 70 63  2c 20 72 31 34 0a 09 4c  |OVEQS.pc, r14..L|
000055d0  44 52 09 72 62 2c 20 5b  72 67 2c 20 23 47 5f 45  |DR.rb, [rg, #G_E|
000055e0  71 75 61 6c 5d 0a 09 4d  4f 56 09 70 63 2c 20 72  |qual]..MOV.pc, r|
000055f0  62 0a 0a 67 72 74 70 0a  3b 20 66 69 78 65 64 20  |b..grtp.; fixed |
00005600  6f 66 66 73 65 74 09 26  32 32 34 20 20 66 72 6f  |offset.&224  fro|
00005610  6d 20 47 6c 6f 62 73 0a  09 54 53 54 53 09 61 31  |m Globs..TSTS.a1|
00005620  2c 20 23 50 5f 6e 75 6d  73 6b 0a 09 54 53 54 45  |, #P_numsk..TSTE|
00005630  51 53 09 61 32 2c 20 23  50 5f 6e 75 6d 73 6b 0a  |QS.a2, #P_numsk.|
00005640  09 42 4e 45 09 67 72 74  78 0a 09 4d 4f 56 09 61  |.BNE.grtx..MOV.a|
00005650  33 2c 20 61 31 2c 20 4c  53 4c 20 23 37 0a 09 43  |3, a1, LSL #7..C|
00005660  4d 50 53 09 61 33 2c 20  61 32 2c 20 4c 53 4c 20  |MPS.a3, a2, LSL |
00005670  23 37 0a 09 4d 4f 56 4c  45 09 61 31 2c 20 6e 69  |#7..MOVLE.a1, ni|
00005680  6c 0a 09 4c 44 52 47 54  09 61 31 2c 20 5b 72 67  |l..LDRGT.a1, [rg|
00005690  2c 20 23 47 5f 74 72 75  65 5d 0a 09 4d 4f 56 53  |, #G_true]..MOVS|
000056a0  09 70 63 2c 20 72 31 34  0a 67 72 74 78 0a 09 4c  |.pc, r14.grtx..L|
000056b0  44 52 09 72 62 2c 20 5b  72 67 2c 20 23 47 5f 47  |DR.rb, [rg, #G_G|
000056c0  72 65 61 74 65 72 70 5d  0a 09 4d 4f 56 09 70 63  |reaterp]..MOV.pc|
000056d0  2c 20 72 62 0a 0a 6c 65  73 73 70 0a 3b 20 66 69  |, rb..lessp.; fi|
000056e0  78 65 64 20 6f 66 66 73  65 74 09 26 32 34 63 20  |xed offset.&24c |
000056f0  20 66 72 6f 6d 20 47 6c  6f 62 73 0a 09 54 53 54  | from Globs..TST|
00005700  53 09 61 31 2c 20 23 50  5f 6e 75 6d 73 6b 0a 09  |S.a1, #P_numsk..|
00005710  54 53 54 45 51 53 09 61  32 2c 20 23 50 5f 6e 75  |TSTEQS.a2, #P_nu|
00005720  6d 73 6b 0a 09 42 4e 45  09 6c 65 73 73 78 0a 09  |msk..BNE.lessx..|
00005730  4d 4f 56 09 61 33 2c 20  61 31 2c 20 4c 53 4c 20  |MOV.a3, a1, LSL |
00005740  23 37 0a 09 43 4d 50 53  09 61 33 2c 20 61 32 2c  |#7..CMPS.a3, a2,|
00005750  20 4c 53 4c 20 23 37 0a  09 4d 4f 56 47 45 09 61  | LSL #7..MOVGE.a|
00005760  31 2c 20 6e 69 6c 0a 09  4c 44 52 4c 54 09 61 31  |1, nil..LDRLT.a1|
00005770  2c 20 5b 72 67 2c 20 23  47 5f 74 72 75 65 5d 0a  |, [rg, #G_true].|
00005780  09 4d 4f 56 53 09 70 63  2c 20 72 31 34 0a 6c 65  |.MOVS.pc, r14.le|
00005790  73 73 78 0a 09 4c 44 52  09 72 62 2c 20 5b 72 67  |ssx..LDR.rb, [rg|
000057a0  2c 20 23 47 5f 4c 65 73  73 70 5d 0a 09 4d 4f 56  |, #G_Lessp]..MOV|
000057b0  09 70 63 2c 20 72 62 0a  0a 71 75 6f 74 69 65 6e  |.pc, rb..quotien|
000057c0  74 0a 3b 20 66 69 78 65  64 20 6f 66 66 73 65 74  |t.; fixed offset|
000057d0  09 26 32 37 34 20 20 66  72 6f 6d 20 47 6c 6f 62  |.&274  from Glob|
000057e0  73 0a 09 54 53 54 53 09  61 31 2c 20 23 50 5f 6e  |s..TSTS.a1, #P_n|
000057f0  75 6d 73 6b 0a 09 54 53  54 45 51 53 09 61 32 2c  |umsk..TSTEQS.a2,|
00005800  20 23 50 5f 6e 75 6d 73  6b 0a 09 42 4e 45 09 71  | #P_numsk..BNE.q|
00005810  75 6f 74 78 0a 09 4d 56  4e 09 72 33 2c 20 23 50  |uotx..MVN.r3, #P|
00005820  5f 6e 75 6d 73 6b 0a 09  43 4d 50 53 09 61 31 2c  |_numsk..CMPS.a1,|
00005830  20 23 50 5f 73 67 6e 62  74 0a 09 43 4d 50 45 51  | #P_sgnbt..CMPEQ|
00005840  53 09 61 32 2c 20 72 33  0a 09 42 4e 45 09 69 71  |S.a2, r3..BNE.iq|
00005850  75 6f 74 69 65 6e 74 0a  71 75 6f 74 78 0a 09 4c  |uotient.quotx..L|
00005860  44 52 09 72 62 2c 20 5b  72 67 2c 20 23 47 5f 51  |DR.rb, [rg, #G_Q|
00005870  75 6f 74 69 65 6e 74 5d  0a 09 4d 4f 56 09 70 63  |uotient]..MOV.pc|
00005880  2c 20 72 62 0a 0a 72 65  6d 61 69 6e 64 65 72 0a  |, rb..remainder.|
00005890  3b 20 66 69 78 65 64 20  6f 66 66 73 65 74 09 26  |; fixed offset.&|
000058a0  32 39 38 20 20 66 72 6f  6d 20 47 6c 6f 62 73 0a  |298  from Globs.|
000058b0  09 54 53 54 53 09 61 31  2c 20 23 50 5f 6e 75 6d  |.TSTS.a1, #P_num|
000058c0  73 6b 0a 09 54 53 54 45  51 53 09 61 32 2c 20 23  |sk..TSTEQS.a2, #|
000058d0  50 5f 6e 75 6d 73 6b 0a  09 42 45 51 09 69 72 65  |P_numsk..BEQ.ire|
000058e0  6d 61 69 6e 64 65 72 0a  09 4c 44 52 09 72 62 2c  |mainder..LDR.rb,|
000058f0  20 5b 72 67 2c 20 23 47  5f 52 65 6d 61 69 6e 64  | [rg, #G_Remaind|
00005900  65 72 5d 0a 09 4d 4f 56  09 70 63 2c 20 72 62 0a  |er]..MOV.pc, rb.|
00005910  0a 74 69 6d 65 73 0a 3b  20 66 69 78 65 64 20 6f  |.times.; fixed o|
00005920  66 66 73 65 74 09 26 32  61 63 20 20 66 72 6f 6d  |ffset.&2ac  from|
00005930  20 47 6c 6f 62 73 0a 09  54 53 54 53 09 61 31 2c  | Globs..TSTS.a1,|
00005940  20 23 50 5f 6e 75 6d 73  6b 0a 09 54 53 54 45 51  | #P_numsk..TSTEQ|
00005950  53 09 61 32 2c 20 23 50  5f 6e 75 6d 73 6b 0a 09  |S.a2, #P_numsk..|
00005960  42 4e 45 09 78 74 69 6d  65 73 0a 09 4d 4f 56 09  |BNE.xtimes..MOV.|
00005970  77 31 2c 20 23 30 0a 09  4d 4f 56 09 77 32 2c 20  |w1, #0..MOV.w2, |
00005980  61 31 2c 20 4c 53 4c 20  23 37 0a 09 4d 4f 56 53  |a1, LSL #7..MOVS|
00005990  09 72 33 2c 20 61 32 2c  20 4c 53 4c 20 23 37 0a  |.r3, a2, LSL #7.|
000059a0  09 4d 4f 56 09 72 33 2c  20 72 33 2c 20 41 53 52  |.MOV.r3, r3, ASR|
000059b0  20 23 37 0a 09 52 53 42  4c 54 09 72 33 2c 20 72  | #7..RSBLT.r3, r|
000059c0  33 2c 20 23 30 0a 35 31  0a 09 4d 4f 56 53 09 72  |3, #0.51..MOVS.r|
000059d0  33 2c 20 72 33 2c 20 4c  53 52 20 23 31 0a 09 41  |3, r3, LSR #1..A|
000059e0  44 44 43 53 53 09 77 31  2c 20 77 31 2c 20 77 32  |DDCSS.w1, w1, w2|
000059f0  0a 09 42 56 53 09 78 74  69 6d 65 73 0a 09 41 44  |..BVS.xtimes..AD|
00005a00  44 53 09 77 32 2c 20 77  32 2c 20 77 32 0a 09 42  |DS.w2, w2, w2..B|
00005a10  56 53 09 78 74 69 6d 65  73 0a 09 43 4d 50 53 09  |VS.xtimes..CMPS.|
00005a20  72 33 2c 20 23 30 0a 09  42 4e 45 09 25 35 31 0a  |r3, #0..BNE.%51.|
00005a30  09 54 53 54 53 09 61 32  2c 20 23 50 5f 73 67 6e  |.TSTS.a2, #P_sgn|
00005a40  62 74 0a 09 52 53 42 4e  45 09 77 31 2c 20 77 31  |bt..RSBNE.w1, w1|
00005a50  2c 20 23 30 0a 09 4d 4f  56 09 61 31 2c 20 77 31  |, #0..MOV.a1, w1|
00005a60  2c 20 4c 53 52 20 23 37  0a 09 4d 4f 56 53 09 70  |, LSR #7..MOVS.p|
00005a70  63 2c 20 72 31 34 0a 78  74 69 6d 65 73 0a 09 4c  |c, r14.xtimes..L|
00005a80  44 52 09 72 62 2c 20 5b  72 67 2c 20 23 47 5f 4d  |DR.rb, [rg, #G_M|
00005a90  75 6c 74 5d 0a 09 4d 4f  56 09 70 63 2c 20 72 62  |ult]..MOV.pc, rb|
00005aa0  0a 0a 69 71 75 6f 74 69  65 6e 74 0a 3b 20 66 69  |..iquotient.; fi|
00005ab0  78 65 64 20 6f 66 66 73  65 74 09 26 33 30 30 20  |xed offset.&300 |
00005ac0  20 66 72 6f 6d 20 47 6c  6f 62 73 0a 09 53 54 4d  | from Globs..STM|
00005ad0  44 42 09 72 67 2c 20 7b  72 30 2c 20 72 33 2c 20  |DB.rg, {r0, r3, |
00005ae0  72 34 2c 20 72 35 2c 20  72 31 34 7d 0a 09 4d 4f  |r4, r5, r14}..MO|
00005af0  56 53 09 72 31 34 2c 20  72 31 2c 20 41 53 4c 20  |VS.r14, r1, ASL |
00005b00  23 37 0a 09 52 53 42 4d  49 09 72 31 34 2c 20 72  |#7..RSBMI.r14, r|
00005b10  31 34 2c 20 23 30 0a 09  4d 4f 56 53 09 72 33 2c  |14, #0..MOVS.r3,|
00005b20  20 72 32 2c 20 41 53 4c  20 23 37 0a 09 42 45 51  | r2, ASL #7..BEQ|
00005b30  09 64 69 76 69 64 65 62  79 30 0a 09 52 53 42 4d  |.divideby0..RSBM|
00005b40  49 09 72 33 2c 20 72 33  2c 20 23 30 0a 09 4d 4f  |I.r3, r3, #0..MO|
00005b50  56 09 72 30 2c 20 72 33  0a 09 4d 4f 56 09 72 34  |V.r0, r3..MOV.r4|
00005b60  2c 20 23 30 0a 09 4d 4f  56 09 72 35 2c 20 23 31  |, #0..MOV.r5, #1|
00005b70  0a 33 31 0a 09 43 4d 50  53 09 72 33 2c 20 23 26  |.31..CMPS.r3, #&|
00005b80  38 30 30 30 30 30 30 30  0a 09 43 4d 50 43 43 53  |80000000..CMPCCS|
00005b90  09 72 33 2c 20 72 31 34  0a 09 4d 4f 56 43 43 09  |.r3, r14..MOVCC.|
00005ba0  72 33 2c 20 72 33 2c 20  41 53 4c 20 23 31 0a 09  |r3, r3, ASL #1..|
00005bb0  4d 4f 56 43 43 09 72 35  2c 20 72 35 2c 20 41 53  |MOVCC.r5, r5, AS|
00005bc0  4c 20 23 31 0a 09 42 43  43 09 25 33 31 0a 0a 33  |L #1..BCC.%31..3|
00005bd0  32 09 43 4d 50 53 09 72  33 2c 20 72 31 34 0a 09  |2.CMPS.r3, r14..|
00005be0  41 44 44 4c 53 09 72 34  2c 20 72 34 2c 20 72 35  |ADDLS.r4, r4, r5|
00005bf0  0a 09 53 55 42 4c 53 09  72 31 34 2c 20 72 31 34  |..SUBLS.r14, r14|
00005c00  2c 20 72 33 0a 09 4d 4f  56 53 09 72 35 2c 20 72  |, r3..MOVS.r5, r|
00005c10  35 2c 20 4c 53 52 20 23  31 0a 09 4d 4f 56 4e 45  |5, LSR #1..MOVNE|
00005c20  09 72 33 2c 20 72 33 2c  20 4c 53 52 20 23 31 0a  |.r3, r3, LSR #1.|
00005c30  09 42 4e 45 09 25 33 32  0a 09 42 09 49 51 75 6f  |.BNE.%32..B.IQuo|
00005c40  74 52 65 6d 46 69 78 53  69 67 6e 73 0a 09 26 20  |tRemFixSigns..& |
00005c50  30 0a 09 26 20 30 0a 09  26 20 30 0a 0a 0a 69 72  |0..& 0..& 0...ir|
00005c60  65 6d 61 69 6e 64 65 72  0a 3b 20 66 69 78 65 64  |emainder.; fixed|
00005c70  20 6f 66 66 73 65 74 09  26 33 36 30 20 20 66 72  | offset.&360  fr|
00005c80  6f 6d 20 47 6c 6f 62 73  0a 09 53 54 52 09 72 31  |om Globs..STR.r1|
00005c90  34 2c 20 5b 72 67 2c 20  23 2d 32 34 5d 0a 09 42  |4, [rg, #-24]..B|
00005ca0  4c 09 69 71 75 6f 74 69  65 6e 74 0a 09 4d 4f 56  |L.iquotient..MOV|
00005cb0  09 72 31 2c 20 72 31 34  2c 20 4c 53 52 20 23 37  |.r1, r14, LSR #7|
00005cc0  0a 09 4c 44 52 09 72 31  34 2c 20 5b 72 67 2c 20  |..LDR.r14, [rg, |
00005cd0  23 2d 32 34 5d 0a 09 4d  4f 56 53 09 70 63 2c 20  |#-24]..MOVS.pc, |
00005ce0  72 31 34 0a 0a 49 51 75  6f 74 52 65 6d 46 69 78  |r14..IQuotRemFix|
00005cf0  53 69 67 6e 73 0a 09 45  4f 52 09 72 32 2c 20 72  |Signs..EOR.r2, r|
00005d00  31 2c 20 72 32 0a 09 54  53 54 53 09 72 32 2c 20  |1, r2..TSTS.r2, |
00005d10  23 50 5f 73 67 6e 62 74  0a 09 42 45 51 09 49 51  |#P_sgnbt..BEQ.IQ|
00005d20  75 6f 74 52 65 6d 53 61  6d 65 53 69 67 6e 73 0a  |uotRemSameSigns.|
00005d30  09 52 53 42 09 72 34 2c  20 72 34 2c 20 23 30 0a  |.RSB.r4, r4, #0.|
00005d40  09 43 4d 50 53 09 72 31  34 2c 20 23 30 0a 09 53  |.CMPS.r14, #0..S|
00005d50  55 42 4e 45 09 72 34 2c  20 72 34 2c 20 23 31 0a  |UBNE.r4, r4, #1.|
00005d60  09 53 55 42 4e 45 09 72  31 34 2c 20 72 31 34 2c  |.SUBNE.r14, r14,|
00005d70  20 72 30 0a 49 51 75 6f  74 52 65 6d 53 61 6d 65  | r0.IQuotRemSame|
00005d80  53 69 67 6e 73 0a 09 54  53 54 53 09 72 31 2c 20  |Signs..TSTS.r1, |
00005d90  23 50 5f 73 67 6e 62 74  0a 09 52 53 42 4e 45 09  |#P_sgnbt..RSBNE.|
00005da0  72 31 34 2c 20 72 31 34  2c 20 23 30 0a 09 42 49  |r14, r14, #0..BI|
00005db0  43 09 72 31 2c 20 72 34  2c 20 23 50 5f 6e 75 6d  |C.r1, r4, #P_num|
00005dc0  73 6b 0a 09 4c 44 4d 44  42 09 72 67 2c 20 7b 72  |sk..LDMDB.rg, {r|
00005dd0  30 2c 20 72 33 2c 20 72  34 2c 20 72 35 2c 20 70  |0, r3, r4, r5, p|
00005de0  63 7d 5e 0a 09 26 20 30  0a 09 26 20 30 0a 09 26  |c}^..& 0..& 0..&|
00005df0  20 30 0a 0a 43 61 6c 6c  50 6f 6c 6c 0a 3b 20 66  | 0..CallPoll.; f|
00005e00  69 78 65 64 20 6f 66 66  73 65 74 09 26 33 61 63  |ixed offset.&3ac|
00005e10  20 20 66 72 6f 6d 20 47  6c 6f 62 73 0a 09 4c 44  |  from Globs..LD|
00005e20  52 09 72 62 2c 20 5b 72  67 2c 20 23 47 5f 50 6f  |R.rb, [rg, #G_Po|
00005e30  6c 6c 53 52 5d 0a 09 4d  4f 56 09 70 63 2c 20 72  |llSR]..MOV.pc, r|
00005e40  62 0a 0a 4c 69 73 74 32  0a 3b 20 66 69 78 65 64  |b..List2.; fixed|
00005e50  20 6f 66 66 73 65 74 09  26 33 62 34 20 20 66 72  | offset.&3b4  fr|
00005e60  6f 6d 20 47 6c 6f 62 73  0a 09 4c 44 52 09 77 32  |om Globs..LDR.w2|
00005e70  2c 20 5b 72 67 2c 20 23  47 5f 66 72 69 6e 67 65  |, [rg, #G_fringe|
00005e80  5d 0a 09 43 4d 50 53 09  77 32 2c 20 72 74 73 0a  |]..CMPS.w2, rts.|
00005e90  09 42 4c 54 09 67 63 5f  4c 69 73 74 32 0a 09 4d  |.BLT.gc_List2..M|
00005ea0  4f 56 09 61 33 2c 20 61  32 0a 09 41 44 44 09 77  |OV.a3, a2..ADD.w|
00005eb0  32 2c 20 77 32 2c 20 23  46 72 69 6e 67 65 47 61  |2, w2, #FringeGa|
00005ec0  70 0a 09 53 55 42 09 61  32 2c 20 77 32 2c 20 23  |p..SUB.a2, w2, #|
00005ed0  38 0a 09 41 44 44 09 61  32 2c 20 61 32 2c 20 23  |8..ADD.a2, a2, #|
00005ee0  50 5f 70 61 69 72 0a 09  53 54 4d 44 42 09 77 32  |P_pair..STMDB.w2|
00005ef0  21 2c 20 7b 61 31 2c 20  61 32 2c 20 61 33 2c 20  |!, {a1, a2, a3, |
00005f00  6e 69 6c 7d 0a 09 41 44  44 09 61 31 2c 20 77 32  |nil}..ADD.a1, w2|
00005f10  2c 20 23 50 5f 70 61 69  72 0a 09 53 55 42 09 77  |, #P_pair..SUB.w|
00005f20  32 2c 20 77 32 2c 20 23  46 72 69 6e 67 65 47 61  |2, w2, #FringeGa|
00005f30  70 0a 09 53 54 52 09 77  32 2c 20 5b 72 67 2c 20  |p..STR.w2, [rg, |
00005f40  23 47 5f 66 72 69 6e 67  65 5d 0a 09 4d 4f 56 53  |#G_fringe]..MOVS|
00005f50  09 70 63 2c 20 72 31 34  0a 0a 4c 69 73 74 32 53  |.pc, r14..List2S|
00005f60  74 61 72 0a 3b 20 66 69  78 65 64 20 6f 66 66 73  |tar.; fixed offs|
00005f70  65 74 09 26 33 65 34 20  20 66 72 6f 6d 20 47 6c  |et.&3e4  from Gl|
00005f80  6f 62 73 0a 09 4c 44 52  09 77 32 2c 20 5b 72 67  |obs..LDR.w2, [rg|
00005f90  2c 20 23 47 5f 66 72 69  6e 67 65 5d 0a 09 43 4d  |, #G_fringe]..CM|
00005fa0  50 53 09 77 32 2c 20 72  74 73 0a 09 42 4c 54 09  |PS.w2, rts..BLT.|
00005fb0  67 63 5f 4c 69 73 74 32  53 74 61 72 0a 09 4d 4f  |gc_List2Star..MO|
00005fc0  56 09 77 31 2c 20 61 33  0a 09 4d 4f 56 09 61 33  |V.w1, a3..MOV.a3|
00005fd0  2c 20 61 32 0a 09 41 44  44 09 77 32 2c 20 77 32  |, a2..ADD.w2, w2|
00005fe0  2c 20 23 46 72 69 6e 67  65 47 61 70 0a 09 53 55  |, #FringeGap..SU|
00005ff0  42 09 61 32 2c 20 77 32  2c 20 23 38 0a 09 41 44  |B.a2, w2, #8..AD|
00006000  44 09 61 32 2c 20 61 32  2c 20 23 50 5f 70 61 69  |D.a2, a2, #P_pai|
00006010  72 0a 09 53 54 4d 44 42  09 77 32 21 2c 20 7b 61  |r..STMDB.w2!, {a|
00006020  31 2c 20 61 32 2c 20 61  33 2c 20 77 31 7d 0a 09  |1, a2, a3, w1}..|
00006030  41 44 44 09 61 31 2c 20  77 32 2c 20 23 50 5f 70  |ADD.a1, w2, #P_p|
00006040  61 69 72 0a 09 53 55 42  09 77 32 2c 20 77 32 2c  |air..SUB.w2, w2,|
00006050  20 23 46 72 69 6e 67 65  47 61 70 0a 09 53 54 52  | #FringeGap..STR|
00006060  09 77 32 2c 20 5b 72 67  2c 20 23 47 5f 66 72 69  |.w2, [rg, #G_fri|
00006070  6e 67 65 5d 0a 09 4d 4f  56 53 09 70 63 2c 20 72  |nge]..MOVS.pc, r|
00006080  31 34 0a 09 4d 4f 56 4e  56 09 72 30 2c 72 30 0a  |14..MOVNV.r0,r0.|
00006090  09 4d 4f 56 4e 56 09 72  30 2c 72 30 0a 0a 4c 69  |.MOVNV.r0,r0..Li|
000060a0  73 74 33 0a 3b 20 66 69  78 65 64 20 6f 66 66 73  |st3.; fixed offs|
000060b0  65 74 09 26 34 32 30 20  20 66 72 6f 6d 20 47 6c  |et.&420  from Gl|
000060c0  6f 62 73 20 20 28 6d 75  73 74 20 62 65 20 2a 31  |obs  (must be *1|
000060d0  36 29 0a 09 4c 44 52 09  77 32 2c 20 5b 72 67 2c  |6)..LDR.w2, [rg,|
000060e0  20 23 47 5f 66 72 69 6e  67 65 5d 0a 09 43 4d 50  | #G_fringe]..CMP|
000060f0  53 09 77 32 2c 20 72 74  73 0a 09 42 4c 54 09 67  |S.w2, rts..BLT.g|
00006100  63 5f 4c 69 73 74 33 0a  09 41 44 44 09 77 32 2c  |c_List3..ADD.w2,|
00006110  20 77 32 2c 20 23 46 72  69 6e 67 65 47 61 70 0a  | w2, #FringeGap.|
00006120  09 53 54 4d 44 42 09 77  32 21 2c 20 7b 61 33 2c  |.STMDB.w2!, {a3,|
00006130  20 6e 69 6c 7d 0a 09 4d  4f 56 09 61 33 2c 20 61  | nil}..MOV.a3, a|
00006140  32 0a 09 41 44 44 09 77  31 2c 20 77 32 2c 20 23  |2..ADD.w1, w2, #|
00006150  50 5f 70 61 69 72 0a 09  53 55 42 09 61 32 2c 20  |P_pair..SUB.a2, |
00006160  77 31 2c 20 23 38 0a 09  53 54 4d 44 42 09 77 32  |w1, #8..STMDB.w2|
00006170  21 2c 20 7b 61 31 2c 20  61 32 2c 20 61 33 2c 20  |!, {a1, a2, a3, |
00006180  77 31 7d 0a 09 41 44 44  09 61 31 2c 20 77 32 2c  |w1}..ADD.a1, w2,|
00006190  20 23 50 5f 70 61 69 72  0a 09 53 55 42 09 77 32  | #P_pair..SUB.w2|
000061a0  2c 20 77 32 2c 20 23 46  72 69 6e 67 65 47 61 70  |, w2, #FringeGap|
000061b0  0a 09 53 54 52 09 77 32  2c 20 5b 72 67 2c 20 23  |..STR.w2, [rg, #|
000061c0  47 5f 66 72 69 6e 67 65  5d 0a 09 4d 4f 56 53 09  |G_fringe]..MOVS.|
000061d0  70 63 2c 20 72 31 34 0a  0a 0a 09 3b 20 66 72 6f  |pc, r14....; fro|
000061e0  6d 20 68 65 72 65 20 6f  6e 2c 20 61 6c 69 67 6e  |m here on, align|
000061f0  6d 65 6e 74 20 64 6f 65  73 6e 27 74 20 6d 61 74  |ment doesn't mat|
00006200  74 65 72 0a 0a 09 26 09  2d 31 0a 09 3d 09 37 2c  |ter...&.-1..=.7,|
00006210  22 43 61 6c 6c 53 65 71  22 0a 67 63 30 09 4d 4f  |"CallSeq".gc0.MO|
00006220  56 09 61 31 2c 20 6e 69  6c 20 09 3b 20 6d 61 6b  |V.a1, nil .; mak|
00006230  65 20 61 6c 6c 20 74 68  65 73 65 20 73 61 66 65  |e all these safe|
00006240  20 6f 76 65 72 20 63 6f  6c 6c 65 63 74 69 6f 6e  | over collection|
00006250  0a 09 09 09 09 3b 20 28  74 68 65 79 20 70 72 6f  |.....; (they pro|
00006260  62 61 62 6c 79 20 77 65  72 65 20 61 6e 79 77 61  |bably were anywa|
00006270  79 2c 20 62 75 74 20 2e  2e 2e 29 0a 67 63 4c 0a  |y, but ...).gcL.|
00006280  67 63 46 0a 67 63 31 09  4d 4f 56 09 61 32 2c 20  |gcF.gc1.MOV.a2, |
00006290  6e 69 6c 0a 67 63 32 09  4d 4f 56 09 61 33 2c 20  |nil.gc2.MOV.a3, |
000062a0  6e 69 6c 0a 67 63 33 09  41 44 52 09 72 30 2c 20  |nil.gc3.ADR.r0, |
000062b0  67 63 30 20 09 3b 20 66  61 6b 65 20 66 75 6e 63  |gc0 .; fake func|
000062c0  74 69 6f 6e 20 6e 61 6d  65 0a 09 53 54 4d 45 41  |tion name..STMEA|
000062d0  09 72 74 73 21 2c 20 7b  72 30 2c 20 72 70 2c 20  |.rts!, {r0, rp, |
000062e0  72 6c 2c 20 72 31 34 7d  0a 09 53 55 42 09 72 70  |rl, r14}..SUB.rp|
000062f0  2c 20 72 74 73 2c 20 23  31 36 0a 09 53 54 4d 45  |, rts, #16..STME|
00006300  41 09 72 74 73 21 2c 20  7b 61 31 2c 20 61 32 2c  |A.rts!, {a1, a2,|
00006310  20 61 33 2c 20 72 62 7d  0a 09 4d 4f 56 09 61 31  | a3, rb}..MOV.a1|
00006320  2c 20 23 30 0a 09 4d 4f  56 09 61 32 2c 20 72 62  |, #0..MOV.a2, rb|
00006330  0a 09 4c 44 52 09 72 62  2c 20 5b 72 67 2c 20 23  |..LDR.rb, [rg, #|
00006340  47 5f 52 63 6c 6d 5d 0a  09 42 4c 09 43 61 6c 6c  |G_Rclm]..BL.Call|
00006350  47 6c 6f 62 0a 09 4c 44  4d 45 41 09 72 74 73 21  |Glob..LDMEA.rts!|
00006360  2c 20 7b 61 31 2c 20 61  32 2c 20 61 33 2c 20 72  |, {a1, a2, a3, r|
00006370  62 7d 0a 09 4d 4f 56 09  72 74 73 2c 20 72 70 20  |b}..MOV.rts, rp |
00006380  09 3b 20 75 6e 77 69 6e  64 20 6f 75 72 20 66 72  |.; unwind our fr|
00006390  61 6d 65 0a 09 4c 44 4d  49 42 09 72 70 2c 20 7b  |ame..LDMIB.rp, {|
000063a0  72 70 2c 20 72 6c 2c 20  72 31 34 7d 0a 09 42 49  |rp, rl, r14}..BI|
000063b0  43 09 70 63 2c 20 72 62  2c 20 23 50 5f 6b 65 79  |C.pc, rb, #P_key|
000063c0  20 3b 20 61 6e 64 20 65  6e 74 65 72 20 74 68 65  | ; and enter the|
000063d0  20 74 61 72 67 65 74 20  66 75 6e 63 74 69 6f 6e  | target function|
000063e0  0a 0a 67 63 46 4e 09 43  4d 50 53 09 77 31 2c 20  |..gcFN.CMPS.w1, |
000063f0  23 32 09 09 3b 20 6d 61  79 20 68 61 76 65 20 68  |#2..; may have h|
00006400  61 64 20 61 6e 79 20 6e  75 6d 62 65 72 20 6f 66  |ad any number of|
00006410  20 61 72 67 75 6d 65 6e  74 73 20 2d 0a 09 09 09  | arguments -....|
00006420  09 3b 20 6d 61 6b 65 20  74 68 65 6d 20 61 6c 6c  |.; make them all|
00006430  20 73 61 66 65 0a 09 4d  4f 56 4c 45 09 61 33 2c  | safe..MOVLE.a3,|
00006440  20 6e 69 6c 0a 09 4d 4f  56 4c 54 09 61 32 2c 20  | nil..MOVLT.a2, |
00006450  6e 69 6c 0a 09 43 4d 50  53 09 77 31 2c 20 23 31  |nil..CMPS.w1, #1|
00006460  0a 09 4d 4f 56 4c 54 09  61 31 2c 20 6e 69 6c 0a  |..MOVLT.a1, nil.|
00006470  67 63 4e 09 41 44 52 09  72 30 2c 20 67 63 30 20  |gcN.ADR.r0, gc0 |
00006480  09 3b 20 66 61 6b 65 20  66 75 6e 63 74 69 6f 6e  |.; fake function|
00006490  20 6e 61 6d 65 0a 09 53  54 4d 45 41 09 72 74 73  | name..STMEA.rts|
000064a0  21 2c 20 7b 72 30 2c 20  72 70 2c 20 72 6c 2c 20  |!, {r0, rp, rl, |
000064b0  72 31 34 7d 0a 09 53 55  42 09 72 70 2c 20 72 74  |r14}..SUB.rp, rt|
000064c0  73 2c 20 23 31 36 0a 09  53 54 4d 45 41 09 72 74  |s, #16..STMEA.rt|
000064d0  73 21 2c 20 7b 61 31 2c  20 61 32 2c 20 61 33 2c  |s!, {a1, a2, a3,|
000064e0  20 77 31 2c 20 72 62 7d  0a 09 4d 4f 56 09 61 31  | w1, rb}..MOV.a1|
000064f0  2c 20 23 30 0a 09 4d 4f  56 09 61 32 2c 20 72 62  |, #0..MOV.a2, rb|
00006500  0a 09 4c 44 52 09 72 62  2c 20 5b 72 67 2c 20 23  |..LDR.rb, [rg, #|
00006510  47 5f 52 63 6c 6d 5d 0a  09 42 4c 09 43 61 6c 6c  |G_Rclm]..BL.Call|
00006520  47 6c 6f 62 0a 09 4c 44  4d 45 41 09 72 74 73 21  |Glob..LDMEA.rts!|
00006530  2c 20 7b 61 31 2c 20 61  32 2c 20 61 33 2c 20 77  |, {a1, a2, a3, w|
00006540  31 2c 20 72 62 7d 0a 09  4d 4f 56 09 72 74 73 2c  |1, rb}..MOV.rts,|
00006550  20 72 70 20 09 3b 20 75  6e 77 69 6e 64 20 6f 75  | rp .; unwind ou|
00006560  72 20 66 72 61 6d 65 0a  09 4c 44 4d 49 42 09 72  |r frame..LDMIB.r|
00006570  70 2c 20 7b 72 70 2c 20  72 6c 2c 20 72 31 34 7d  |p, {rp, rl, r14}|
00006580  0a 09 42 49 43 09 77 32  2c 20 72 62 2c 20 23 50  |..BIC.w2, rb, #P|
00006590  5f 6b 65 79 09 3b 20 61  6e 64 20 65 6e 74 65 72  |_key.; and enter|
000065a0  20 74 68 65 20 74 61 72  67 65 74 20 66 75 6e 63  | the target func|
000065b0  74 69 6f 6e 0a 09 41 44  44 09 70 63 2c 20 77 32  |tion..ADD.pc, w2|
000065c0  2c 20 23 34 0a 0a 62 67  63 30 09 4d 4f 56 09 61  |, #4..bgc0.MOV.a|
000065d0  31 2c 20 6e 69 6c 0a 62  67 63 31 09 4d 4f 56 09  |1, nil.bgc1.MOV.|
000065e0  61 32 2c 20 6e 69 6c 0a  62 67 63 32 09 4d 4f 56  |a2, nil.bgc2.MOV|
000065f0  09 61 33 2c 20 6e 69 6c  0a 62 67 63 33 09 41 44  |.a3, nil.bgc3.AD|
00006600  52 09 72 30 2c 20 67 63  30 20 09 3b 20 66 61 6b  |R.r0, gc0 .; fak|
00006610  65 20 66 75 6e 63 74 69  6f 6e 20 6e 61 6d 65 0a  |e function name.|
00006620  09 53 54 4d 45 41 09 72  74 73 21 2c 20 7b 72 30  |.STMEA.rts!, {r0|
00006630  2c 20 72 70 2c 20 72 6c  2c 20 72 31 34 7d 0a 09  |, rp, rl, r14}..|
00006640  53 55 42 09 72 70 2c 20  72 74 73 2c 20 23 31 36  |SUB.rp, rts, #16|
00006650  0a 09 53 54 4d 45 41 09  72 74 73 21 2c 20 7b 61  |..STMEA.rts!, {a|
00006660  31 2c 20 61 32 2c 20 61  33 2c 20 77 32 2c 20 72  |1, a2, a3, w2, r|
00006670  62 7d 0a 09 4d 4f 56 09  61 31 2c 20 23 30 0a 09  |b}..MOV.a1, #0..|
00006680  4d 4f 56 09 61 32 2c 20  77 32 0a 09 4c 44 52 09  |MOV.a2, w2..LDR.|
00006690  72 62 2c 20 5b 72 67 2c  20 23 47 5f 52 63 6c 6d  |rb, [rg, #G_Rclm|
000066a0  5d 0a 09 42 4c 09 43 61  6c 6c 47 6c 6f 62 0a 09  |]..BL.CallGlob..|
000066b0  4c 44 4d 45 41 09 72 74  73 21 2c 20 7b 61 31 2c  |LDMEA.rts!, {a1,|
000066c0  20 61 32 2c 20 61 33 2c  20 77 32 2c 20 72 62 7d  | a2, a3, w2, rb}|
000066d0  0a 09 4d 4f 56 09 72 74  73 2c 20 72 70 20 09 3b  |..MOV.rts, rp .;|
000066e0  20 75 6e 77 69 6e 64 20  6f 75 72 20 66 72 61 6d  | unwind our fram|
000066f0  65 0a 09 4c 44 4d 49 42  09 72 70 2c 20 7b 72 70  |e..LDMIB.rp, {rp|
00006700  2c 20 72 6c 2c 20 72 31  34 7d 0a 09 42 49 43 09  |, rl, r14}..BIC.|
00006710  70 63 2c 20 77 32 2c 20  23 50 5f 6b 65 79 09 3b  |pc, w2, #P_key.;|
00006720  20 61 6e 64 20 65 6e 74  65 72 20 74 68 65 20 74  | and enter the t|
00006730  61 72 67 65 74 20 66 75  6e 63 74 69 6f 6e 0a 0a  |arget function..|
00006740  09 26 09 2d 31 0a 09 3d  09 37 2c 22 43 6f 6e 73  |.&.-1..=.7,"Cons|
00006750  20 20 20 22 0a 63 6f 6e  73 67 63 09 41 44 52 09  |   ".consgc.ADR.|
00006760  72 30 2c 20 63 6f 6e 73  67 63 0a 09 53 54 4d 45  |r0, consgc..STME|
00006770  41 09 72 74 73 21 2c 20  7b 72 30 2c 20 72 70 2c  |A.rts!, {r0, rp,|
00006780  20 72 6c 2c 20 72 31 34  7d 0a 09 53 55 42 09 72  | rl, r14}..SUB.r|
00006790  70 2c 20 72 74 73 2c 20  23 31 36 0a 09 53 54 4d  |p, rts, #16..STM|
000067a0  45 41 09 72 74 73 21 2c  20 7b 61 31 2c 20 61 32  |EA.rts!, {a1, a2|
000067b0  7d 0a 09 41 44 52 09 72  31 2c 20 63 6f 6e 73 5f  |}..ADR.r1, cons_|
000067c0  73 70 61 63 65 5f 6d 65  73 73 0a 09 4d 4f 56 09  |space_mess..MOV.|
000067d0  61 31 2c 20 61 31 2c 20  4c 53 52 20 23 32 0a 09  |a1, a1, LSR #2..|
000067e0  4c 44 52 09 72 62 2c 20  5b 72 67 2c 20 23 47 5f  |LDR.rb, [rg, #G_|
000067f0  52 63 6c 6d 5d 0a 09 42  4c 09 43 61 6c 6c 47 6c  |Rclm]..BL.CallGl|
00006800  6f 62 0a 09 4c 44 4d 45  41 09 72 74 73 21 2c 20  |ob..LDMEA.rts!, |
00006810  7b 61 31 2c 20 61 32 7d  0a 09 4c 44 4d 45 41 09  |{a1, a2}..LDMEA.|
00006820  72 74 73 21 2c 20 7b 72  30 2c 20 72 70 2c 20 72  |rts!, {r0, rp, r|
00006830  6c 2c 20 72 31 34 7d 0a  09 42 09 63 6f 6e 73 0a  |l, r14}..B.cons.|
00006840  0a 09 26 09 2d 31 0a 09  3d 09 37 2c 22 4c 69 73  |..&.-1..=.7,"Lis|
00006850  74 32 2a 20 22 0a 67 63  5f 4c 69 73 74 32 0a 09  |t2* ".gc_List2..|
00006860  4d 4f 56 09 61 33 2c 20  6e 69 6c 0a 67 63 5f 4c  |MOV.a3, nil.gc_L|
00006870  69 73 74 32 53 74 61 72  0a 09 41 44 52 09 72 30  |ist2Star..ADR.r0|
00006880  2c 20 67 63 5f 4c 69 73  74 32 0a 09 53 54 4d 45  |, gc_List2..STME|
00006890  41 09 72 74 73 21 2c 20  7b 72 30 2c 20 72 70 2c  |A.rts!, {r0, rp,|
000068a0  20 72 6c 2c 20 72 31 34  7d 0a 09 53 55 42 09 72  | rl, r14}..SUB.r|
000068b0  70 2c 20 72 74 73 2c 20  23 31 36 0a 09 53 54 4d  |p, rts, #16..STM|
000068c0  45 41 09 72 74 73 21 2c  20 7b 61 31 2c 20 61 32  |EA.rts!, {a1, a2|
000068d0  2c 20 61 33 7d 0a 09 41  44 52 09 72 31 2c 20 63  |, a3}..ADR.r1, c|
000068e0  6f 6e 73 5f 73 70 61 63  65 5f 6d 65 73 73 0a 09  |ons_space_mess..|
000068f0  4d 4f 56 09 61 31 2c 20  61 31 2c 20 4c 53 52 20  |MOV.a1, a1, LSR |
00006900  23 32 0a 09 4c 44 52 09  72 62 2c 20 5b 72 67 2c  |#2..LDR.rb, [rg,|
00006910  20 23 47 5f 52 63 6c 6d  5d 0a 09 42 4c 09 43 61  | #G_Rclm]..BL.Ca|
00006920  6c 6c 47 6c 6f 62 0a 09  4c 44 4d 45 41 09 72 74  |llGlob..LDMEA.rt|
00006930  73 21 2c 20 7b 61 31 2c  20 61 32 2c 20 61 33 7d  |s!, {a1, a2, a3}|
00006940  0a 09 4c 44 4d 45 41 09  72 74 73 21 2c 20 7b 72  |..LDMEA.rts!, {r|
00006950  30 2c 20 72 70 2c 20 72  6c 2c 20 72 31 34 7d 0a  |0, rp, rl, r14}.|
00006960  09 42 09 4c 69 73 74 32  53 74 61 72 0a 0a 09 26  |.B.List2Star...&|
00006970  09 2d 31 0a 09 3d 09 37  2c 22 4c 69 73 74 33 20  |.-1..=.7,"List3 |
00006980  20 22 0a 67 63 5f 4c 69  73 74 33 0a 09 41 44 52  | ".gc_List3..ADR|
00006990  09 72 30 2c 20 67 63 5f  4c 69 73 74 33 0a 09 53  |.r0, gc_List3..S|
000069a0  54 4d 45 41 09 72 74 73  21 2c 20 7b 72 30 2c 20  |TMEA.rts!, {r0, |
000069b0  72 70 2c 20 72 6c 2c 20  72 31 34 7d 0a 09 53 55  |rp, rl, r14}..SU|
000069c0  42 09 72 70 2c 20 72 74  73 2c 20 23 31 36 0a 09  |B.rp, rts, #16..|
000069d0  53 54 4d 45 41 09 72 74  73 21 2c 20 7b 61 31 2c  |STMEA.rts!, {a1,|
000069e0  20 61 32 2c 20 61 33 7d  0a 09 41 44 52 09 72 31  | a2, a3}..ADR.r1|
000069f0  2c 20 63 6f 6e 73 5f 73  70 61 63 65 5f 6d 65 73  |, cons_space_mes|
00006a00  73 0a 09 4d 4f 56 09 61  31 2c 20 61 31 2c 20 4c  |s..MOV.a1, a1, L|
00006a10  53 52 20 23 32 0a 09 4c  44 52 09 72 62 2c 20 5b  |SR #2..LDR.rb, [|
00006a20  72 67 2c 20 23 47 5f 52  63 6c 6d 5d 0a 09 42 4c  |rg, #G_Rclm]..BL|
00006a30  09 43 61 6c 6c 47 6c 6f  62 0a 09 4c 44 4d 45 41  |.CallGlob..LDMEA|
00006a40  09 72 74 73 21 2c 20 7b  61 31 2c 20 61 32 2c 20  |.rts!, {a1, a2, |
00006a50  61 33 7d 0a 09 4c 44 4d  45 41 09 72 74 73 21 2c  |a3}..LDMEA.rts!,|
00006a60  20 7b 72 30 2c 20 72 70  2c 20 72 6c 2c 20 72 31  | {r0, rp, rl, r1|
00006a70  34 7d 0a 09 42 09 4c 69  73 74 33 0a 0a 63 6f 6e  |4}..B.List3..con|
00006a80  73 5f 73 70 61 63 65 5f  6d 65 73 73 0a 09 3d 09  |s_space_mess..=.|
00006a90  31 30 2c 22 43 6f 6e 73  20 73 70 61 63 65 22 0a  |10,"Cons space".|
00006aa0  09 41 4c 49 47 4e 20 34  0a 0a 71 63 61 6c 6c 30  |.ALIGN 4..qcall0|
00006ab0  09 51 43 61 6c 6c 42 6f  64 79 20 30 0a 09 4d 4f  |.QCallBody 0..MO|
00006ac0  56 09 61 33 2c 20 23 30  0a 49 6e 74 65 72 70 72  |V.a3, #0.Interpr|
00006ad0  65 74 6e 0a 09 4d 4f 56  09 61 32 2c 20 6e 69 6c  |etn..MOV.a2, nil|
00006ae0  0a 49 6e 74 65 72 70 72  65 74 6c 0a 09 4d 4f 56  |.Interpretl..MOV|
00006af0  09 61 34 2c 20 6e 69 6c  0a 09 4d 4f 56 09 61 31  |.a4, nil..MOV.a1|
00006b00  2c 20 77 32 0a 09 4c 44  52 09 72 62 2c 20 5b 72  |, w2..LDR.rb, [r|
00006b10  67 2c 20 23 47 5f 46 75  6e 61 70 5d 0a 09 4d 4f  |g, #G_Funap]..MO|
00006b20  56 09 70 63 2c 20 72 62  0a 0a 71 63 61 6c 6c 31  |V.pc, rb..qcall1|
00006b30  09 51 43 61 6c 6c 42 6f  64 79 20 31 0a 09 53 54  |.QCallBody 1..ST|
00006b40  52 09 61 31 2c 20 5b 72  67 2c 20 23 47 5f 61 72  |R.a1, [rg, #G_ar|
00006b50  67 31 5d 0a 09 4d 4f 56  09 61 33 2c 20 23 31 0a  |g1]..MOV.a3, #1.|
00006b60  09 42 09 49 6e 74 65 72  70 72 65 74 6e 0a 0a 71  |.B.Interpretn..q|
00006b70  63 61 6c 6c 32 09 51 43  61 6c 6c 42 6f 64 79 20  |call2.QCallBody |
00006b80  32 0a 09 41 44 44 09 72  30 2c 20 72 67 2c 20 23  |2..ADD.r0, rg, #|
00006b90  47 5f 61 72 67 31 0a 09  53 54 4d 49 41 09 72 30  |G_arg1..STMIA.r0|
00006ba0  2c 20 7b 61 31 2c 20 61  32 7d 0a 09 4d 4f 56 09  |, {a1, a2}..MOV.|
00006bb0  61 33 2c 20 23 32 0a 09  42 09 49 6e 74 65 72 70  |a3, #2..B.Interp|
00006bc0  72 65 74 6e 0a 0a 71 63  61 6c 6c 33 09 51 43 61  |retn..qcall3.QCa|
00006bd0  6c 6c 42 6f 64 79 20 33  0a 09 41 44 44 09 72 30  |llBody 3..ADD.r0|
00006be0  2c 20 72 67 2c 20 23 47  5f 61 72 67 31 0a 09 53  |, rg, #G_arg1..S|
00006bf0  54 4d 49 41 09 72 30 2c  20 7b 61 31 2c 20 61 32  |TMIA.r0, {a1, a2|
00006c00  2c 20 61 33 7d 0a 09 4d  4f 56 09 61 33 2c 20 23  |, a3}..MOV.a3, #|
00006c10  33 0a 09 42 09 49 6e 74  65 72 70 72 65 74 6e 0a  |3..B.Interpretn.|
00006c20  0a 71 63 61 6c 6c 4e 09  41 44 44 09 72 30 2c 20  |.qcallN.ADD.r0, |
00006c30  72 67 2c 20 23 47 5f 61  72 67 31 0a 09 53 54 4d  |rg, #G_arg1..STM|
00006c40  49 41 09 72 30 2c 20 7b  61 31 2c 20 61 32 2c 20  |IA.r0, {a1, a2, |
00006c50  61 33 7d 0a 09 4d 4f 56  09 61 33 2c 20 77 31 0a  |a3}..MOV.a3, w1.|
00006c60  09 42 09 49 6e 74 65 72  70 72 65 74 6e 0a 0a 71  |.B.Interpretn..q|
00006c70  63 61 6c 6c 4c 09 4d 56  4e 09 61 33 2c 20 23 31  |callL.MVN.a3, #1|
00006c80  09 20 20 3b 20 2d 32 0a  09 4d 4f 56 09 61 32 2c  |.  ; -2..MOV.a2,|
00006c90  20 61 31 0a 09 42 09 49  6e 74 65 72 70 72 65 74  | a1..B.Interpret|
00006ca0  6c 0a 0a 71 63 61 6c 6c  46 09 4d 4f 56 09 61 33  |l..qcallF.MOV.a3|
00006cb0  2c 20 23 30 09 20 20 3b  20 2d 31 0a 09 4d 4f 56  |, #0.  ; -1..MOV|
00006cc0  09 61 32 2c 20 61 31 0a  09 42 09 49 6e 74 65 72  |.a2, a1..B.Inter|
00006cd0  70 72 65 74 6c 0a 0a 71  63 61 6c 6c 46 4e 20 43  |pretl..qcallFN C|
00006ce0  4d 50 53 09 77 31 2c 20  23 32 09 09 3b 20 6d 61  |MPS.w1, #2..; ma|
00006cf0  79 20 68 61 76 65 20 68  61 64 20 61 6e 79 20 6e  |y have had any n|
00006d00  75 6d 62 65 72 20 6f 66  20 61 72 67 75 6d 65 6e  |umber of argumen|
00006d10  74 73 20 2d 0a 09 09 09  09 3b 20 6d 61 6b 65 20  |ts -.....; make |
00006d20  74 68 65 6d 20 61 6c 6c  20 73 61 66 65 0a 09 4d  |them all safe..M|
00006d30  4f 56 4c 45 09 61 33 2c  20 6e 69 6c 0a 09 4d 4f  |OVLE.a3, nil..MO|
00006d40  56 4c 54 09 61 32 2c 20  6e 69 6c 0a 09 43 4d 50  |VLT.a2, nil..CMP|
00006d50  53 09 77 31 2c 20 23 31  0a 09 4d 4f 56 4c 54 09  |S.w1, #1..MOVLT.|
00006d60  61 31 2c 20 6e 69 6c 0a  09 41 44 44 09 72 30 2c  |a1, nil..ADD.r0,|
00006d70  20 72 67 2c 20 23 47 5f  61 72 67 31 0a 09 53 54  | rg, #G_arg1..ST|
00006d80  4d 49 41 09 72 30 2c 20  7b 61 31 2c 20 61 32 2c  |MIA.r0, {a1, a2,|
00006d90  20 61 33 7d 0a 09 4d 4f  56 09 61 32 2c 20 77 31  | a3}..MOV.a2, w1|
00006da0  0a 09 4d 4f 56 09 61 31  2c 20 77 32 0a 09 4c 44  |..MOV.a1, w2..LD|
00006db0  52 09 72 62 2c 20 5b 72  67 2c 20 23 47 5f 4c 69  |R.rb, [rg, #G_Li|
00006dc0  6e 6b 46 65 78 70 72 6e  5d 0a 09 4d 4f 56 09 70  |nkFexprn]..MOV.p|
00006dd0  63 2c 20 72 62 0a 0a 78  63 61 72 5f 61 34 20 09  |c, rb..xcar_a4 .|
00006de0  4d 4f 56 09 77 32 2c 20  72 62 0a 78 63 61 72 5f  |MOV.w2, rb.xcar_|
00006df0  77 32 20 09 4d 4f 56 09  77 31 2c 20 77 32 0a 78  |w2 .MOV.w1, w2.x|
00006e00  63 61 72 5f 77 31 20 09  4d 4f 56 09 61 33 2c 20  |car_w1 .MOV.a3, |
00006e10  77 31 0a 78 63 61 72 5f  61 33 20 09 4d 4f 56 09  |w1.xcar_a3 .MOV.|
00006e20  61 31 2c 20 61 33 0a 78  63 61 72 5f 61 31 20 09  |a1, a3.xcar_a1 .|
00006e30  4d 4f 56 09 61 32 2c 20  61 31 0a 78 63 61 72 5f  |MOV.a2, a1.xcar_|
00006e40  61 32 20 09 4d 4f 56 09  61 31 2c 20 23 45 5f 63  |a2 .MOV.a1, #E_c|
00006e50  61 72 0a 09 09 4c 44 52  09 72 62 2c 20 5b 72 67  |ar...LDR.rb, [rg|
00006e60  2c 20 23 47 5f 4d 69 78  45 72 72 6f 72 5d 0a 09  |, #G_MixError]..|
00006e70  09 4d 4f 56 09 70 63 2c  20 72 62 0a 0a 78 63 64  |.MOV.pc, rb..xcd|
00006e80  72 5f 61 34 20 09 4d 4f  56 09 77 32 2c 20 72 62  |r_a4 .MOV.w2, rb|
00006e90  0a 78 63 64 72 5f 77 32  20 09 4d 4f 56 09 77 31  |.xcdr_w2 .MOV.w1|
00006ea0  2c 20 77 32 0a 78 63 64  72 5f 77 31 20 09 4d 4f  |, w2.xcdr_w1 .MO|
00006eb0  56 09 61 33 2c 20 77 31  0a 78 63 64 72 5f 61 33  |V.a3, w1.xcdr_a3|
00006ec0  20 09 4d 4f 56 09 61 31  2c 20 61 33 0a 78 63 64  | .MOV.a1, a3.xcd|
00006ed0  72 5f 61 31 20 09 4d 4f  56 09 61 32 2c 20 61 31  |r_a1 .MOV.a2, a1|
00006ee0  0a 78 63 64 72 5f 61 32  20 09 4d 4f 56 09 61 31  |.xcdr_a2 .MOV.a1|
00006ef0  2c 20 23 45 5f 63 64 72  0a 09 09 4c 44 52 09 72  |, #E_cdr...LDR.r|
00006f00  62 2c 20 5b 72 67 2c 20  23 47 5f 4d 69 78 45 72  |b, [rg, #G_MixEr|
00006f10  72 6f 72 5d 0a 09 09 4d  4f 56 09 70 63 2c 20 72  |ror]...MOV.pc, r|
00006f20  62 0a 0a 78 72 70 6c 61  63 61 5f 61 34 09 4d 4f  |b..xrplaca_a4.MO|
00006f30  56 09 77 32 2c 20 72 62  0a 78 72 70 6c 61 63 61  |V.w2, rb.xrplaca|
00006f40  5f 77 32 09 4d 4f 56 09  77 31 2c 20 77 32 0a 78  |_w2.MOV.w1, w2.x|
00006f50  72 70 6c 61 63 61 5f 77  31 09 4d 4f 56 09 61 33  |rplaca_w1.MOV.a3|
00006f60  2c 20 77 31 0a 78 72 70  6c 61 63 61 5f 61 33 09  |, w1.xrplaca_a3.|
00006f70  4d 4f 56 09 61 31 2c 20  61 33 0a 78 72 70 6c 61  |MOV.a1, a3.xrpla|
00006f80  63 61 5f 61 31 09 4d 4f  56 09 61 32 2c 20 61 31  |ca_a1.MOV.a2, a1|
00006f90  0a 78 72 70 6c 61 63 61  5f 61 32 09 4d 4f 56 09  |.xrplaca_a2.MOV.|
00006fa0  61 31 2c 20 23 45 5f 72  70 6c 61 63 61 0a 09 09  |a1, #E_rplaca...|
00006fb0  4c 44 52 09 72 62 2c 20  5b 72 67 2c 20 23 47 5f  |LDR.rb, [rg, #G_|
00006fc0  4d 69 78 45 72 72 6f 72  5d 0a 09 09 4d 4f 56 09  |MixError]...MOV.|
00006fd0  70 63 2c 20 72 62 0a 0a  78 72 70 6c 61 63 64 5f  |pc, rb..xrplacd_|
00006fe0  61 34 09 4d 4f 56 09 77  32 2c 20 72 62 0a 78 72  |a4.MOV.w2, rb.xr|
00006ff0  70 6c 61 63 64 5f 77 32  09 4d 4f 56 09 77 31 2c  |placd_w2.MOV.w1,|
00007000  20 77 32 0a 78 72 70 6c  61 63 64 5f 77 31 09 4d  | w2.xrplacd_w1.M|
00007010  4f 56 09 61 33 2c 20 77  31 0a 78 72 70 6c 61 63  |OV.a3, w1.xrplac|
00007020  64 5f 61 33 09 4d 4f 56  09 61 31 2c 20 61 33 0a  |d_a3.MOV.a1, a3.|
00007030  78 72 70 6c 61 63 64 5f  61 31 09 4d 4f 56 09 61  |xrplacd_a1.MOV.a|
00007040  32 2c 20 61 31 0a 78 72  70 6c 61 63 64 5f 61 32  |2, a1.xrplacd_a2|
00007050  09 4d 4f 56 09 61 31 2c  20 23 45 5f 72 70 6c 61  |.MOV.a1, #E_rpla|
00007060  63 64 0a 09 09 4c 44 52  09 72 62 2c 20 5b 72 67  |cd...LDR.rb, [rg|
00007070  2c 20 23 47 5f 4d 69 78  45 72 72 6f 72 5d 0a 09  |, #G_MixError]..|
00007080  09 4d 4f 56 09 70 63 2c  20 72 62 0a 0a 78 72 70  |.MOV.pc, rb..xrp|
00007090  6c 61 63 77 31 5f 61 34  09 4d 4f 56 09 77 32 2c  |lacw1_a4.MOV.w2,|
000070a0  20 72 62 0a 78 72 70 6c  61 63 77 31 5f 77 32 09  | rb.xrplacw1_w2.|
000070b0  4d 4f 56 09 77 31 2c 20  77 32 0a 78 72 70 6c 61  |MOV.w1, w2.xrpla|
000070c0  63 77 31 5f 77 31 09 4d  4f 56 09 61 33 2c 20 77  |cw1_w1.MOV.a3, w|
000070d0  31 0a 78 72 70 6c 61 63  77 31 5f 61 33 09 4d 4f  |1.xrplacw1_a3.MO|
000070e0  56 09 61 31 2c 20 61 33  0a 78 72 70 6c 61 63 77  |V.a1, a3.xrplacw|
000070f0  31 5f 61 31 09 4d 4f 56  09 61 32 2c 20 61 31 0a  |1_a1.MOV.a2, a1.|
00007100  78 72 70 6c 61 63 77 31  5f 61 32 09 4d 4f 56 09  |xrplacw1_a2.MOV.|
00007110  61 31 2c 20 23 45 5f 72  70 6c 61 63 77 31 0a 09  |a1, #E_rplacw1..|
00007120  09 4c 44 52 09 72 62 2c  20 5b 72 67 2c 20 23 47  |.LDR.rb, [rg, #G|
00007130  5f 4d 69 78 45 72 72 6f  72 5d 0a 09 09 4d 4f 56  |_MixError]...MOV|
00007140  09 70 63 2c 20 72 62 0a  0a 78 72 70 6c 61 63 77  |.pc, rb..xrplacw|
00007150  32 5f 61 34 09 4d 4f 56  09 77 32 2c 20 72 62 0a  |2_a4.MOV.w2, rb.|
00007160  78 72 70 6c 61 63 77 32  5f 77 32 09 4d 4f 56 09  |xrplacw2_w2.MOV.|
00007170  77 31 2c 20 77 32 0a 78  72 70 6c 61 63 77 32 5f  |w1, w2.xrplacw2_|
00007180  77 31 09 4d 4f 56 09 61  33 2c 20 77 31 0a 78 72  |w1.MOV.a3, w1.xr|
00007190  70 6c 61 63 77 32 5f 61  33 09 4d 4f 56 09 61 31  |placw2_a3.MOV.a1|
000071a0  2c 20 61 33 0a 78 72 70  6c 61 63 77 32 5f 61 31  |, a3.xrplacw2_a1|
000071b0  09 4d 4f 56 09 61 32 2c  20 61 31 0a 78 72 70 6c  |.MOV.a2, a1.xrpl|
000071c0  61 63 77 32 5f 61 32 09  4d 4f 56 09 61 31 2c 20  |acw2_a2.MOV.a1, |
000071d0  23 45 5f 72 70 6c 61 63  77 32 0a 09 09 4c 44 52  |#E_rplacw2...LDR|
000071e0  09 72 62 2c 20 5b 72 67  2c 20 23 47 5f 4d 69 78  |.rb, [rg, #G_Mix|
000071f0  45 72 72 6f 72 5d 0a 09  09 4d 4f 56 09 70 63 2c  |Error]...MOV.pc,|
00007200  20 72 62 0a 20 5d 0a 0a  64 69 76 69 64 65 62 79  | rb. ]..divideby|
00007210  30 0a 09 41 44 52 09 61  31 2c 20 64 69 76 30 6d  |0..ADR.a1, div0m|
00007220  65 73 73 0a 09 42 09 43  61 6c 6c 5f 46 61 75 6c  |ess..B.Call_Faul|
00007230  74 0a 64 69 76 30 6d 65  73 73 0a 09 3d 09 31 37  |t.div0mess..=.17|
00007240  2c 20 22 44 69 76 69 73  69 6f 6e 20 62 79 20 7a  |, "Division by z|
00007250  65 72 6f 22 2c 31 30 0a  0a 09 41 4c 49 47 4e 09  |ero",10...ALIGN.|
00007260  34 0a 0a 0a 20 47 6c 6f  62 44 65 66 20 31 30 36  |4... GlobDef 106|
00007270  2c 54 4b 52 45 72 72 0a  20 3b 20 54 4b 52 45 72  |,TKRErr. ; TKREr|
00007280  72 28 62 75 66 66 65 72  2c 20 6d 61 78 6c 65 6e  |r(buffer, maxlen|
00007290  67 74 68 29 0a 20 3b 20  4d 6f 76 65 73 20 74 68  |gth). ; Moves th|
000072a0  65 20 6d 6f 73 74 20 72  65 63 65 6e 74 20 65 72  |e most recent er|
000072b0  72 6f 72 20 73 74 72 69  6e 67 20 69 6e 74 6f 20  |ror string into |
000072c0  74 68 65 20 67 69 76 65  6e 20 62 75 66 66 65 72  |the given buffer|
000072d0  2e 0a 20 3b 20 72 65 74  75 72 6e 73 20 74 68 65  |.. ; returns the|
000072e0  20 28 62 63 70 6c 20 61  64 64 72 65 73 73 20 6f  | (bcpl address o|
000072f0  66 20 74 68 65 29 20 62  75 66 66 65 72 2c 20 6a  |f the) buffer, j|
00007300  75 73 74 20 61 73 20 70  61 73 73 65 64 0a 0a 09  |ust as passed...|
00007310  4d 4f 56 09 61 33 2c 20  61 31 2c 20 41 53 4c 20  |MOV.a3, a1, ASL |
00007320  23 32 0a 09 4c 44 52 09  72 62 2c 20 4c 6f 63 61  |#2..LDR.rb, Loca|
00007330  6c 44 61 74 61 50 0a 09  41 44 44 09 61 34 2c 20  |lDataP..ADD.a4, |
00007340  72 62 2c 20 23 4f 5f 65  72 72 6f 72 53 74 72 69  |rb, #O_errorStri|
00007350  6e 67 0a 09 4d 4f 56 09  77 32 2c 20 23 30 0a 54  |ng..MOV.w2, #0.T|
00007360  4b 52 45 72 72 31 0a 09  4c 44 52 42 09 72 62 2c  |KRErr1..LDRB.rb,|
00007370  20 5b 61 34 5d 2c 23 2b  31 0a 09 43 4d 50 53 09  | [a4],#+1..CMPS.|
00007380  72 62 2c 20 23 30 0a 09  42 45 51 09 54 4b 52 45  |rb, #0..BEQ.TKRE|
00007390  72 72 32 0a 09 41 44 44  09 77 32 2c 20 77 32 2c  |rr2..ADD.w2, w2,|
000073a0  20 23 31 0a 09 53 54 52  42 09 72 62 2c 20 5b 61  | #1..STRB.rb, [a|
000073b0  33 2c 20 77 32 5d 0a 09  43 4d 50 53 09 77 32 2c  |3, w2]..CMPS.w2,|
000073c0  20 61 32 0a 09 42 4c 54  09 54 4b 52 45 72 72 31  | a2..BLT.TKRErr1|
000073d0  0a 54 4b 52 45 72 72 32  0a 09 53 54 52 42 09 77  |.TKRErr2..STRB.w|
000073e0  32 2c 20 5b 61 33 5d 0a  09 4d 4f 56 53 09 70 63  |2, [a3]..MOVS.pc|
000073f0  2c 20 72 31 34 0a 0a 72  39 20 52 4e 20 39 0a 0a  |, r14..r9 RN 9..|
00007400  20 47 6c 6f 62 44 65 66  20 39 34 2c 20 53 57 49  | GlobDef 94, SWI|
00007410  0a 09 41 44 52 09 77 31  2c 20 41 66 74 65 72 53  |..ADR.w1, AfterS|
00007420  57 49 0a 09 53 55 42 09  77 31 2c 20 77 31 2c 20  |WI..SUB.w1, w1, |
00007430  72 74 73 0a 09 53 55 42  09 77 31 2c 20 77 31 2c  |rts..SUB.w1, w1,|
00007440  20 23 31 32 0a 09 4d 4f  56 09 77 31 2c 20 77 31  | #12..MOV.w1, w1|
00007450  2c 20 4c 53 52 20 23 32  0a 09 42 49 43 09 77 31  |, LSR #2..BIC.w1|
00007460  2c 20 77 31 2c 20 23 26  66 66 30 30 30 30 30 30  |, w1, #&ff000000|
00007470  0a 09 41 44 44 09 77 31  2c 20 77 31 2c 20 23 26  |..ADD.w1, w1, #&|
00007480  65 61 30 30 30 30 30 30  09 3b 20 42 20 61 6c 77  |ea000000.; B alw|
00007490  61 79 73 0a 09 41 44 44  09 61 31 2c 20 61 31 2c  |ays..ADD.a1, a1,|
000074a0  20 23 26 45 46 30 30 30  30 30 30 09 3b 20 53 57  | #&EF000000.; SW|
000074b0  49 20 2b 20 41 6c 77 61  79 73 0a 09 53 54 4d 45  |I + Always..STME|
000074c0  41 09 72 74 73 21 2c 20  7b 61 31 2c 20 77 31 7d  |A.rts!, {a1, w1}|
000074d0  0a 09 53 54 4d 45 41 09  72 74 73 21 2c 20 7b 6e  |..STMEA.rts!, {n|
000074e0  69 6c 62 61 73 65 2c 20  72 67 62 2c 20 72 67 2c  |ilbase, rgb, rg,|
000074f0  20 72 70 7d 0a 09 53 54  4d 45 41 09 72 74 73 21  | rp}..STMEA.rts!|
00007500  2c 20 7b 61 33 7d 0a 09  4d 4f 56 09 61 32 2c 20  |, {a3}..MOV.a2, |
00007510  61 32 2c 20 41 53 4c 20  23 32 0a 09 4c 44 4d 49  |a2, ASL #2..LDMI|
00007520  41 09 61 32 2c 20 7b 72  30 20 2d 20 72 39 7d 0a  |A.a2, {r0 - r9}.|
00007530  09 53 55 42 09 70 63 2c  20 72 74 73 2c 20 23 32  |.SUB.pc, rts, #2|
00007540  38 0a 41 66 74 65 72 53  57 49 0a 09 4c 44 4d 45  |8.AfterSWI..LDME|
00007550  41 09 72 74 73 21 2c 20  7b 72 70 7d 0a 09 4d 4f  |A.rts!, {rp}..MO|
00007560  56 09 72 70 2c 20 72 70  2c 20 41 53 4c 20 23 32  |V.rp, rp, ASL #2|
00007570  0a 09 53 54 4d 49 41 09  72 70 2c 20 7b 72 30 20  |..STMIA.rp, {r0 |
00007580  2d 20 72 39 7d 0a 09 4c  44 4d 45 41 09 72 74 73  |- r9}..LDMEA.rts|
00007590  21 2c 20 7b 6e 69 6c 62  61 73 65 2c 20 72 67 62  |!, {nilbase, rgb|
000075a0  2c 20 72 67 2c 20 72 70  7d 0a 09 53 55 42 09 72  |, rg, rp}..SUB.r|
000075b0  74 73 2c 20 72 74 73 2c  20 23 38 0a 09 4d 4f 56  |ts, rts, #8..MOV|
000075c0  56 43 09 61 31 2c 20 23  30 0a 09 4d 4f 56 53 09  |VC.a1, #0..MOVS.|
000075d0  70 63 2c 20 72 31 34 0a  0a 0a 20 47 6c 6f 62 44  |pc, r14... GlobD|
000075e0  65 66 20 39 33 2c 4f 53  42 79 74 65 32 0a 0a 09  |ef 93,OSByte2...|
000075f0  4d 4f 56 09 72 30 2c 20  61 31 0a 09 4d 4f 56 09  |MOV.r0, a1..MOV.|
00007600  72 31 2c 20 61 32 0a 09  4d 4f 56 09 72 32 2c 20  |r1, a2..MOV.r2, |
00007610  61 33 0a 09 53 57 49 09  42 79 74 65 0a 09 4d 4f  |a3..SWI.Byte..MO|
00007620  56 56 53 09 61 31 2c 20  72 30 0a 09 4d 4f 56 56  |VVS.a1, r0..MOVV|
00007630  53 53 09 70 63 2c 20 72  31 34 0a 09 41 4e 44 09  |SS.pc, r14..AND.|
00007640  61 31 2c 20 72 31 2c 20  23 26 66 66 0a 09 4f 52  |a1, r1, #&ff..OR|
00007650  52 09 61 31 2c 20 61 31  2c 20 72 32 2c 20 41 53  |R.a1, a1, r2, AS|
00007660  4c 20 23 38 0a 09 42 49  43 09 61 31 2c 20 61 31  |L #8..BIC.a1, a1|
00007670  2c 20 23 26 66 66 30 30  30 30 0a 09 4f 52 52 43  |, #&ff0000..ORRC|
00007680  53 09 61 31 2c 20 61 31  2c 20 23 26 38 30 30 30  |S.a1, a1, #&8000|
00007690  30 30 0a 09 42 49 43 09  61 31 2c 20 61 31 2c 20  |00..BIC.a1, a1, |
000076a0  23 26 66 66 30 30 30 30  30 30 0a 09 4d 4f 56 53  |#&ff000000..MOVS|
000076b0  09 70 63 2c 20 72 31 34  0a 0a 20 47 6c 6f 62 44  |.pc, r14.. GlobD|
000076c0  65 66 20 31 30 34 2c 4f  53 42 79 74 65 0a 0a 09  |ef 104,OSByte...|
000076d0  4d 4f 56 09 72 30 2c 20  61 31 0a 09 4d 4f 56 09  |MOV.r0, a1..MOV.|
000076e0  72 31 2c 20 61 32 0a 09  4d 4f 56 09 72 32 2c 20  |r1, a2..MOV.r2, |
000076f0  61 33 0a 09 53 57 49 09  42 79 74 65 0a 09 53 54  |a3..SWI.Byte..ST|
00007700  52 09 72 32 2c 20 5b 72  67 2c 20 23 47 5f 72 65  |R.r2, [rg, #G_re|
00007710  73 75 6c 74 32 5d 0a 09  4d 4f 56 09 61 31 2c 20  |sult2]..MOV.a1, |
00007720  72 31 0a 09 4d 4f 56 53  09 70 63 2c 20 72 31 34  |r1..MOVS.pc, r14|
00007730  0a 0a 20 47 6c 6f 62 44  65 66 20 31 30 35 2c 4f  |.. GlobDef 105,O|
00007740  53 57 6f 72 64 0a 0a 09  41 4e 44 53 09 72 30 2c  |SWord...ANDS.r0,|
00007750  20 61 31 2c 20 23 32 35  35 0a 09 4d 4f 56 09 72  | a1, #255..MOV.r|
00007760  31 2c 20 61 32 2c 20 41  53 4c 20 23 32 0a 09 42  |1, a2, ASL #2..B|
00007770  45 51 09 72 64 6c 69 6e  65 0a 09 53 57 49 09 57  |EQ.rdline..SWI.W|
00007780  6f 72 64 0a 09 53 54 52  09 72 30 2c 20 5b 72 67  |ord..STR.r0, [rg|
00007790  2c 20 23 47 5f 72 65 73  75 6c 74 32 5d 0a 09 4d  |, #G_result2]..M|
000077a0  4f 56 09 61 31 2c 20 72  32 0a 09 4d 4f 56 53 09  |OV.a1, r2..MOVS.|
000077b0  70 63 2c 20 72 31 34 0a  0a 72 64 6c 69 6e 65 09  |pc, r14..rdline.|
000077c0  20 20 3b 20 52 65 61 64  4c 69 6e 65 20 68 61 73  |  ; ReadLine has|
000077d0  20 74 6f 20 62 65 20 64  6f 6e 65 20 62 79 20 61  | to be done by a|
000077e0  20 73 65 70 65 72 61 74  65 20 6b 65 72 6e 65 6c  | seperate kernel|
000077f0  20 63 61 6c 6c 3a 0a 09  20 20 3b 20 4f 53 57 4f  | call:..  ; OSWO|
00007800  52 44 20 30 20 77 6f 6e  27 74 20 64 6f 20 69 74  |RD 0 won't do it|
00007810  2e 0a 09 4c 44 52 09 72  30 2c 20 5b 72 31 2c 20  |...LDR.r0, [r1, |
00007820  23 30 5d 09 3b 20 61 64  64 72 65 73 73 20 6f 66  |#0].; address of|
00007830  20 62 75 66 66 65 72 0a  09 4d 4f 56 09 72 34 2c  | buffer..MOV.r4,|
00007840  20 72 30 0a 09 4c 44 52  42 09 72 33 2c 20 5b 72  | r0..LDRB.r3, [r|
00007850  31 2c 20 23 36 5d 09 3b  20 6d 61 78 20 69 6e 70  |1, #6].; max inp|
00007860  75 74 20 62 79 74 65 0a  09 4c 44 52 42 09 72 32  |ut byte..LDRB.r2|
00007870  2c 20 5b 72 31 2c 20 23  35 5d 09 3b 20 6d 69 6e  |, [r1, #5].; min|
00007880  20 20 22 20 20 20 20 20  22 0a 09 4c 44 52 42 09  |  "     "..LDRB.|
00007890  72 31 2c 20 5b 72 31 2c  20 23 34 5d 09 3b 20 6d  |r1, [r1, #4].; m|
000078a0  61 78 20 69 6e 70 75 74  20 6c 65 6e 67 74 68 0a  |ax input length.|
000078b0  09 53 57 49 09 52 65 61  64 4c 69 6e 65 0a 09 4d  |.SWI.ReadLine..M|
000078c0  4f 56 09 72 32 2c 20 23  30 09 09 3b 20 74 68 65  |OV.r2, #0..; the|
000078d0  20 63 61 72 72 79 20 66  6c 61 67 20 67 6f 65 73  | carry flag goes|
000078e0  20 74 6f 20 52 65 73 75  6c 74 32 0a 09 4d 56 4e  | to Result2..MVN|
000078f0  43 53 09 72 32 2c 20 72  32 0a 09 53 54 52 09 72  |CS.r2, r2..STR.r|
00007900  32 2c 20 5b 72 67 2c 20  23 47 5f 72 65 73 75 6c  |2, [rg, #G_resul|
00007910  74 32 5d 0a 09 4d 4f 56  53 09 70 63 2c 20 72 31  |t2]..MOVS.pc, r1|
00007920  34 0a 0a 20 47 6c 6f 62  44 65 66 20 39 36 2c 4f  |4.. GlobDef 96,O|
00007930  53 41 72 67 73 0a 20 3b  20 72 65 73 75 6c 74 20  |SArgs. ; result |
00007940  3a 3d 20 6f 73 61 72 67  73 28 6f 70 2c 20 68 61  |:= osargs(op, ha|
00007950  6e 64 6c 65 2c 20 70 74  72 29 0a 0a 09 4d 4f 56  |ndle, ptr)...MOV|
00007960  09 72 30 2c 20 61 31 0a  09 4d 4f 56 09 72 31 2c  |.r0, a1..MOV.r1,|
00007970  20 61 32 0a 09 4d 4f 56  09 72 32 2c 20 61 33 0a  | a2..MOV.r2, a3.|
00007980  09 53 57 49 09 41 72 67  73 0a 09 4d 4f 56 09 61  |.SWI.Args..MOV.a|
00007990  31 2c 20 72 30 0a 09 53  54 52 09 72 32 2c 20 5b  |1, r0..STR.r2, [|
000079a0  72 67 2c 20 23 47 5f 72  65 73 75 6c 74 32 5d 0a  |rg, #G_result2].|
000079b0  09 4d 4f 56 53 09 70 63  2c 20 72 31 34 0a 0a 0a  |.MOVS.pc, r14...|
000079c0  20 47 6c 6f 62 44 65 66  20 39 39 2c 4f 53 46 69  | GlobDef 99,OSFi|
000079d0  6e 64 0a 0a 20 3b 20 4f  53 46 69 6e 64 28 6f 70  |nd.. ; OSFind(op|
000079e0  2c 20 61 72 67 29 0a 20  3b 20 6f 70 3d 30 2c 20  |, arg). ; op=0, |
000079f0  28 63 6c 6f 73 65 29 20  61 72 67 20 69 73 20 66  |(close) arg is f|
00007a00  69 6c 65 20 68 61 6e 64  6c 65 0a 20 3b 20 6f 70  |ile handle. ; op|
00007a10  20 7e 3d 30 20 28 6f 70  65 6e 29 20 61 72 67 20  | ~=0 (open) arg |
00007a20  69 73 20 66 69 6c 65 20  6e 61 6d 65 2c 20 72 65  |is file name, re|
00007a30  74 75 72 6e 73 20 68 61  6e 64 6c 65 0a 20 3b 09  |turns handle. ;.|
00007a40  20 20 66 69 6c 65 6e 61  6d 65 20 69 73 20 42 43  |  filename is BC|
00007a50  50 4c 20 73 74 72 69 6e  67 3a 20 6d 75 73 74 20  |PL string: must |
00007a60  62 65 20 6d 61 64 65 20  69 6e 74 6f 20 43 52 2d  |be made into CR-|
00007a70  74 65 72 6d 69 6e 61 74  65 64 20 6f 6e 65 0a 09  |terminated one..|
00007a80  53 54 4d 45 41 09 72 74  73 21 2c 20 7b 72 31 34  |STMEA.rts!, {r14|
00007a90  7d 0a 09 4d 4f 56 53 09  72 30 2c 20 61 31 0a 09  |}..MOVS.r0, a1..|
00007aa0  4d 4f 56 09 72 31 2c 20  61 32 0a 09 4d 4f 56 09  |MOV.r1, a2..MOV.|
00007ab0  72 32 2c 20 23 30 0a 09  42 45 51 09 64 6f 6f 73  |r2, #0..BEQ.doos|
00007ac0  66 0a 0a 09 4d 4f 56 09  72 31 2c 20 72 31 2c 20  |f...MOV.r1, r1, |
00007ad0  41 53 4c 20 23 32 0a 09  42 4c 09 63 72 74 65 72  |ASL #2..BL.crter|
00007ae0  6d 0a 0a 64 6f 6f 73 66  0a 09 53 57 49 09 4f 70  |m..doosf..SWI.Op|
00007af0  65 6e 0a 09 53 54 52 09  72 30 2c 20 5b 72 67 2c  |en..STR.r0, [rg,|
00007b00  20 23 47 5f 72 65 73 75  6c 74 32 5d 0a 09 4d 4f  | #G_result2]..MO|
00007b10  56 56 53 09 72 30 2c 20  23 30 09 09 3b 20 49 20  |VVS.r0, #0..; I |
00007b20  73 75 70 70 6f 73 65 20  79 6f 75 20 63 61 6e 20  |suppose you can |
00007b30  67 65 74 20 61 6e 20 65  72 72 6f 72 20 68 65 72  |get an error her|
00007b40  65 0a 61 66 74 65 72 6f  73 66 0a 09 43 4d 50 53  |e.afterosf..CMPS|
00007b50  09 72 32 2c 20 23 30 09  09 3b 20 72 32 20 6e 6f  |.r2, #0..; r2 no|
00007b60  6e 2d 7a 65 72 6f 20 6d  65 61 6e 73 20 61 6e 20  |n-zero means an |
00007b70  61 72 67 75 6d 65 6e 74  20 73 74 72 69 6e 67 20  |argument string |
00007b80  6e 65 65 64 73 0a 09 4d  4f 56 45 51 09 61 31 2c  |needs..MOVEQ.a1,|
00007b90  20 72 30 09 09 3b 20 73  68 75 66 66 6c 69 6e 67  | r0..; shuffling|
00007ba0  20 75 70 20 61 67 61 69  6e 0a 09 4c 44 4d 45 51  | up again..LDMEQ|
00007bb0  45 41 20 72 74 73 21 2c  20 7b 70 63 7d 5e 0a 20  |EA rts!, {pc}^. |
00007bc0  3b 20 72 33 20 70 6f 69  6e 74 73 20 74 6f 20 74  |; r3 points to t|
00007bd0  68 65 20 6c 61 73 74 20  62 79 74 65 20 6f 66 20  |he last byte of |
00007be0  74 68 65 20 73 74 72 69  6e 67 20 61 73 20 77 61  |the string as wa|
00007bf0  73 2c 20 6e 6f 77 20 69  74 73 20 74 65 72 6d 69  |s, now its termi|
00007c00  6e 61 74 69 6e 67 20 43  52 0a 20 3b 20 72 34 20  |nating CR. ; r4 |
00007c10  70 6f 69 6e 74 73 20 74  6f 20 74 68 65 20 66 69  |points to the fi|
00007c20  72 73 74 20 62 79 74 65  20 28 77 61 73 20 74 68  |rst byte (was th|
00007c30  65 20 6c 65 6e 67 74 68  29 2e 20 72 32 20 69 73  |e length). r2 is|
00007c40  20 74 68 65 20 6c 65 6e  67 74 68 2e 0a 6f 73 66  | the length..osf|
00007c50  63 32 0a 09 4c 44 52 42  09 72 31 2c 20 5b 72 33  |c2..LDRB.r1, [r3|
00007c60  2c 20 23 2d 31 5d 0a 09  53 54 52 42 09 72 31 2c  |, #-1]..STRB.r1,|
00007c70  20 5b 72 33 5d 2c 20 23  2d 31 0a 09 43 4d 50 53  | [r3], #-1..CMPS|
00007c80  09 72 33 2c 20 72 34 0a  09 42 47 54 09 6f 73 66  |.r3, r4..BGT.osf|
00007c90  63 32 0a 09 53 54 52 42  09 72 32 2c 20 5b 72 33  |c2..STRB.r2, [r3|
00007ca0  5d 0a 09 4d 4f 56 09 61  31 2c 20 72 30 0a 09 4c  |]..MOV.a1, r0..L|
00007cb0  44 4d 45 41 09 72 74 73  21 2c 20 7b 70 63 7d 5e  |DMEA.rts!, {pc}^|
00007cc0  0a 0a 63 72 74 65 72 6d  0a 09 4c 44 52 42 09 72  |..crterm..LDRB.r|
00007cd0  32 2c 20 5b 72 31 2c 20  23 30 5d 09 3b 20 6c 65  |2, [r1, #0].; le|
00007ce0  6e 67 74 68 20 6f 66 20  66 69 6c 65 6e 61 6d 65  |ngth of filename|
00007cf0  0a 09 41 4e 44 09 72 33  2c 20 72 32 2c 20 23 33  |..AND.r3, r2, #3|
00007d00  0a 09 43 4d 50 53 09 72  33 2c 20 23 33 0a 09 42  |..CMPS.r3, #3..B|
00007d10  45 51 09 6f 73 66 64 6f  77 6e 0a 09 4d 4f 56 09  |EQ.osfdown..MOV.|
00007d20  72 33 2c 20 23 26 30 44  09 3b 20 69 66 20 74 68  |r3, #&0D.; if th|
00007d30  65 72 65 27 73 20 72 6f  6f 6d 2c 20 61 64 64 20  |ere's room, add |
00007d40  61 20 74 65 72 6d 69 6e  61 74 69 6e 67 0a 09 41  |a terminating..A|
00007d50  44 44 09 72 31 2c 20 72  31 2c 20 23 31 09 3b 20  |DD.r1, r1, #1.; |
00007d60  43 52 20 6f 6e 20 74 68  65 20 65 6e 64 20 6f 66  |CR on the end of|
00007d70  20 74 68 65 20 73 74 72  69 6e 67 0a 09 53 54 52  | the string..STR|
00007d80  42 09 72 33 2c 20 5b 72  31 2c 20 72 32 5d 0a 09  |B.r3, [r1, r2]..|
00007d90  4d 4f 56 09 72 32 2c 20  23 30 0a 09 4d 4f 56 09  |MOV.r2, #0..MOV.|
00007da0  70 63 2c 20 72 31 34 0a  0a 6f 73 66 64 6f 77 6e  |pc, r14..osfdown|
00007db0  20 09 09 09 3b 20 6f 74  68 65 72 77 69 73 65 2c  | ...; otherwise,|
00007dc0  20 73 68 75 66 66 6c 65  20 74 68 65 20 73 74 72  | shuffle the str|
00007dd0  69 6e 67 20 64 6f 77 6e  0a 09 4d 4f 56 09 72 33  |ing down..MOV.r3|
00007de0  2c 20 72 31 09 09 3b 20  6f 6e 65 20 62 79 74 65  |, r1..; one byte|
00007df0  20 28 72 65 6d 65 6d 62  65 72 69 6e 67 20 74 68  | (remembering th|
00007e00  65 20 6c 65 6e 67 74 68  29 20 61 6e 64 20 70 6c  |e length) and pl|
00007e10  61 6e 74 0a 09 41 44 44  09 72 35 2c 20 72 31 2c  |ant..ADD.r5, r1,|
00007e20  20 72 32 09 3b 20 61 20  43 52 20 61 74 20 74 68  | r2.; a CR at th|
00007e30  65 20 65 6e 64 0a 6f 73  66 63 6f 70 79 0a 09 4c  |e end.osfcopy..L|
00007e40  44 52 42 09 72 34 2c 20  5b 72 33 2c 20 23 31 5d  |DRB.r4, [r3, #1]|
00007e50  0a 09 53 54 52 42 09 72  34 2c 20 5b 72 33 5d 2c  |..STRB.r4, [r3],|
00007e60  20 23 31 0a 09 43 4d 50  53 09 72 33 2c 20 72 35  | #1..CMPS.r3, r5|
00007e70  0a 09 42 4c 54 09 6f 73  66 63 6f 70 79 0a 09 4d  |..BLT.osfcopy..M|
00007e80  4f 56 09 72 35 2c 20 23  26 30 44 0a 09 53 54 52  |OV.r5, #&0D..STR|
00007e90  42 09 72 35 2c 20 5b 72  33 5d 0a 09 4d 4f 56 09  |B.r5, [r3]..MOV.|
00007ea0  72 34 2c 20 72 31 0a 09  4d 4f 56 09 70 63 2c 20  |r4, r1..MOV.pc, |
00007eb0  72 31 34 0a 0a 20 47 6c  6f 62 44 65 66 20 31 30  |r14.. GlobDef 10|
00007ec0  30 2c 4f 53 46 69 6c 65  0a 0a 20 3b 20 6f 73 66  |0,OSFile.. ; osf|
00007ed0  69 6c 65 20 77 68 61 74  2c 20 66 69 6c 65 6e 61  |ile what, filena|
00007ee0  6d 65 2c 20 61 72 67 73  0a 20 3b 20 66 69 6c 65  |me, args. ; file|
00007ef0  6e 61 6d 65 20 69 73 20  61 20 42 43 50 4c 20 73  |name is a BCPL s|
00007f00  74 72 69 6e 67 20 28 73  6f 20 6e 65 65 64 73 20  |tring (so needs |
00007f10  63 6f 6e 76 65 72 73 69  6f 6e 29 0a 20 3b 20 61  |conversion). ; a|
00007f20  72 67 73 20 69 73 20 61  20 42 43 50 4c 20 76 65  |rgs is a BCPL ve|
00007f30  63 74 6f 72 2c 20 62 75  74 20 74 68 65 20 61 64  |ctor, but the ad|
00007f40  64 72 65 73 73 65 73 20  69 6e 20 69 74 20 61 72  |dresses in it ar|
00007f50  65 20 72 65 61 6c 2e 0a  20 3b 20 49 66 20 61 6e  |e real.. ; If an|
00007f60  20 65 72 72 6f 72 20 6f  63 63 75 72 73 2c 20 52  | error occurs, R|
00007f70  65 73 75 6c 74 32 20 69  73 20 72 65 74 75 72 6e  |esult2 is return|
00007f80  65 64 20 6e 6f 6e 2d 7a  65 72 6f 0a 09 53 54 4d  |ed non-zero..STM|
00007f90  45 41 09 72 74 73 21 2c  20 7b 72 31 34 7d 0a 09  |EA.rts!, {r14}..|
00007fa0  4d 4f 56 09 72 30 2c 20  61 31 0a 09 4d 4f 56 09  |MOV.r0, a1..MOV.|
00007fb0  72 31 2c 20 61 32 2c 20  41 53 4c 20 23 32 0a 09  |r1, a2, ASL #2..|
00007fc0  4d 4f 56 09 72 62 2c 20  61 33 0a 09 4d 4f 56 09  |MOV.rb, a3..MOV.|
00007fd0  72 32 2c 20 23 30 0a 09  42 4c 09 63 72 74 65 72  |r2, #0..BL.crter|
00007fe0  6d 0a 09 4d 4f 56 09 72  62 2c 20 72 62 2c 20 41  |m..MOV.rb, rb, A|
00007ff0  53 4c 20 23 32 0a 09 53  54 4d 45 41 09 72 74 73  |SL #2..STMEA.rts|
00008000  21 2c 20 7b 72 32 2c 20  72 33 2c 20 72 34 7d 0a  |!, {r2, r3, r4}.|
00008010  09 4c 44 4d 49 41 09 72  62 2c 20 7b 72 32 2c 20  |.LDMIA.rb, {r2, |
00008020  72 33 2c 20 72 34 2c 20  72 35 7d 20 20 3b 20 75  |r3, r4, r5}  ; u|
00008030  2d 6b 20 63 61 6c 6c 20  77 61 6e 74 73 20 61 72  |-k call wants ar|
00008040  67 73 20 69 6e 20 72 65  67 69 73 74 65 72 73 0a  |gs in registers.|
00008050  09 53 57 49 09 46 69 6c  65 0a 09 53 54 4d 49 41  |.SWI.File..STMIA|
00008060  09 72 62 2c 20 7b 72 32  2c 20 72 33 2c 20 72 34  |.rb, {r2, r3, r4|
00008070  2c 20 72 35 7d 20 20 3b  20 61 6e 64 20 72 65 74  |, r5}  ; and ret|
00008080  75 72 6e 73 20 74 68 65  6d 20 6c 69 6b 65 77 69  |urns them likewi|
00008090  73 65 0a 09 4d 4f 56 09  72 32 2c 20 23 30 0a 09  |se..MOV.r2, #0..|
000080a0  4d 56 4e 56 53 09 72 32  2c 20 23 30 0a 09 53 54  |MVNVS.r2, #0..ST|
000080b0  52 09 72 32 2c 20 5b 72  67 2c 20 23 47 5f 72 65  |R.r2, [rg, #G_re|
000080c0  73 75 6c 74 32 5d 0a 09  4c 44 4d 45 41 09 72 74  |sult2]..LDMEA.rt|
000080d0  73 21 2c 20 7b 72 32 2c  20 72 33 2c 20 72 34 7d  |s!, {r2, r3, r4}|
000080e0  0a 09 42 09 61 66 74 65  72 6f 73 66 0a 0a 20 47  |..B.afterosf.. G|
000080f0  6c 6f 62 44 65 66 20 31  30 37 2c 4f 53 47 42 50  |lobDef 107,OSGBP|
00008100  42 0a 20 3b 20 4f 53 47  42 50 42 20 66 75 6e 63  |B. ; OSGBPB func|
00008110  74 69 6f 6e 2c 20 68 61  6e 64 6c 65 2c 20 70 61  |tion, handle, pa|
00008120  72 61 6d 65 74 65 72 73  0a 20 3b 20 70 61 72 61  |rameters. ; para|
00008130  6d 65 74 65 72 73 20 69  73 20 61 20 42 43 50 4c  |meters is a BCPL|
00008140  20 76 65 63 74 6f 72 3b  20 61 64 64 72 65 73 73  | vector; address|
00008150  65 73 20 69 6e 20 69 74  20 61 72 65 20 48 57 20  |es in it are HW |
00008160  6f 6e 65 73 2e 0a 20 3b  20 52 65 74 75 72 6e 73  |ones.. ; Returns|
00008170  20 72 65 73 75 6c 74 20  73 65 74 20 6f 6e 20 73  | result set on s|
00008180  75 63 63 65 73 73 20 6f  66 20 63 61 6c 6c 20 28  |uccess of call (|
00008190  23 30 20 69 66 20 63 61  72 72 79 20 6f 72 20 6f  |#0 if carry or o|
000081a0  76 65 72 66 6c 6f 77 29  2e 0a 20 3b 20 72 65 73  |verflow).. ; res|
000081b0  75 6c 74 32 20 69 73 20  74 68 65 20 72 65 74 75  |ult2 is the retu|
000081c0  72 6e 65 64 20 68 61 6e  64 6c 65 0a 09 53 54 4d  |rned handle..STM|
000081d0  45 41 09 72 74 73 21 2c  20 7b 72 31 34 7d 0a 09  |EA.rts!, {r14}..|
000081e0  4d 4f 56 09 72 30 2c 20  61 31 0a 09 4d 4f 56 09  |MOV.r0, a1..MOV.|
000081f0  72 31 2c 20 61 32 0a 09  4d 4f 56 09 72 62 2c 20  |r1, a2..MOV.rb, |
00008200  61 33 2c 20 41 53 4c 20  23 32 0a 09 4c 44 4d 49  |a3, ASL #2..LDMI|
00008210  41 09 72 62 2c 20 7b 72  32 2c 20 72 33 2c 20 72  |A.rb, {r2, r3, r|
00008220  34 7d 0a 09 53 57 49 09  4d 75 6c 74 69 70 6c 65  |4}..SWI.Multiple|
00008230  0a 09 53 54 4d 49 41 09  72 62 2c 20 7b 72 32 2c  |..STMIA.rb, {r2,|
00008240  20 72 33 2c 20 72 34 7d  0a 09 53 54 52 09 72 31  | r3, r4}..STR.r1|
00008250  2c 20 5b 72 67 2c 20 23  47 5f 72 65 73 75 6c 74  |, [rg, #G_result|
00008260  32 5d 0a 09 4d 4f 56 09  61 31 2c 20 23 30 0a 09  |2]..MOV.a1, #0..|
00008270  4d 4f 56 43 53 09 61 31  2c 20 23 31 0a 09 4d 4f  |MOVCS.a1, #1..MO|
00008280  56 56 53 09 61 31 2c 20  23 2d 31 0a 09 4c 44 4d  |VVS.a1, #-1..LDM|
00008290  45 41 09 72 74 73 21 2c  20 7b 70 63 7d 5e 0a 0a  |EA.rts!, {pc}^..|
000082a0  20 47 6c 6f 62 44 65 66  20 31 30 32 2c 4f 53 57  | GlobDef 102,OSW|
000082b0  72 43 68 0a 0a 09 4d 4f  56 09 72 30 2c 20 61 31  |rCh...MOV.r0, a1|
000082c0  0a 09 53 57 49 09 57 72  69 74 65 43 0a 09 4d 4f  |..SWI.WriteC..MO|
000082d0  56 09 61 31 2c 20 72 30  0a 09 4d 4f 56 53 09 70  |V.a1, r0..MOVS.p|
000082e0  63 2c 20 72 31 34 0a 0a  20 47 6c 6f 62 44 65 66  |c, r14.. GlobDef|
000082f0  20 31 30 33 2c 4f 53 52  64 43 68 0a 0a 09 53 57  | 103,OSRdCh...SW|
00008300  49 09 52 65 61 64 43 0a  09 4d 4f 56 09 61 31 2c  |I.ReadC..MOV.a1,|
00008310  20 72 30 0a 09 4d 4f 56  09 72 32 2c 20 23 30 09  | r0..MOV.r2, #0.|
00008320  09 3b 20 74 68 65 20 63  61 72 72 79 20 66 6c 61  |.; the carry fla|
00008330  67 20 67 6f 65 73 20 74  6f 20 52 65 73 75 6c 74  |g goes to Result|
00008340  32 0a 09 4d 56 4e 43 53  09 72 32 2c 20 72 32 0a  |2..MVNCS.r2, r2.|
00008350  09 53 54 52 09 72 32 2c  20 5b 72 67 2c 20 23 47  |.STR.r2, [rg, #G|
00008360  5f 72 65 73 75 6c 74 32  5d 0a 09 4d 4f 56 53 09  |_result2]..MOVS.|
00008370  70 63 2c 20 72 31 34 0a  0a 20 47 6c 6f 62 44 65  |pc, r14.. GlobDe|
00008380  66 20 39 38 2c 4f 53 42  50 75 74 0a 0a 20 3b 20  |f 98,OSBPut.. ; |
00008390  6f 73 62 70 75 74 28 62  79 74 65 2c 20 63 68 61  |osbput(byte, cha|
000083a0  6e 6e 65 6c 29 0a 09 4d  4f 56 09 72 30 2c 20 61  |nnel)..MOV.r0, a|
000083b0  31 0a 09 4d 4f 56 09 72  31 2c 20 61 32 0a 09 53  |1..MOV.r1, a2..S|
000083c0  57 49 09 42 50 75 74 0a  09 4d 4f 56 09 61 31 2c  |WI.BPut..MOV.a1,|
000083d0  20 23 30 0a 09 4d 4f 56  56 53 09 61 31 2c 20 72  | #0..MOVVS.a1, r|
000083e0  30 0a 09 4d 4f 56 53 09  70 63 2c 20 72 31 34 0a  |0..MOVS.pc, r14.|
000083f0  0a 20 47 6c 6f 62 44 65  66 20 39 37 2c 4f 53 42  |. GlobDef 97,OSB|
00008400  47 65 74 0a 0a 20 3b 20  6f 73 62 67 65 74 28 63  |Get.. ; osbget(c|
00008410  68 61 6e 6e 65 6c 29 0a  20 5b 20 61 31 3c 3e 72  |hannel). [ a1<>r|
00008420  31 0a 09 4d 4f 56 09 72  31 2c 20 61 31 0a 20 5d  |1..MOV.r1, a1. ]|
00008430  0a 09 53 57 49 09 42 47  65 74 0a 09 4d 4f 56 09  |..SWI.BGet..MOV.|
00008440  61 31 2c 20 72 30 0a 09  4d 4f 56 43 43 53 09 70  |a1, r0..MOVCCS.p|
00008450  63 2c 20 72 31 34 0a 09  4d 4f 56 09 61 31 2c 20  |c, r14..MOV.a1, |
00008460  23 26 46 46 09 3b 20 63  61 72 72 79 20 73 65 74  |#&FF.; carry set|
00008470  20 2d 3e 20 65 6e 64 6f  66 66 69 6c 65 0a 09 4d  | -> endoffile..M|
00008480  4f 56 09 61 31 2c 20 61  31 2c 20 41 53 4c 20 23  |OV.a1, a1, ASL #|
00008490  31 0a 09 4d 4f 56 53 09  70 63 2c 20 72 31 34 0a  |1..MOVS.pc, r14.|
000084a0  0a 0a 20 47 6c 6f 62 44  65 66 20 36 36 2c 52 65  |.. GlobDef 66,Re|
000084b0  61 64 42 79 74 65 73 0a  3b 0a 3b 4c 45 54 20 72  |adBytes.;.;LET r|
000084c0  65 61 64 62 79 74 65 73  28 76 2c 62 2c 6e 29 20  |eadbytes(v,b,n) |
000084d0  3d 20 56 41 4c 4f 46 0a  3b 24 28 20 46 4f 52 20  |= VALOF.;$( FOR |
000084e0  6a 20 3d 20 30 20 54 4f  20 6e 20 2d 20 31 20 44  |j = 0 TO n - 1 D|
000084f0  4f 0a 3b 20 20 20 24 28  0a 3b 20 20 20 20 20 20  |O.;   $(.;      |
00008500  4c 45 54 20 63 20 3d 20  72 64 63 68 28 29 0a 3b  |LET c = rdch().;|
00008510  20 20 20 20 20 20 49 46  20 63 20 3d 20 65 6e 64  |      IF c = end|
00008520  73 74 72 65 61 6d 63 68  20 74 68 65 6e 20 52 45  |streamch then RE|
00008530  53 55 4c 54 49 53 20 6a  0a 3b 20 20 20 20 20 20  |SULTIS j.;      |
00008540  76 25 28 62 2b 6a 29 20  3a 3d 20 63 0a 3b 20 20  |v%(b+j) := c.;  |
00008550  20 24 29 0a 3b 20 20 20  52 45 53 55 4c 54 49 53  | $).;   RESULTIS|
00008560  20 6e 0a 3b 24 29 0a 3b  0a 09 53 54 4d 45 41 09  | n.;$).;..STMEA.|
00008570  72 74 73 21 2c 20 7b 72  62 2c 20 72 70 2c 20 72  |rts!, {rb, rp, r|
00008580  6c 2c 20 72 31 34 7d 0a  09 53 55 42 09 72 70 2c  |l, r14}..SUB.rp,|
00008590  20 72 74 73 2c 20 23 31  36 0a 09 53 54 4d 45 41  | rts, #16..STMEA|
000085a0  09 72 74 73 21 2c 20 7b  61 33 7d 0a 09 43 4d 50  |.rts!, {a3}..CMP|
000085b0  53 09 61 33 2c 20 23 30  0a 09 42 4c 45 09 52 65  |S.a3, #0..BLE.Re|
000085c0  61 64 42 79 74 65 73 45  78 69 74 0a 09 41 44 44  |adBytesExit..ADD|
000085d0  09 61 32 2c 20 61 32 2c  20 61 31 2c 20 41 53 4c  |.a2, a2, a1, ASL|
000085e0  20 23 32 0a 52 65 61 64  42 79 74 65 73 4c 6f 6f  | #2.ReadBytesLoo|
000085f0  70 0a 09 53 54 4d 45 41  09 72 74 73 21 2c 20 7b  |p..STMEA.rts!, {|
00008600  61 32 2c 20 61 33 7d 0a  09 4c 44 52 09 72 62 2c  |a2, a3}..LDR.rb,|
00008610  20 5b 72 67 2c 20 23 47  5f 42 69 6e 52 64 43 68  | [rg, #G_BinRdCh|
00008620  5d 0a 09 4d 4f 56 09 72  31 34 2c 20 70 63 0a 09  |]..MOV.r14, pc..|
00008630  4d 4f 56 09 70 63 2c 20  72 62 0a 09 4c 44 4d 45  |MOV.pc, rb..LDME|
00008640  41 09 72 74 73 21 2c 20  7b 61 32 2c 20 61 33 7d  |A.rts!, {a2, a3}|
00008650  0a 09 4d 4f 56 09 77 32  2c 20 61 31 2c 20 4c 53  |..MOV.w2, a1, LS|
00008660  52 20 23 31 0a 09 43 4d  50 53 09 77 32 2c 20 23  |R #1..CMPS.w2, #|
00008670  26 66 66 0a 09 42 45 51  09 52 65 61 64 42 79 74  |&ff..BEQ.ReadByt|
00008680  65 73 52 65 74 75 72 6e  4a 0a 09 53 54 52 42 09  |esReturnJ..STRB.|
00008690  61 31 2c 20 5b 61 32 5d  2c 20 23 2b 31 0a 09 53  |a1, [a2], #+1..S|
000086a0  55 42 53 09 61 33 2c 20  61 33 2c 20 23 31 0a 09  |UBS.a3, a3, #1..|
000086b0  42 47 54 09 52 65 61 64  42 79 74 65 73 4c 6f 6f  |BGT.ReadBytesLoo|
000086c0  70 0a 52 65 61 64 42 79  74 65 73 45 78 69 74 0a  |p.ReadBytesExit.|
000086d0  09 4c 44 4d 45 41 09 72  74 73 21 2c 20 7b 61 31  |.LDMEA.rts!, {a1|
000086e0  7d 0a 09 4d 4f 56 09 72  74 73 2c 20 72 70 0a 09  |}..MOV.rts, rp..|
000086f0  4c 44 4d 49 42 09 72 74  73 2c 20 7b 72 70 2c 20  |LDMIB.rts, {rp, |
00008700  72 6c 2c 20 70 63 7d 5e  0a 0a 52 65 61 64 42 79  |rl, pc}^..ReadBy|
00008710  74 65 73 52 65 74 75 72  6e 4a 0a 09 4c 44 4d 45  |tesReturnJ..LDME|
00008720  41 09 72 74 73 21 2c 20  7b 61 31 7d 0a 09 53 55  |A.rts!, {a1}..SU|
00008730  42 09 61 31 2c 20 61 31  2c 20 61 33 0a 09 4d 4f  |B.a1, a1, a3..MO|
00008740  56 09 72 74 73 2c 20 72  70 0a 09 4c 44 4d 49 42  |V.rts, rp..LDMIB|
00008750  09 72 74 73 2c 20 7b 72  70 2c 20 72 6c 2c 20 70  |.rts, {rp, rl, p|
00008760  63 7d 5e 0a 0a 0a 20 47  6c 6f 62 44 65 66 20 36  |c}^... GlobDef 6|
00008770  37 2c 57 72 69 74 65 42  79 74 65 73 0a 0a 3b 41  |7,WriteBytes..;A|
00008780  4e 44 20 77 72 69 74 65  62 79 74 65 73 28 76 2c  |ND writebytes(v,|
00008790  62 2c 6e 29 20 42 45 0a  3b 20 20 20 46 4f 52 20  |b,n) BE.;   FOR |
000087a0  69 20 3d 20 30 20 54 4f  20 6e 20 2d 20 31 20 44  |i = 0 TO n - 1 D|
000087b0  4f 20 62 69 6e 61 72 79  77 72 63 68 28 76 25 28  |O binarywrch(v%(|
000087c0  62 2b 69 29 29 0a 3b 0a  09 53 54 4d 45 41 09 72  |b+i)).;..STMEA.r|
000087d0  74 73 21 2c 20 7b 72 62  2c 20 72 70 2c 20 72 6c  |ts!, {rb, rp, rl|
000087e0  2c 20 72 31 34 7d 0a 09  53 55 42 09 72 70 2c 20  |, r14}..SUB.rp, |
000087f0  72 74 73 2c 20 23 31 36  0a 09 43 4d 50 53 09 61  |rts, #16..CMPS.a|
00008800  33 2c 20 23 30 0a 09 42  4c 45 09 57 72 69 74 65  |3, #0..BLE.Write|
00008810  42 79 74 65 73 45 78 69  74 0a 09 41 44 44 09 61  |BytesExit..ADD.a|
00008820  32 2c 20 61 32 2c 20 61  31 2c 20 41 53 4c 20 23  |2, a2, a1, ASL #|
00008830  32 0a 57 72 69 74 65 42  79 74 65 73 4c 6f 6f 70  |2.WriteBytesLoop|
00008840  0a 09 4c 44 52 42 09 61  31 2c 20 5b 61 32 5d 2c  |..LDRB.a1, [a2],|
00008850  20 23 2b 31 0a 09 53 54  4d 45 41 09 72 74 73 21  | #+1..STMEA.rts!|
00008860  2c 20 7b 61 32 2c 20 61  33 7d 0a 09 4c 44 52 09  |, {a2, a3}..LDR.|
00008870  72 62 2c 20 5b 72 67 2c  20 23 47 5f 42 69 6e 57  |rb, [rg, #G_BinW|
00008880  72 43 68 5d 0a 09 4d 4f  56 09 72 31 34 2c 20 70  |rCh]..MOV.r14, p|
00008890  63 0a 09 4d 4f 56 09 70  63 2c 20 72 62 0a 09 4c  |c..MOV.pc, rb..L|
000088a0  44 4d 45 41 09 72 74 73  21 2c 20 7b 61 32 2c 20  |DMEA.rts!, {a2, |
000088b0  61 33 7d 0a 09 53 55 42  53 09 61 33 2c 20 61 33  |a3}..SUBS.a3, a3|
000088c0  2c 20 23 31 0a 09 42 47  54 09 57 72 69 74 65 42  |, #1..BGT.WriteB|
000088d0  79 74 65 73 4c 6f 6f 70  0a 57 72 69 74 65 42 79  |ytesLoop.WriteBy|
000088e0  74 65 73 45 78 69 74 0a  09 4d 4f 56 09 72 74 73  |tesExit..MOV.rts|
000088f0  2c 20 72 70 0a 09 4c 44  4d 49 42 09 72 74 73 2c  |, rp..LDMIB.rts,|
00008900  20 7b 72 70 2c 20 72 6c  2c 20 70 63 7d 5e 0a 0a  | {rp, rl, pc}^..|
00008910  0a 20 47 6c 6f 62 44 65  66 20 31 36 2c 4d 75 6c  |. GlobDef 16,Mul|
00008920  44 69 76 0a 20 3b 20 6d  75 6c 64 69 76 28 61 2c  |Div. ; muldiv(a,|
00008930  20 62 2c 20 63 29 0a 20  3b 20 72 65 73 75 6c 74  | b, c). ; result|
00008940  20 3d 20 61 2a 62 2f 63  0a 20 3b 20 72 65 73 75  | = a*b/c. ; resu|
00008950  6c 74 32 20 3d 20 61 2a  62 20 52 45 4d 20 63 0a  |lt2 = a*b REM c.|
00008960  20 3b 20 74 68 65 20 69  6e 74 65 72 6d 65 64 69  | ; the intermedi|
00008970  61 74 65 20 70 72 6f 64  75 63 74 20 69 73 20 36  |ate product is 6|
00008980  34 20 62 69 74 73 20 6c  6f 6e 67 0a 20 3b 20 64  |4 bits long. ; d|
00008990  6f 20 65 76 65 72 79 74  68 69 6e 67 20 75 73 69  |o everything usi|
000089a0  6e 67 20 6d 6f 64 75 6c  75 73 65 73 2c 20 61 6e  |ng moduluses, an|
000089b0  64 20 73 6f 72 74 20 6f  75 74 20 73 69 67 6e 73  |d sort out signs|
000089c0  20 6c 61 74 65 72 0a 0a  09 53 54 4d 45 41 09 72  | later...STMEA.r|
000089d0  74 73 21 2c 20 7b 72 62  2c 20 72 70 2c 20 72 6c  |ts!, {rb, rp, rl|
000089e0  2c 20 72 31 34 7d 0a 09  53 55 42 09 72 70 2c 20  |, r14}..SUB.rp, |
000089f0  72 74 73 2c 20 23 31 36  0a 09 53 54 4d 45 41 09  |rts, #16..STMEA.|
00008a00  72 74 73 21 2c 20 7b 61  31 2c 20 61 32 2c 20 61  |rts!, {a1, a2, a|
00008a10  33 7d 0a 0a 20 3b 20 66  69 72 73 74 2c 20 74 68  |3}.. ; first, th|
00008a20  65 20 64 6f 75 62 6c 65  2d 6c 65 6e 67 74 68 20  |e double-length |
00008a30  70 72 6f 64 75 63 74 2c  20 72 65 74 75 72 6e 65  |product, returne|
00008a40  64 20 69 6e 20 61 33 20  26 20 61 34 0a 20 3b 20  |d in a3 & a4. ; |
00008a50  75 73 65 73 20 72 30 2c  20 61 31 20 61 6e 64 20  |uses r0, a1 and |
00008a60  61 32 20 61 73 20 77 6f  72 6b 73 70 61 63 65 0a  |a2 as workspace.|
00008a70  09 4d 4f 56 09 61 33 2c  20 23 30 0a 09 4d 4f 56  |.MOV.a3, #0..MOV|
00008a80  09 61 34 2c 20 23 30 0a  09 4d 4f 56 09 72 30 2c  |.a4, #0..MOV.r0,|
00008a90  20 23 30 0a 09 43 4d 50  53 09 61 32 2c 20 23 30  | #0..CMPS.a2, #0|
00008aa0  0a 09 52 53 42 4c 54 09  61 32 2c 20 61 32 2c 20  |..RSBLT.a2, a2, |
00008ab0  23 30 09 3b 20 61 62 73  20 62 0a 09 4d 4f 56 09  |#0.; abs b..MOV.|
00008ac0  72 62 2c 20 61 32 0a 09  43 4d 50 53 09 61 31 2c  |rb, a2..CMPS.a1,|
00008ad0  20 23 30 0a 09 52 53 42  4c 54 09 61 31 2c 20 61  | #0..RSBLT.a1, a|
00008ae0  31 2c 20 23 30 09 3b 20  61 62 73 20 61 0a 6d 75  |1, #0.; abs a.mu|
00008af0  6c 64 69 76 30 0a 09 4d  4f 56 53 09 61 32 2c 20  |ldiv0..MOVS.a2, |
00008b00  61 32 2c 20 4c 53 52 20  23 31 0a 09 42 43 43 09  |a2, LSR #1..BCC.|
00008b10  6d 75 6c 64 69 76 31 0a  09 41 44 44 53 09 61 34  |muldiv1..ADDS.a4|
00008b20  2c 20 61 34 2c 20 61 31  0a 09 41 44 43 09 61 33  |, a4, a1..ADC.a3|
00008b30  2c 20 61 33 2c 20 72 30  0a 6d 75 6c 64 69 76 31  |, a3, r0.muldiv1|
00008b40  0a 09 4d 4f 56 53 09 61  31 2c 20 61 31 2c 20 41  |..MOVS.a1, a1, A|
00008b50  53 4c 20 23 31 0a 09 41  44 43 09 72 30 2c 20 72  |SL #1..ADC.r0, r|
00008b60  30 2c 20 72 30 0a 09 43  4d 50 53 09 61 32 2c 20  |0, r0..CMPS.a2, |
00008b70  23 30 0a 09 42 4e 45 09  6d 75 6c 64 69 76 30 0a  |#0..BNE.muldiv0.|
00008b80  0a 20 3b 20 6e 6f 77 20  74 68 65 20 36 34 2a 33  |. ; now the 64*3|
00008b90  32 20 62 69 74 20 64 69  76 69 64 65 0a 20 3b 20  |2 bit divide. ; |
00008ba0  64 69 76 69 64 65 6e 64  20 69 6e 20 61 33 20 61  |dividend in a3 a|
00008bb0  6e 64 20 61 34 0a 20 3b  20 72 65 6d 61 69 6e 64  |nd a4. ; remaind|
00008bc0  65 72 20 65 6e 64 73 20  75 70 20 69 6e 20 61 34  |er ends up in a4|
00008bd0  3b 20 71 75 6f 74 69 65  6e 74 20 69 6e 20 72 30  |; quotient in r0|
00008be0  0a 20 3b 20 75 73 65 73  20 61 31 20 61 6e 64 20  |. ; uses a1 and |
00008bf0  61 32 20 74 6f 20 68 6f  6c 64 20 74 68 65 20 28  |a2 to hold the (|
00008c00  73 68 69 66 74 65 64 29  20 64 69 76 69 73 6f 72  |shifted) divisor|
00008c10  3b 0a 20 3b 09 77 32 20  66 6f 72 20 74 68 65 20  |;. ;.w2 for the |
00008c20  63 75 72 72 65 6e 74 20  62 69 74 20 69 6e 20 74  |current bit in t|
00008c30  68 65 20 71 75 6f 74 69  65 6e 74 0a 09 4c 44 4d  |he quotient..LDM|
00008c40  45 41 09 72 74 73 2c 20  7b 61 32 7d 0a 09 43 4d  |EA.rts, {a2}..CM|
00008c50  50 53 09 61 32 2c 20 23  30 0a 09 42 45 51 09 64  |PS.a2, #0..BEQ.d|
00008c60  69 76 69 64 65 62 79 30  0a 09 52 53 42 4c 54 09  |ivideby0..RSBLT.|
00008c70  61 32 2c 20 61 32 2c 20  23 30 09 3b 20 61 62 73  |a2, a2, #0.; abs|
00008c80  20 63 0a 09 4d 4f 56 09  72 62 2c 20 61 32 0a 09  | c..MOV.rb, a2..|
00008c90  4d 4f 56 09 72 30 2c 20  23 30 0a 09 4d 4f 56 09  |MOV.r0, #0..MOV.|
00008ca0  61 31 2c 20 23 30 0a 09  4d 4f 56 09 77 32 2c 20  |a1, #0..MOV.w2, |
00008cb0  23 30 0a 09 4d 4f 56 09  72 31 34 2c 20 23 31 0a  |#0..MOV.r14, #1.|
00008cc0  6d 75 6c 64 69 76 32 0a  09 43 4d 50 53 09 61 31  |muldiv2..CMPS.a1|
00008cd0  2c 20 23 26 38 30 30 30  30 30 30 30 0a 09 42 43  |, #&80000000..BC|
00008ce0  53 09 6d 75 6c 64 69 76  33 0a 09 43 4d 50 53 09  |S.muldiv3..CMPS.|
00008cf0  61 31 2c 20 61 33 0a 09  43 4d 50 45 51 53 09 61  |a1, a3..CMPEQS.a|
00008d00  32 2c 20 61 34 09 09 3b  20 63 6f 6d 70 61 72 65  |2, a4..; compare|
00008d10  20 6f 66 20 5b 61 31 2c  20 61 32 5d 20 61 67 61  | of [a1, a2] aga|
00008d20  69 6e 73 74 20 5b 61 33  2c 20 61 34 5d 0a 09 42  |inst [a3, a4]..B|
00008d30  43 53 09 6d 75 6c 64 69  76 33 0a 09 4d 4f 56 53  |CS.muldiv3..MOVS|
00008d40  09 61 32 2c 20 61 32 2c  20 41 53 4c 20 23 31 0a  |.a2, a2, ASL #1.|
00008d50  09 4d 4f 56 09 61 31 2c  20 61 31 2c 20 41 53 4c  |.MOV.a1, a1, ASL|
00008d60  20 23 31 0a 09 41 44 43  09 61 31 2c 20 61 31 2c  | #1..ADC.a1, a1,|
00008d70  20 23 30 0a 09 41 44 44  09 77 32 2c 20 77 32 2c  | #0..ADD.w2, w2,|
00008d80  20 23 31 0a 09 42 09 6d  75 6c 64 69 76 32 0a 0a  | #1..B.muldiv2..|
00008d90  6d 75 6c 64 69 76 33 0a  09 43 4d 50 53 09 61 31  |muldiv3..CMPS.a1|
00008da0  2c 20 61 33 0a 09 43 4d  50 45 51 53 09 61 32 2c  |, a3..CMPEQS.a2,|
00008db0  20 61 34 0a 09 42 48 49  09 6d 75 6c 64 69 76 34  | a4..BHI.muldiv4|
00008dc0  0a 09 43 4d 50 53 09 77  32 2c 20 23 33 31 0a 09  |..CMPS.w2, #31..|
00008dd0  41 44 44 4c 45 09 72 30  2c 20 72 30 2c 20 72 31  |ADDLE.r0, r0, r1|
00008de0  34 2c 20 41 53 4c 20 77  32 0a 09 53 55 42 53 09  |4, ASL w2..SUBS.|
00008df0  61 34 2c 20 61 34 2c 20  61 32 0a 09 53 42 43 09  |a4, a4, a2..SBC.|
00008e00  61 33 2c 20 61 33 2c 20  61 31 0a 6d 75 6c 64 69  |a3, a3, a1.muldi|
00008e10  76 34 0a 09 4d 4f 56 53  09 61 31 2c 20 61 31 2c  |v4..MOVS.a1, a1,|
00008e20  20 41 53 52 20 23 31 0a  09 4d 4f 56 09 61 32 2c  | ASR #1..MOV.a2,|
00008e30  20 61 32 2c 20 52 52 58  0a 09 53 55 42 53 09 77  | a2, RRX..SUBS.w|
00008e40  32 2c 20 77 32 2c 20 23  31 0a 09 42 47 45 09 6d  |2, w2, #1..BGE.m|
00008e50  75 6c 64 69 76 33 0a 0a  20 3b 20 6e 6f 77 20 61  |uldiv3.. ; now a|
00008e60  6c 6c 20 77 65 20 6e 65  65 64 20 74 6f 20 64 6f  |ll we need to do|
00008e70  20 69 73 20 73 6f 72 74  20 6f 75 74 20 74 68 65  | is sort out the|
00008e80  20 73 69 67 6e 73 2e 0a  09 4c 44 4d 45 41 09 72  | signs...LDMEA.r|
00008e90  74 73 21 2c 20 7b 61 31  2c 20 61 32 2c 20 61 33  |ts!, {a1, a2, a3|
00008ea0  7d 0a 09 45 4f 52 09 61  32 2c 20 61 32 2c 20 61  |}..EOR.a2, a2, a|
00008eb0  31 09 3b 20 61 32 20 68  61 73 20 74 68 65 20 73  |1.; a2 has the s|
00008ec0  69 67 6e 20 6f 66 20 61  2a 62 3a 20 61 33 20 69  |ign of a*b: a3 i|
00008ed0  73 20 74 68 65 20 73 69  67 6e 20 6f 66 20 63 0a  |s the sign of c.|
00008ee0  09 4d 4f 56 09 61 31 2c  20 72 30 0a 09 54 45 51  |.MOV.a1, r0..TEQ|
00008ef0  53 09 61 32 2c 20 61 33  09 09 3b 20 69 66 20 61  |S.a2, a3..; if a|
00008f00  2a 62 20 61 6e 64 20 63  20 68 61 76 65 20 6f 70  |*b and c have op|
00008f10  70 6f 73 69 74 65 20 73  69 67 6e 73 2c 0a 09 52  |posite signs,..R|
00008f20  53 42 4d 49 09 61 31 2c  20 61 31 2c 20 23 30 09  |SBMI.a1, a1, #0.|
00008f30  3b 20 6e 65 67 61 74 65  20 74 68 65 20 71 75 6f  |; negate the quo|
00008f40  74 69 65 6e 74 0a 09 43  4d 50 53 09 61 32 2c 20  |tient..CMPS.a2, |
00008f50  23 30 09 09 3b 20 61 6e  64 20 69 66 20 74 68 65  |#0..; and if the|
00008f60  20 64 69 76 69 64 65 6e  64 20 77 61 73 20 6e 65  | dividend was ne|
00008f70  67 61 74 69 76 65 2c 0a  09 52 53 42 4c 54 09 61  |gative,..RSBLT.a|
00008f80  34 2c 20 61 34 2c 20 23  30 09 3b 20 6e 65 67 61  |4, a4, #0.; nega|
00008f90  74 65 20 74 68 65 20 72  65 6d 61 69 6e 64 65 72  |te the remainder|
00008fa0  0a 09 53 54 52 09 61 34  2c 20 5b 72 67 2c 20 23  |..STR.a4, [rg, #|
00008fb0  47 5f 72 65 73 75 6c 74  32 5d 0a 09 4c 44 4d 45  |G_result2]..LDME|
00008fc0  41 09 72 74 73 21 2c 20  7b 72 62 2c 20 72 70 2c  |A.rts!, {rb, rp,|
00008fd0  20 72 6c 2c 20 70 63 7d  5e 0a 0a 20 47 6c 6f 62  | rl, pc}^.. Glob|
00008fe0  44 65 66 20 35 34 2c 47  65 74 56 65 63 0a 0a 09  |Def 54,GetVec...|
00008ff0  41 44 44 09 72 31 2c 20  61 31 2c 20 23 32 09 3b  |ADD.r1, a1, #2.;|
00009000  20 61 63 74 75 61 6c 20  6e 75 6d 62 65 72 20 6f  | actual number o|
00009010  66 20 77 6f 72 64 73 20  72 65 71 75 69 72 65 64  |f words required|
00009020  0a 09 43 4d 50 53 09 72  31 2c 20 23 31 0a 09 42  |..CMPS.r1, #1..B|
00009030  4c 45 09 67 76 66 61 69  6c 0a 0a 09 4c 44 52 09  |LE.gvfail...LDR.|
00009040  72 30 2c 20 4c 6f 63 61  6c 44 61 74 61 50 0a 09  |r0, LocalDataP..|
00009050  41 44 44 09 72 30 2c 20  72 30 2c 20 23 4f 5f 66  |ADD.r0, r0, #O_f|
00009060  72 65 65 48 65 61 70 43  68 61 69 6e 2d 34 09 3b  |reeHeapChain-4.;|
00009070  20 70 72 65 76 69 6f 75  73 20 66 72 65 65 20 63  | previous free c|
00009080  68 61 69 6e 20 65 6e 74  72 79 0a 09 4c 44 52 09  |hain entry..LDR.|
00009090  72 33 2c 20 5b 72 30 2c  20 23 34 5d 09 09 09 3b  |r3, [r0, #4]...;|
000090a0  20 66 72 65 65 20 63 68  61 69 6e 20 28 42 43 50  | free chain (BCP|
000090b0  4c 20 61 64 64 72 65 73  73 29 0a 67 76 30 09 4d  |L address).gv0.M|
000090c0  4f 56 09 72 62 2c 20 72  33 2c 20 41 53 4c 20 23  |OV.rb, r3, ASL #|
000090d0  32 0a 09 4c 44 4d 49 41  09 72 62 2c 20 7b 72 34  |2..LDMIA.rb, {r4|
000090e0  2c 20 72 35 7d 0a 09 43  4d 50 53 09 72 34 2c 20  |, r5}..CMPS.r4, |
000090f0  23 30 0a 09 42 45 51 09  67 76 66 61 69 6c 0a 0a  |#0..BEQ.gvfail..|
00009100  20 3b 20 61 20 66 72 65  65 20 62 6c 6f 63 6b 20  | ; a free block |
00009110  68 61 73 20 62 65 65 6e  20 66 6f 75 6e 64 2e 20  |has been found. |
00009120  20 41 6d 61 6c 67 61 6d  61 74 65 20 6c 61 74 65  | Amalgamate late|
00009130  72 20 62 6c 6f 63 6b 73  0a 09 4d 4f 56 09 72 32  |r blocks..MOV.r2|
00009140  2c 20 72 33 09 09 3b 20  73 74 61 72 74 20 6f 66  |, r3..; start of|
00009150  20 66 72 65 65 20 73 70  61 63 65 20 28 73 61 76  | free space (sav|
00009160  65 64 20 66 6f 72 20 6c  61 74 65 72 29 0a 67 76  |ed for later).gv|
00009170  31 09 41 44 44 09 72 33  2c 20 72 34 2c 20 72 33  |1.ADD.r3, r4, r3|
00009180  09 3b 20 61 64 6a 61 63  65 6e 74 20 62 6c 6f 63  |.; adjacent bloc|
00009190  6b 20 61 62 6f 76 65 0a  09 4d 4f 56 09 72 62 2c  |k above..MOV.rb,|
000091a0  20 72 33 2c 20 41 53 4c  20 23 32 0a 09 4c 44 4d  | r3, ASL #2..LDM|
000091b0  49 41 09 72 62 2c 20 7b  72 34 2c 20 72 62 7d 0a  |IA.rb, {r4, rb}.|
000091c0  09 43 4d 50 53 09 72 34  2c 20 23 30 0a 09 4d 4f  |.CMPS.r4, #0..MO|
000091d0  56 47 54 09 72 35 2c 20  72 62 0a 09 42 47 54 09  |VGT.r5, rb..BGT.|
000091e0  67 76 31 09 09 3b 20 74  68 69 73 20 62 6c 6f 63  |gv1..; this bloc|
000091f0  6b 20 69 73 20 66 72 65  65 20 74 6f 6f 0a 0a 20  |k is free too.. |
00009200  3b 20 65 6e 64 20 6f 66  20 61 64 6a 61 63 65 6e  |; end of adjacen|
00009210  74 20 66 72 65 65 20 62  6c 6f 63 6b 73 2e 0a 20  |t free blocks.. |
00009220  3b 20 72 32 20 3d 20 73  74 61 72 74 20 6f 66 20  |; r2 = start of |
00009230  66 72 65 65 20 73 70 61  63 65 0a 20 3b 20 72 33  |free space. ; r3|
00009240  20 3d 20 65 6e 64 20 6f  66 20 66 72 65 65 20 73  | = end of free s|
00009250  70 61 63 65 20 28 62 6f  74 68 20 42 43 50 4c 20  |pace (both BCPL |
00009260  61 64 64 72 65 73 73 65  73 29 0a 09 53 55 42 09  |addresses)..SUB.|
00009270  72 34 2c 20 72 33 2c 20  72 32 09 3b 20 61 6d 6f  |r4, r3, r2.; amo|
00009280  75 6e 74 20 66 72 65 65  20 28 77 6f 72 64 73 29  |unt free (words)|
00009290  0a 09 43 4d 50 53 09 72  34 2c 20 72 31 09 09 3b  |..CMPS.r4, r1..;|
000092a0  20 63 6f 6d 70 61 72 65  20 61 67 61 69 6e 73 74  | compare against|
000092b0  20 72 65 71 75 65 73 74  0a 09 4d 4f 56 09 72 62  | request..MOV.rb|
000092c0  2c 20 72 32 2c 20 41 53  4c 20 23 32 0a 09 53 54  |, r2, ASL #2..ST|
000092d0  4d 4c 54 49 41 20 72 62  2c 20 7b 72 34 2c 20 72  |MLTIA rb, {r4, r|
000092e0  35 7d 09 3b 20 6e 6f 74  20 65 6e 6f 75 67 68 20  |5}.; not enough |
000092f0  2d 20 72 65 77 72 69 74  65 20 6c 65 6e 67 74 68  |- rewrite length|
00009300  20 61 6e 64 20 6e 65 78  74 0a 09 4d 4f 56 4c 54  | and next..MOVLT|
00009310  09 72 30 2c 20 72 62 09  09 3b 20 6e 65 77 20 70  |.r0, rb..; new p|
00009320  72 65 76 69 6f 75 73 0a  09 4d 4f 56 4c 54 09 72  |revious..MOVLT.r|
00009330  33 2c 20 72 35 0a 09 42  4c 54 09 67 76 30 20 3b  |3, r5..BLT.gv0 ;|
00009340  20 6e 6f 74 20 65 6e 6f  75 67 68 0a 0a 09 53 55  | not enough...SU|
00009350  42 09 72 34 2c 20 72 34  2c 20 72 31 0a 09 43 4d  |B.r4, r4, r1..CM|
00009360  50 53 09 72 34 2c 20 23  31 09 09 3b 20 64 6f 6e  |PS.r4, #1..; don|
00009370  27 74 20 62 6f 74 68 65  72 20 77 69 74 68 20 73  |'t bother with s|
00009380  69 6e 67 6c 65 2d 77 6f  72 64 20 62 6c 6f 63 6b  |ingle-word block|
00009390  73 0a 09 09 09 09 3b 20  28 74 68 65 79 27 72 65  |s.....; (they're|
000093a0  20 75 6e 61 6c 6c 6f 63  61 74 61 62 6c 65 20 61  | unallocatable a|
000093b0  6e 79 68 6f 77 29 0a 09  41 44 44 47 54 09 72 33  |nyhow)..ADDGT.r3|
000093c0  2c 20 72 32 2c 20 72 31  09 3b 20 69 66 20 6e 6f  |, r2, r1.; if no|
000093d0  74 20 65 78 61 63 74 20  66 69 74 2c 20 66 72 65  |t exact fit, fre|
000093e0  65 20 72 65 6d 61 69 6e  64 65 72 0a 09 53 54 52  |e remainder..STR|
000093f0  47 54 09 72 33 2c 20 5b  72 30 2c 20 23 34 5d 0a  |GT.r3, [r0, #4].|
00009400  09 4d 4f 56 47 54 09 72  33 2c 20 72 33 2c 20 41  |.MOVGT.r3, r3, A|
00009410  53 4c 20 23 32 0a 09 53  54 4d 47 54 49 41 20 72  |SL #2..STMGTIA r|
00009420  33 2c 20 7b 72 34 2c 20  72 35 7d 0a 0a 09 53 54  |3, {r4, r5}...ST|
00009430  52 4c 45 09 72 35 2c 20  5b 72 30 2c 20 23 34 5d  |RLE.r5, [r0, #4]|
00009440  0a 09 41 44 44 4c 45 09  72 31 2c 20 72 31 2c 20  |..ADDLE.r1, r1, |
00009450  72 34 0a 0a 09 52 53 42  09 72 31 2c 20 72 31 2c  |r4...RSB.r1, r1,|
00009460  20 23 30 09 3b 20 6d 61  72 6b 20 62 6c 6f 63 6b  | #0.; mark block|
00009470  20 61 6c 6c 6f 63 61 74  65 64 0a 09 53 54 52 09  | allocated..STR.|
00009480  72 31 2c 20 5b 72 62 5d  0a 09 41 44 44 09 61 31  |r1, [rb]..ADD.a1|
00009490  2c 20 72 32 2c 20 23 31  09 3b 20 76 65 63 74 6f  |, r2, #1.; vecto|
000094a0  72 20 72 65 74 75 72 6e  65 64 20 6f 6d 69 74 73  |r returned omits|
000094b0  20 74 68 65 20 68 65 61  64 65 72 0a 09 4d 4f 56  | the header..MOV|
000094c0  53 09 70 63 2c 20 72 31  34 0a 0a 67 76 66 61 69  |S.pc, r14..gvfai|
000094d0  6c 09 4d 4f 56 09 61 31  2c 20 23 30 0a 09 4d 4f  |l.MOV.a1, #0..MO|
000094e0  56 53 09 70 63 2c 20 72  31 34 0a 0a 20 47 6c 6f  |VS.pc, r14.. Glo|
000094f0  62 44 65 66 20 35 35 2c  46 72 65 65 56 65 63 0a  |bDef 55,FreeVec.|
00009500  0a 09 43 4d 50 53 09 61  31 2c 20 23 30 0a 09 4d  |..CMPS.a1, #0..M|
00009510  4f 56 4c 45 53 09 70 63  2c 20 72 31 34 0a 09 54  |OVLES.pc, r14..T|
00009520  53 54 53 09 61 31 2c 20  23 26 66 66 30 30 30 30  |STS.a1, #&ff0000|
00009530  30 30 0a 09 42 4e 45 09  46 56 45 72 72 6f 72 0a  |00..BNE.FVError.|
00009540  09 53 55 42 09 72 31 2c  20 61 31 2c 20 23 31 0a  |.SUB.r1, a1, #1.|
00009550  09 4d 4f 56 09 72 32 2c  20 72 31 2c 20 41 53 4c  |.MOV.r2, r1, ASL|
00009560  20 23 32 0a 09 4c 44 52  09 72 33 2c 20 5b 72 32  | #2..LDR.r3, [r2|
00009570  5d 0a 09 52 53 42 53 09  72 33 2c 20 72 33 2c 20  |]..RSBS.r3, r3, |
00009580  23 30 0a 09 42 4c 45 09  46 56 45 72 72 6f 72 0a  |#0..BLE.FVError.|
00009590  09 4c 44 52 09 72 30 2c  20 4c 6f 63 61 6c 44 61  |.LDR.r0, LocalDa|
000095a0  74 61 50 0a 09 41 44 44  09 72 30 2c 20 72 30 2c  |taP..ADD.r0, r0,|
000095b0  20 23 4f 5f 66 72 65 65  48 65 61 70 43 68 61 69  | #O_freeHeapChai|
000095c0  6e 2d 34 09 3b 20 70 72  65 76 69 6f 75 73 20 66  |n-4.; previous f|
000095d0  72 65 65 20 63 68 61 69  6e 20 65 6e 74 72 79 0a  |ree chain entry.|
000095e0  46 56 31 0a 09 4c 44 52  09 72 34 2c 20 5b 72 30  |FV1..LDR.r4, [r0|
000095f0  2c 20 23 34 5d 0a 09 43  4d 50 53 09 72 31 2c 20  |, #4]..CMPS.r1, |
00009600  72 34 0a 09 4d 4f 56 47  54 09 72 30 2c 20 72 34  |r4..MOVGT.r0, r4|
00009610  2c 20 41 53 4c 20 23 32  0a 09 42 47 54 09 46 56  |, ASL #2..BGT.FV|
00009620  31 0a 09 53 54 52 09 72  31 2c 20 5b 72 30 2c 20  |1..STR.r1, [r0, |
00009630  23 34 5d 0a 09 53 54 4d  49 41 09 72 32 2c 20 7b  |#4]..STMIA.r2, {|
00009640  72 33 2c 20 72 34 7d 0a  09 4d 4f 56 53 09 70 63  |r3, r4}..MOVS.pc|
00009650  2c 20 72 31 34 0a 0a 46  56 45 72 72 6f 72 0a 09  |, r14..FVError..|
00009660  41 44 52 09 61 31 2c 20  46 56 45 72 72 4d 65 73  |ADR.a1, FVErrMes|
00009670  73 0a 09 42 09 43 61 6c  6c 5f 46 61 75 6c 74 0a  |s..B.Call_Fault.|
00009680  46 56 45 72 72 4d 65 73  73 0a 09 3d 09 31 33 2c  |FVErrMess..=.13,|
00009690  22 46 72 65 65 56 65 63  20 65 72 72 6f 72 22 0a  |"FreeVec error".|
000096a0  09 41 4c 49 47 4e 09 34  0a 0a 0a 20 47 6c 6f 62  |.ALIGN.4... Glob|
000096b0  44 65 66 20 34 31 2c 4c  65 76 65 6c 0a 0a 09 4d  |Def 41,Level...M|
000096c0  4f 56 09 61 31 2c 20 72  70 0a 09 4d 4f 56 53 09  |OV.a1, rp..MOVS.|
000096d0  70 63 2c 20 72 31 34 0a  0a 20 47 6c 6f 62 44 65  |pc, r14.. GlobDe|
000096e0  66 20 34 32 2c 4c 6f 6e  67 4a 75 6d 70 0a 20 3b  |f 42,LongJump. ;|
000096f0  20 6c 6f 6e 67 6a 75 6d  70 28 73 74 61 63 6b 2c  | longjump(stack,|
00009700  20 6c 61 62 29 0a 0a 09  43 4d 50 53 09 72 70 2c  | lab)...CMPS.rp,|
00009710  20 61 31 0a 09 4d 4f 56  45 51 09 70 63 2c 20 61  | a1..MOVEQ.pc, a|
00009720  32 09 09 3b 20 66 69 6c  74 65 72 20 6f 75 74 20  |2..; filter out |
00009730  73 69 6c 6c 79 20 63 61  73 65 20 6f 66 20 6c 6f  |silly case of lo|
00009740  63 61 6c 20 6c 6f 6e 67  6a 75 6d 70 0a 09 4d 4f  |cal longjump..MO|
00009750  56 09 77 31 2c 20 72 70  0a 09 3b 20 6d 75 73 74  |V.w1, rp..; must|
00009760  20 63 68 61 69 6e 20 64  6f 77 6e 20 73 74 61 63  | chain down stac|
00009770  6b 20 74 6f 20 66 69 6e  64 20 72 6c 0a 09 3b 20  |k to find rl..; |
00009780  28 73 74 6f 72 65 64 20  69 6e 20 74 68 65 20 6c  |(stored in the l|
00009790  69 6e 6b 61 67 65 20 66  6f 72 20 74 68 65 20 66  |inkage for the f|
000097a0  72 61 6d 65 20 61 62 6f  76 65 29 0a 6c 6a 31 09  |rame above).lj1.|
000097b0  4c 44 52 09 77 32 2c 20  5b 77 31 2c 20 23 66 72  |LDR.w2, [w1, #fr|
000097c0  72 70 5d 0a 09 43 4d 50  53 09 77 32 2c 20 77 31  |rp]..CMPS.w2, w1|
000097d0  0a 09 42 45 51 09 4c 6f  6e 67 4a 75 6d 70 45 72  |..BEQ.LongJumpEr|
000097e0  72 6f 72 0a 09 43 4d 50  53 09 77 32 2c 20 61 31  |ror..CMPS.w2, a1|
000097f0  0a 09 4d 4f 56 4e 45 09  77 31 2c 20 77 32 0a 09  |..MOVNE.w1, w2..|
00009800  42 4e 45 09 6c 6a 31 0a  09 4c 44 52 09 72 6c 2c  |BNE.lj1..LDR.rl,|
00009810  20 5b 77 31 2c 20 23 66  72 72 6c 5d 20 3b 20 6e  | [w1, #frrl] ; n|
00009820  6f 20 6e 65 65 64 20 74  6f 20 6c 6f 61 64 20 72  |o need to load r|
00009830  62 0a 09 4d 4f 56 09 72  74 73 2c 20 77 31 0a 09  |b..MOV.rts, w1..|
00009840  4d 4f 56 09 72 70 2c 20  61 31 0a 09 4d 4f 56 09  |MOV.rp, a1..MOV.|
00009850  70 63 2c 20 61 32 0a 0a  4c 6f 6e 67 4a 75 6d 70  |pc, a2..LongJump|
00009860  45 72 72 6f 72 0a 09 4d  4f 56 09 61 33 2c 20 61  |Error..MOV.a3, a|
00009870  31 0a 09 41 44 52 09 61  31 2c 20 4c 6f 6e 67 4a  |1..ADR.a1, LongJ|
00009880  75 6d 70 45 72 72 4d 65  73 73 0a 09 42 09 43 61  |umpErrMess..B.Ca|
00009890  6c 6c 5f 46 61 75 6c 74  0a 0a 4c 6f 6e 67 4a 75  |ll_Fault..LongJu|
000098a0  6d 70 45 72 72 4d 65 73  73 0a 09 3d 09 35 31 2c  |mpErrMess..=.51,|
000098b0  22 44 65 73 74 69 6e 61  74 69 6f 6e 20 66 72 61  |"Destination fra|
000098c0  6d 65 20 25 6e 20 66 6f  72 20 4c 6f 6e 67 4a 75  |me %n for LongJu|
000098d0  6d 70 20 6e 6f 74 20 69  6e 20 74 68 65 20 73 74  |mp not in the st|
000098e0  61 63 6b 22 2c 31 30 0a  09 41 4c 49 47 4e 09 34  |ack",10..ALIGN.4|
000098f0  0a 0a 20 47 6c 6f 62 44  65 66 20 34 33 2c 41 70  |.. GlobDef 43,Ap|
00009900  74 6f 76 65 63 0a 20 3b  20 61 70 74 6f 76 65 63  |tovec. ; aptovec|
00009910  20 28 70 72 6f 63 2c 20  76 65 63 20 75 62 29 0a  | (proc, vec ub).|
00009920  20 3b 20 57 61 6e 74 73  20 69 74 73 20 6f 77 6e  | ; Wants its own|
00009930  20 66 72 61 6d 65 20 73  6f 20 74 68 61 74 20 52  | frame so that R|
00009940  54 53 20 67 65 74 73 20  72 65 73 65 74 20 6f 6e  |TS gets reset on|
00009950  20 72 65 74 75 72 6e 0a  20 3b 20 6e 6f 74 65 3a  | return. ; note:|
00009960  20 6e 65 65 64 73 20 72  65 70 6c 61 63 65 6d 65  | needs replaceme|
00009970  6e 74 20 66 6f 72 20 64  6f 77 6e 77 61 72 64 2d  |nt for downward-|
00009980  67 72 6f 77 69 6e 67 20  73 74 61 63 6b 73 0a 0a  |growing stacks..|
00009990  09 53 54 4d 45 41 09 72  74 73 21 2c 20 7b 72 31  |.STMEA.rts!, {r1|
000099a0  34 2c 20 72 62 2c 20 72  6c 2c 20 72 70 7d 0a 09  |4, rb, rl, rp}..|
000099b0  53 55 42 09 72 70 2c 20  72 74 73 2c 20 23 31 36  |SUB.rp, rts, #16|
000099c0  0a 09 4d 4f 56 09 72 62  2c 20 72 31 0a 09 4d 4f  |..MOV.rb, r1..MO|
000099d0  56 09 61 31 2c 20 72 74  73 2c 20 4c 53 52 20 23  |V.a1, rts, LSR #|
000099e0  32 20 09 20 3b 20 76 65  63 74 6f 72 20 28 42 43  |2 . ; vector (BC|
000099f0  50 4c 29 20 61 64 64 72  65 73 73 0a 09 41 44 44  |PL) address..ADD|
00009a00  09 72 74 73 2c 20 72 74  73 2c 20 61 32 2c 20 41  |.rts, rts, a2, A|
00009a10  53 4c 20 23 32 0a 09 41  44 44 09 72 74 73 2c 20  |SL #2..ADD.rts, |
00009a20  72 74 73 2c 20 23 34 09  09 3b 20 69 6e 63 72 65  |rts, #4..; incre|
00009a30  6d 65 6e 74 20 74 6f 73  20 62 79 20 76 65 63 74  |ment tos by vect|
00009a40  6f 72 20 73 69 7a 65 0a  09 42 4c 09 43 61 6c 6c  |or size..BL.Call|
00009a50  47 6c 6f 62 0a 09 4d 4f  56 09 72 74 73 2c 20 72  |Glob..MOV.rts, r|
00009a60  70 0a 09 4c 44 4d 46 44  09 72 70 2c 20 7b 70 63  |p..LDMFD.rp, {pc|
00009a70  2c 20 72 62 2c 20 72 6c  2c 20 72 70 7d 5e 0a 0a  |, rb, rl, rp}^..|
00009a80  20 47 6c 6f 62 44 65 66  20 31 35 2c 47 65 74 42  | GlobDef 15,GetB|
00009a90  79 74 65 0a 20 3b 20 67  65 74 62 79 74 65 28 76  |yte. ; getbyte(v|
00009aa0  65 63 2c 20 6f 66 66 73  65 74 29 0a 0a 09 4c 44  |ec, offset)...LD|
00009ab0  52 42 09 61 31 2c 20 5b  61 32 2c 20 61 31 2c 20  |RB.a1, [a2, a1, |
00009ac0  41 53 4c 20 23 32 5d 0a  09 4d 4f 56 53 09 70 63  |ASL #2]..MOVS.pc|
00009ad0  2c 20 72 31 34 0a 0a 20  47 6c 6f 62 44 65 66 20  |, r14.. GlobDef |
00009ae0  31 34 2c 50 75 74 42 79  74 65 0a 20 3b 20 70 75  |14,PutByte. ; pu|
00009af0  74 62 79 74 65 28 76 65  63 2c 20 6f 66 66 73 65  |tbyte(vec, offse|
00009b00  74 2c 20 76 61 6c 75 65  29 0a 0a 09 53 54 52 42  |t, value)...STRB|
00009b10  09 61 33 2c 20 5b 61 32  2c 20 61 31 2c 20 41 53  |.a3, [a2, a1, AS|
00009b20  4c 20 23 32 5d 0a 09 4d  4f 56 53 09 70 63 2c 20  |L #2]..MOVS.pc, |
00009b30  72 31 34 0a 0a 20 47 6c  6f 62 44 65 66 20 33 37  |r14.. GlobDef 37|
00009b40  2c 47 42 79 74 65 73 0a  20 3b 20 67 62 79 74 65  |,GBytes. ; gbyte|
00009b50  73 28 62 61 2c 20 20 73  69 7a 65 29 0a 0a 09 4d  |s(ba,  size)...M|
00009b60  4f 56 09 72 30 2c 20 61  31 0a 09 4d 4f 56 09 61  |OV.r0, a1..MOV.a|
00009b70  31 2c 20 23 30 0a 67 62  31 09 4c 44 52 42 09 61  |1, #0.gb1.LDRB.a|
00009b80  33 2c 20 5b 72 30 5d 2c  20 23 2b 31 0a 09 41 44  |3, [r0], #+1..AD|
00009b90  44 09 61 31 2c 20 61 33  2c 20 61 31 2c 20 41 53  |D.a1, a3, a1, AS|
00009ba0  4c 20 23 38 0a 09 53 55  42 53 09 61 32 2c 20 61  |L #8..SUBS.a2, a|
00009bb0  32 2c 20 23 31 0a 09 42  47 54 09 67 62 31 0a 09  |2, #1..BGT.gb1..|
00009bc0  4d 4f 56 53 09 70 63 2c  20 72 31 34 0a 0a 20 47  |MOVS.pc, r14.. G|
00009bd0  6c 6f 62 44 65 66 20 33  38 2c 50 42 79 74 65 73  |lobDef 38,PBytes|
00009be0  0a 20 3b 20 70 62 79 74  65 73 28 62 61 2c 20 20  |. ; pbytes(ba,  |
00009bf0  73 69 7a 65 2c 20 20 64  61 74 61 29 0a 0a 09 41  |size,  data)...A|
00009c00  44 44 09 61 31 2c 20 61  31 2c 20 61 32 0a 70 62  |DD.a1, a1, a2.pb|
00009c10  31 09 53 54 52 42 09 61  33 2c 20 5b 61 31 2c 20  |1.STRB.a3, [a1, |
00009c20  23 2d 31 5d 21 0a 09 4d  4f 56 09 61 33 2c 20 61  |#-1]!..MOV.a3, a|
00009c30  33 2c 20 4c 53 52 20 23  38 0a 09 53 55 42 53 09  |3, LSR #8..SUBS.|
00009c40  61 32 2c 20 61 32 2c 20  23 31 0a 09 42 47 54 09  |a2, a2, #1..BGT.|
00009c50  70 62 31 0a 09 4d 4f 56  53 09 70 63 2c 20 72 31  |pb1..MOVS.pc, r1|
00009c60  34 0a 0a 20 47 6c 6f 62  44 65 66 20 31 34 30 2c  |4.. GlobDef 140,|
00009c70  4d 6f 76 65 57 6f 72 64  73 0a 3b 20 6d 6f 76 65  |MoveWords.; move|
00009c80  77 6f 72 64 73 28 64 69  72 65 63 74 69 6f 6e 2c  |words(direction,|
00009c90  20 6c 65 6e 67 74 68 2c  20 66 72 6f 6d 2c 20 74  | length, from, t|
00009ca0  6f 29 0a 3b 20 20 64 69  72 65 63 74 69 6f 6e 20  |o).;  direction |
00009cb0  3d 20 52 31 2c 20 6c 65  6e 67 74 68 20 3d 20 52  |= R1, length = R|
00009cc0  32 2c 20 66 72 6f 6d 20  3d 20 52 33 2c 20 74 6f  |2, from = R3, to|
00009cd0  20 3d 20 52 34 0a 3b 20  66 72 6f 6d 20 61 6e 64  | = R4.; from and|
00009ce0  20 74 6f 20 61 72 65 20  42 43 50 4c 20 61 64 64  | to are BCPL add|
00009cf0  72 65 73 73 65 73 0a 09  4d 4f 56 09 61 34 2c 09  |resses..MOV.a4,.|
00009d00  61 34 2c 20 41 53 4c 20  23 32 0a 09 4d 4f 56 09  |a4, ASL #2..MOV.|
00009d10  61 33 2c 09 61 33 2c 20  41 53 4c 20 23 32 0a 6d  |a3,.a3, ASL #2.m|
00009d20  77 31 0a 09 4c 44 52 09  72 30 2c 09 5b 61 33 5d  |w1..LDR.r0,.[a3]|
00009d30  2c 20 72 31 2c 20 41 53  4c 20 23 32 0a 09 53 54  |, r1, ASL #2..ST|
00009d40  52 09 72 30 2c 09 5b 61  34 5d 2c 20 72 31 2c 20  |R.r0,.[a4], r1, |
00009d50  41 53 4c 20 23 32 0a 09  53 55 42 53 09 61 32 2c  |ASL #2..SUBS.a2,|
00009d60  09 61 32 2c 09 23 31 0a  09 42 47 54 09 6d 77 31  |.a2,.#1..BGT.mw1|
00009d70  0a 09 4d 4f 56 53 09 70  63 2c 09 72 31 34 0a 0a  |..MOVS.pc,.r14..|
00009d80  20 47 6c 6f 62 44 65 66  20 31 34 31 2c 46 69 6c  | GlobDef 141,Fil|
00009d90  6c 57 6f 72 64 73 0a 3b  20 77 6f 72 64 66 69 6c  |lWords.; wordfil|
00009da0  6c 28 62 61 73 65 2c 20  6c 65 6e 67 74 68 2c 20  |l(base, length, |
00009db0  76 61 6c 75 65 29 0a 3b  20 49 6e 69 74 69 61 6c  |value).; Initial|
00009dc0  69 73 65 20 21 62 61 73  65 20 74 6f 20 62 61 73  |ise !base to bas|
00009dd0  65 21 28 6c 65 6e 67 74  68 2d 31 29 20 74 6f 20  |e!(length-1) to |
00009de0  76 61 6c 75 65 2e 0a 3b  20 62 61 73 65 20 69 73  |value..; base is|
00009df0  20 61 20 42 43 50 4c 20  61 64 64 72 65 73 73 2e  | a BCPL address.|
00009e00  0a 0a 09 4d 4f 56 09 61  31 2c 09 61 31 2c 41 53  |...MOV.a1,.a1,AS|
00009e10  4c 20 23 32 0a 77 66 31  0a 09 53 54 52 09 61 33  |L #2.wf1..STR.a3|
00009e20  2c 09 5b 61 31 5d 2c 23  2b 34 0a 09 53 55 42 53  |,.[a1],#+4..SUBS|
00009e30  09 61 32 2c 09 61 32 2c  09 23 31 0a 09 42 47 54  |.a2,.a2,.#1..BGT|
00009e40  09 77 66 31 0a 09 4d 4f  56 53 09 70 63 2c 09 72  |.wf1..MOVS.pc,.r|
00009e50  31 34 0a 0a 3b 20 2a 2a  2a 20 63 6f 2d 72 6f 75  |14..; *** co-rou|
00009e60  74 69 6e 65 20 6d 61 6e  61 67 65 6d 65 6e 74 20  |tine management |
00009e70  73 74 75 66 66 0a 3b 0a  0a 20 47 6c 6f 62 44 65  |stuff.;.. GlobDe|
00009e80  66 20 35 32 2c 43 6f 57  61 69 74 0a 3b 20 43 6f  |f 52,CoWait.; Co|
00009e90  57 61 69 74 28 63 70 74  72 29 0a 0a 09 53 54 4d  |Wait(cptr)...STM|
00009ea0  45 41 09 72 74 73 21 2c  20 7b 72 62 2c 20 72 6c  |EA.rts!, {rb, rl|
00009eb0  2c 20 72 70 2c 20 72 31  34 7d 20 3b 20 70 72 6f  |, rp, r14} ; pro|
00009ec0  70 65 72 20 65 6e 74 72  79 20 73 65 71 75 65 6e  |per entry sequen|
00009ed0  63 65 0a 09 53 55 42 09  72 70 2c 20 72 74 73 2c  |ce..SUB.rp, rts,|
00009ee0  20 23 31 36 0a 09 53 54  4d 45 41 09 72 74 73 21  | #16..STMEA.rts!|
00009ef0  2c 20 7b 61 31 7d 0a 09  4c 44 52 09 61 32 2c 20  |, {a1}..LDR.a2, |
00009f00  5b 72 67 2c 20 23 47 5f  73 74 61 63 6b 42 61 73  |[rg, #G_stackBas|
00009f10  65 5d 0a 09 4d 4f 56 09  61 32 2c 20 61 32 2c 20  |e]..MOV.a2, a2, |
00009f20  41 53 4c 20 23 32 0a 09  4c 44 52 09 61 33 2c 20  |ASL #2..LDR.a3, |
00009f30  5b 61 32 2c 20 23 63 62  5f 63 61 6c 6c 65 72 5d  |[a2, #cb_caller]|
00009f40  0a 09 43 4d 4e 09 61 33  2c 20 23 31 0a 09 42 45  |..CMN.a3, #1..BE|
00009f50  51 09 43 6f 45 72 72 6f  72 20 09 09 3b 20 74 68  |Q.CoError ..; th|
00009f60  65 20 72 6f 6f 74 20 63  6f 72 6f 75 74 69 6e 65  |e root coroutine|
00009f70  20 63 61 6e 27 74 20 77  61 69 74 0a 0a 09 53 54  | can't wait...ST|
00009f80  52 09 61 33 2c 20 5b 72  67 2c 20 23 47 5f 73 74  |R.a3, [rg, #G_st|
00009f90  61 63 6b 42 61 73 65 5d  0a 09 4d 4f 56 09 61 34  |ackBase]..MOV.a4|
00009fa0  2c 20 23 30 0a 09 53 54  52 09 61 34 2c 20 5b 61  |, #0..STR.a4, [a|
00009fb0  32 2c 20 23 63 62 5f 63  61 6c 6c 65 72 5d 0a 09  |2, #cb_caller]..|
00009fc0  53 54 52 09 72 70 2c 20  5b 61 32 2c 20 23 63 62  |STR.rp, [a2, #cb|
00009fd0  5f 72 65 73 75 6d 65 5f  72 70 5d 0a 09 4d 4f 56  |_resume_rp]..MOV|
00009fe0  09 61 33 2c 20 61 33 2c  20 41 53 4c 20 23 32 0a  |.a3, a3, ASL #2.|
00009ff0  09 4c 44 52 09 72 74 73  2c 20 5b 61 33 2c 20 23  |.LDR.rts, [a3, #|
0000a000  63 62 5f 72 65 73 75 6d  65 5f 72 70 5d 0a 09 4c  |cb_resume_rp]..L|
0000a010  44 4d 45 44 09 72 74 73  2c 20 7b 72 6c 2c 20 72  |DMED.rts, {rl, r|
0000a020  70 2c 20 70 63 7d 5e 0a  0a 0a 20 47 6c 6f 62 44  |p, pc}^... GlobD|
0000a030  65 66 20 34 38 2c 43 72  65 61 74 65 43 6f 0a 3b  |ef 48,CreateCo.;|
0000a040  20 43 72 65 61 74 65 43  6f 28 66 75 6e 63 74 69  | CreateCo(functi|
0000a050  6f 6e 2c 20 73 74 61 63  6b 73 69 7a 65 29 0a 0a  |on, stacksize)..|
0000a060  09 53 54 4d 45 41 09 72  74 73 21 2c 20 7b 72 62  |.STMEA.rts!, {rb|
0000a070  2c 20 72 6c 2c 20 72 70  2c 20 72 31 34 7d 20 3b  |, rl, rp, r14} ;|
0000a080  20 70 72 6f 70 65 72 20  65 6e 74 72 79 20 73 65  | proper entry se|
0000a090  71 75 65 6e 63 65 0a 09  53 55 42 09 72 70 2c 20  |quence..SUB.rp, |
0000a0a0  72 74 73 2c 20 23 31 36  0a 09 53 54 4d 45 41 09  |rts, #16..STMEA.|
0000a0b0  72 74 73 21 2c 20 7b 61  31 2c 20 61 32 7d 0a 09  |rts!, {a1, a2}..|
0000a0c0  4d 4f 56 09 61 31 2c 20  61 32 09 09 09 3b 20 61  |MOV.a1, a2...; a|
0000a0d0  63 71 75 69 72 65 20 74  68 65 20 73 74 61 63 6b  |cquire the stack|
0000a0e0  0a 09 4c 44 52 09 72 62  2c 20 5b 72 67 2c 20 23  |..LDR.rb, [rg, #|
0000a0f0  47 5f 47 65 74 56 65 63  5d 0a 09 42 4c 09 43 61  |G_GetVec]..BL.Ca|
0000a100  6c 6c 47 6c 6f 62 0a 0a  09 43 4d 50 53 09 61 31  |llGlob...CMPS.a1|
0000a110  2c 20 23 30 0a 09 42 45  51 09 43 6f 45 72 72 6f  |, #0..BEQ.CoErro|
0000a120  72 0a 0a 09 4c 44 4d 45  41 09 72 74 73 21 2c 20  |r...LDMEA.rts!, |
0000a130  7b 72 34 2c 20 72 31 34  7d 20 09 3b 20 67 65 74  |{r4, r14} .; get|
0000a140  20 74 68 69 73 20 66 75  6e 63 74 69 6f 6e 27 73  | this function's|
0000a150  20 61 72 67 75 6d 65 6e  74 73 20 62 61 63 6b 0a  | arguments back.|
0000a160  09 41 44 44 09 72 31 34  2c 20 61 31 2c 20 72 31  |.ADD.r14, a1, r1|
0000a170  34 09 09 3b 20 28 42 43  50 4c 29 20 73 74 61 63  |4..; (BCPL) stac|
0000a180  6b 20 65 6e 64 0a 09 4d  4f 56 09 61 32 2c 20 61  |k end..MOV.a2, a|
0000a190  31 2c 20 41 53 4c 20 23  32 09 09 20 3b 20 28 68  |1, ASL #2.. ; (h|
0000a1a0  77 29 20 73 74 61 63 6b  20 62 61 73 65 0a 09 4c  |w) stack base..L|
0000a1b0  44 52 09 72 62 2c 20 5b  72 67 2c 20 23 47 5f 73  |DR.rb, [rg, #G_s|
0000a1c0  74 61 63 6b 42 61 73 65  5d 09 3b 20 63 61 6c 6c  |tackBase].; call|
0000a1d0  65 72 73 20 28 42 43 50  4c 29 20 73 74 61 63 6b  |ers (BCPL) stack|
0000a1e0  20 62 61 73 65 0a 09 4d  4f 56 09 61 33 2c 20 72  | base..MOV.a3, r|
0000a1f0  62 2c 20 41 53 4c 20 23  32 0a 09 4c 44 52 09 77  |b, ASL #2..LDR.w|
0000a200  32 2c 20 5b 61 33 2c 20  23 63 62 5f 6e 65 78 74  |2, [a3, #cb_next|
0000a210  5d 09 3b 20 63 68 61 69  6e 20 6e 65 77 20 63 6f  |].; chain new co|
0000a220  72 6f 75 74 69 6e 65 20  61 66 74 65 72 20 63 72  |routine after cr|
0000a230  65 61 74 6f 72 0a 09 53  54 52 09 61 31 2c 20 5b  |eator..STR.a1, [|
0000a240  61 33 2c 20 23 63 62 5f  6e 65 78 74 5d 0a 09 53  |a3, #cb_next]..S|
0000a250  54 4d 45 41 09 61 32 2c  20 7b 77 32 2c 20 72 62  |TMEA.a2, {w2, rb|
0000a260  2c 20 72 31 34 7d 09 3b  20 73 65 74 73 20 63 62  |, r14}.; sets cb|
0000a270  5f 6e 65 78 74 3a 20 63  62 5f 63 61 6c 6c 65 72  |_next: cb_caller|
0000a280  3a 20 63 62 5f 73 74 61  63 6b 65 6e 64 0a 09 53  |: cb_stackend..S|
0000a290  54 52 09 72 34 2c 20 5b  61 32 2c 20 23 63 62 5f  |TR.r4, [a2, #cb_|
0000a2a0  66 6e 5d 0a 09 53 54 52  09 72 70 2c 20 5b 61 33  |fn]..STR.rp, [a3|
0000a2b0  2c 20 23 63 62 5f 72 65  73 75 6d 65 5f 72 70 5d  |, #cb_resume_rp]|
0000a2c0  0a 09 53 54 52 09 61 31  2c 20 5b 72 67 2c 20 23  |..STR.a1, [rg, #|
0000a2d0  47 5f 73 74 61 63 6b 42  61 73 65 5d 0a 09 41 44  |G_stackBase]..AD|
0000a2e0  44 09 72 70 2c 20 61 32  2c 20 23 63 62 5f 72 65  |D.rp, a2, #cb_re|
0000a2f0  61 6c 5f 73 74 61 63 6b  0a 43 72 65 61 74 65 43  |al_stack.CreateC|
0000a300  6f 32 0a 09 4d 4f 56 09  72 74 73 2c 20 72 70 0a  |o2..MOV.rts, rp.|
0000a310  09 4c 44 52 09 72 62 2c  20 5b 72 67 2c 20 23 47  |.LDR.rb, [rg, #G|
0000a320  5f 43 6f 57 61 69 74 5d  0a 09 42 4c 09 43 61 6c  |_CoWait]..BL.Cal|
0000a330  6c 47 6c 6f 62 0a 09 4c  44 52 09 72 62 2c 20 5b  |lGlob..LDR.rb, [|
0000a340  72 70 2c 20 23 63 62 5f  66 6e 2d 63 62 5f 72 65  |rp, #cb_fn-cb_re|
0000a350  61 6c 5f 73 74 61 63 6b  5d 0a 09 42 4c 09 43 61  |al_stack]..BL.Ca|
0000a360  6c 6c 47 6c 6f 62 0a 09  42 09 43 72 65 61 74 65  |llGlob..B.Create|
0000a370  43 6f 32 0a 0a 0a 20 47  6c 6f 62 44 65 66 20 34  |Co2... GlobDef 4|
0000a380  39 2c 44 65 6c 65 74 65  43 6f 0a 3b 20 73 75 63  |9,DeleteCo.; suc|
0000a390  63 65 73 73 63 6f 64 65  20 3a 3d 20 44 65 6c 65  |cesscode := Dele|
0000a3a0  74 65 43 6f 28 63 70 74  72 29 0a 0a 09 53 54 4d  |teCo(cptr)...STM|
0000a3b0  45 41 09 72 74 73 21 2c  20 7b 72 62 2c 20 72 6c  |EA.rts!, {rb, rl|
0000a3c0  2c 20 72 70 2c 20 72 31  34 7d 20 3b 20 70 72 6f  |, rp, r14} ; pro|
0000a3d0  70 65 72 20 65 6e 74 72  79 20 73 65 71 75 65 6e  |per entry sequen|
0000a3e0  63 65 0a 09 53 55 42 09  72 70 2c 20 72 74 73 2c  |ce..SUB.rp, rts,|
0000a3f0  20 23 31 36 0a 09 53 54  4d 45 41 09 72 74 73 21  | #16..STMEA.rts!|
0000a400  2c 20 7b 61 31 7d 0a 09  4d 4f 56 09 61 32 2c 20  |, {a1}..MOV.a2, |
0000a410  61 31 2c 20 41 53 4c 20  23 32 0a 09 4c 44 52 09  |a1, ASL #2..LDR.|
0000a420  61 33 2c 20 5b 61 32 2c  20 23 63 62 5f 63 61 6c  |a3, [a2, #cb_cal|
0000a430  6c 65 72 5d 0a 09 43 4d  50 53 09 61 33 2c 20 23  |ler]..CMPS.a3, #|
0000a440  30 0a 09 42 4e 45 09 43  6f 45 72 72 6f 72 20 09  |0..BNE.CoError .|
0000a450  09 3b 20 63 61 6e 27 74  20 2d 20 69 74 27 73 20  |.; can't - it's |
0000a460  73 74 69 6c 6c 20 61 63  74 69 76 65 0a 0a 09 4c  |still active...L|
0000a470  44 52 09 61 33 2c 20 5b  72 67 2c 20 23 47 5f 73  |DR.a3, [rg, #G_s|
0000a480  74 61 63 6b 42 61 73 65  5d 09 3b 20 64 6f 77 6e  |tackBase].; down|
0000a490  20 74 68 65 20 63 61 6c  6c 65 72 20 63 68 61 69  | the caller chai|
0000a4a0  6e 20 74 6f 20 74 68 65  20 72 6f 6f 74 0a 44 65  |n to the root.De|
0000a4b0  6c 65 74 65 43 6f 31 0a  09 4d 4f 56 09 61 34 2c  |leteCo1..MOV.a4,|
0000a4c0  20 61 33 2c 20 41 53 4c  20 23 32 0a 09 4c 44 52  | a3, ASL #2..LDR|
0000a4d0  09 61 34 2c 20 5b 61 34  2c 20 23 63 62 5f 63 61  |.a4, [a4, #cb_ca|
0000a4e0  6c 6c 65 72 5d 0a 09 43  4d 4e 09 61 34 2c 20 23  |ller]..CMN.a4, #|
0000a4f0  31 0a 09 42 4e 45 09 44  65 6c 65 74 65 43 6f 31  |1..BNE.DeleteCo1|
0000a500  0a 0a 3b 20 61 33 20 69  73 20 6e 6f 77 20 74 68  |..; a3 is now th|
0000a510  65 20 72 6f 6f 74 20 63  6f 72 6f 75 74 69 6e 65  |e root coroutine|
0000a520  0a 3b 20 53 65 61 72 63  68 20 73 74 61 72 74 69  |.; Search starti|
0000a530  6e 67 20 66 72 6f 6d 20  69 74 20 66 6f 72 20 74  |ng from it for t|
0000a540  68 65 20 74 61 72 67 65  74 20 63 6f 72 6f 75 74  |he target corout|
0000a550  69 6e 65 0a 09 4d 4f 56  09 72 30 2c 20 23 30 0a  |ine..MOV.r0, #0.|
0000a560  44 65 6c 65 74 65 43 6f  32 0a 09 4d 4f 56 09 61  |DeleteCo2..MOV.a|
0000a570  34 2c 20 61 33 0a 09 4c  44 52 09 61 33 2c 20 5b  |4, a3..LDR.a3, [|
0000a580  72 30 2c 20 61 33 2c 20  41 53 4c 20 23 32 5d 0a  |r0, a3, ASL #2].|
0000a590  09 43 4d 50 53 09 61 33  2c 20 23 30 0a 09 42 45  |.CMPS.a3, #0..BE|
0000a5a0  51 09 43 6f 45 72 72 6f  72 20 09 09 3b 20 6e 6f  |Q.CoError ..; no|
0000a5b0  74 20 66 6f 75 6e 64 20  2d 20 65 6e 64 20 6f 66  |t found - end of|
0000a5c0  20 63 68 61 69 6e 0a 09  43 4d 50 53 09 61 31 2c  | chain..CMPS.a1,|
0000a5d0  20 61 33 0a 09 42 4e 45  09 44 65 6c 65 74 65 43  | a3..BNE.DeleteC|
0000a5e0  6f 32 0a 0a 09 4c 44 52  09 61 32 2c 20 5b 72 30  |o2...LDR.a2, [r0|
0000a5f0  2c 20 61 31 2c 20 41 53  4c 20 23 32 5d 0a 09 53  |, a1, ASL #2]..S|
0000a600  54 52 09 61 32 2c 20 5b  72 30 2c 20 61 34 2c 20  |TR.a2, [r0, a4, |
0000a610  41 53 4c 20 23 32 5d 09  20 3b 20 75 6e 6c 69 6e  |ASL #2]. ; unlin|
0000a620  6b 20 74 68 65 20 74 61  72 67 65 74 20 63 6f 72  |k the target cor|
0000a630  6f 75 74 69 6e 65 0a 09  4c 44 52 09 72 62 2c 20  |outine..LDR.rb, |
0000a640  5b 72 67 2c 20 23 47 5f  46 72 65 65 56 65 63 5d  |[rg, #G_FreeVec]|
0000a650  09 3b 20 72 65 6c 69 6e  71 75 69 73 68 20 69 74  |.; relinquish it|
0000a660  73 20 73 74 61 63 6b 0a  09 42 4c 09 43 61 6c 6c  |s stack..BL.Call|
0000a670  47 6c 6f 62 0a 09 4d 4f  56 09 72 74 73 2c 20 72  |Glob..MOV.rts, r|
0000a680  70 0a 09 4c 44 4d 45 44  09 72 74 73 2c 20 7b 72  |p..LDMED.rts, {r|
0000a690  6c 2c 20 72 70 2c 20 70  63 7d 5e 0a 0a 0a 20 47  |l, rp, pc}^... G|
0000a6a0  6c 6f 62 44 65 66 20 35  30 2c 43 61 6c 6c 43 6f  |lobDef 50,CallCo|
0000a6b0  0a 3b 20 43 61 6c 6c 43  6f 28 63 70 74 72 2c 20  |.; CallCo(cptr, |
0000a6c0  61 72 67 29 0a 0a 09 53  54 4d 45 41 09 72 74 73  |arg)...STMEA.rts|
0000a6d0  21 2c 20 7b 72 62 2c 20  72 6c 2c 20 72 70 2c 20  |!, {rb, rl, rp, |
0000a6e0  72 31 34 7d 20 3b 20 70  72 6f 70 65 72 20 65 6e  |r14} ; proper en|
0000a6f0  74 72 79 20 73 65 71 75  65 6e 63 65 0a 09 53 55  |try sequence..SU|
0000a700  42 09 72 70 2c 20 72 74  73 2c 20 23 31 36 0a 09  |B.rp, rts, #16..|
0000a710  53 54 4d 45 41 09 72 74  73 21 2c 20 7b 61 31 2c  |STMEA.rts!, {a1,|
0000a720  20 61 32 7d 0a 09 4d 4f  56 09 61 33 2c 20 61 31  | a2}..MOV.a3, a1|
0000a730  2c 20 41 53 4c 20 23 32  0a 09 4c 44 52 09 61 34  |, ASL #2..LDR.a4|
0000a740  2c 20 5b 61 33 2c 20 23  63 62 5f 63 61 6c 6c 65  |, [a3, #cb_calle|
0000a750  72 5d 0a 09 43 4d 50 53  09 61 34 2c 20 23 30 0a  |r]..CMPS.a4, #0.|
0000a760  09 42 4e 45 09 43 6f 45  72 72 6f 72 20 09 09 3b  |.BNE.CoError ..;|
0000a770  20 61 6c 72 65 61 64 79  20 61 63 74 69 76 65 0a  | already active.|
0000a780  0a 09 4c 44 52 09 72 62  2c 20 5b 72 67 2c 20 23  |..LDR.rb, [rg, #|
0000a790  47 5f 73 74 61 63 6b 42  61 73 65 5d 0a 09 53 54  |G_stackBase]..ST|
0000a7a0  52 09 72 62 2c 20 5b 61  33 2c 20 23 63 62 5f 63  |R.rb, [a3, #cb_c|
0000a7b0  61 6c 6c 65 72 5d 0a 09  4d 4f 56 09 72 62 2c 20  |aller]..MOV.rb, |
0000a7c0  72 62 2c 20 41 53 4c 20  23 32 0a 0a 43 6f 45 6e  |rb, ASL #2..CoEn|
0000a7d0  74 65 72 0a 20 3b 20 65  6e 74 65 72 20 63 6f 72  |ter. ; enter cor|
0000a7e0  6f 75 74 69 6e 65 20 61  31 2e 09 61 33 20 69 73  |outine a1..a3 is|
0000a7f0  20 68 77 20 76 65 72 73  69 6f 6e 20 6f 66 20 61  | hw version of a|
0000a800  31 2e 0a 20 3b 20 72 62  20 69 73 20 68 77 20 61  |1.. ; rb is hw a|
0000a810  64 64 72 65 73 73 20 6f  66 20 63 75 72 72 65 6e  |ddress of curren|
0000a820  74 20 63 6f 72 6f 75 74  69 6e 65 0a 09 53 54 52  |t coroutine..STR|
0000a830  09 61 31 2c 20 5b 72 67  2c 20 23 47 5f 73 74 61  |.a1, [rg, #G_sta|
0000a840  63 6b 42 61 73 65 5d 0a  09 53 54 52 09 72 70 2c  |ckBase]..STR.rp,|
0000a850  20 5b 72 62 2c 20 23 63  62 5f 72 65 73 75 6d 65  | [rb, #cb_resume|
0000a860  5f 72 70 5d 0a 09 4c 44  52 09 72 74 73 2c 20 5b  |_rp]..LDR.rts, [|
0000a870  61 33 2c 20 23 63 62 5f  72 65 73 75 6d 65 5f 72  |a3, #cb_resume_r|
0000a880  70 5d 0a 09 4d 4f 56 09  61 31 2c 20 61 32 0a 09  |p]..MOV.a1, a2..|
0000a890  4c 44 4d 45 44 09 72 74  73 2c 20 7b 72 6c 2c 20  |LDMED.rts, {rl, |
0000a8a0  72 70 2c 20 70 63 7d 5e  0a 0a 0a 20 47 6c 6f 62  |rp, pc}^... Glob|
0000a8b0  44 65 66 20 35 31 2c 52  65 73 75 6d 65 43 6f 0a  |Def 51,ResumeCo.|
0000a8c0  3b 20 52 65 73 75 6d 65  43 6f 28 63 70 74 72 2c  |; ResumeCo(cptr,|
0000a8d0  20 61 72 67 29 0a 0a 09  53 54 4d 45 41 09 72 74  | arg)...STMEA.rt|
0000a8e0  73 21 2c 20 7b 72 62 2c  20 72 6c 2c 20 72 70 2c  |s!, {rb, rl, rp,|
0000a8f0  20 72 31 34 7d 20 3b 20  70 72 6f 70 65 72 20 65  | r14} ; proper e|
0000a900  6e 74 72 79 20 73 65 71  75 65 6e 63 65 0a 09 53  |ntry sequence..S|
0000a910  55 42 09 72 70 2c 20 72  74 73 2c 20 23 31 36 0a  |UB.rp, rts, #16.|
0000a920  09 53 54 4d 45 41 09 72  74 73 21 2c 20 7b 61 31  |.STMEA.rts!, {a1|
0000a930  2c 20 61 32 7d 0a 09 4c  44 52 09 72 62 2c 20 5b  |, a2}..LDR.rb, [|
0000a940  72 67 2c 20 23 47 5f 73  74 61 63 6b 42 61 73 65  |rg, #G_stackBase|
0000a950  5d 0a 09 43 4d 50 53 09  72 62 2c 20 61 31 0a 09  |]..CMPS.rb, a1..|
0000a960  42 45 51 09 52 65 73 75  6d 65 43 6f 31 09 09 3b  |BEQ.ResumeCo1..;|
0000a970  20 69 74 73 20 74 68 65  20 63 75 72 72 65 6e 74  | its the current|
0000a980  20 63 6f 72 6f 75 74 69  6e 65 0a 09 4d 4f 56 09  | coroutine..MOV.|
0000a990  61 33 2c 20 61 31 2c 20  41 53 4c 20 23 32 0a 09  |a3, a1, ASL #2..|
0000a9a0  4c 44 52 09 61 34 2c 20  5b 61 33 2c 20 23 63 62  |LDR.a4, [a3, #cb|
0000a9b0  5f 63 61 6c 6c 65 72 5d  0a 09 42 4e 45 09 43 6f  |_caller]..BNE.Co|
0000a9c0  45 72 72 6f 72 20 09 09  3b 20 74 61 72 67 65 74  |Error ..; target|
0000a9d0  20 69 73 20 61 6c 72 65  61 64 79 20 61 63 74 69  | is already acti|
0000a9e0  76 65 0a 09 4d 4f 56 09  72 62 2c 20 72 62 2c 20  |ve..MOV.rb, rb, |
0000a9f0  41 53 4c 20 23 32 0a 09  4c 44 52 09 61 34 2c 20  |ASL #2..LDR.a4, |
0000aa00  5b 72 62 2c 20 23 63 62  5f 63 61 6c 6c 65 72 5d  |[rb, #cb_caller]|
0000aa10  0a 09 43 4d 4e 09 61 34  2c 20 23 31 0a 09 42 45  |..CMN.a4, #1..BE|
0000aa20  51 09 43 6f 45 72 72 6f  72 20 09 09 3b 20 63 61  |Q.CoError ..; ca|
0000aa30  6c 6c 65 72 20 69 73 20  72 6f 6f 74 0a 09 53 54  |ller is root..ST|
0000aa40  52 09 61 34 2c 20 5b 61  33 2c 20 23 63 62 5f 63  |R.a4, [a3, #cb_c|
0000aa50  61 6c 6c 65 72 5d 09 3b  20 61 63 74 69 76 61 74  |aller].; activat|
0000aa60  65 20 74 61 72 67 65 74  0a 09 4d 4f 56 09 61 34  |e target..MOV.a4|
0000aa70  2c 20 23 30 0a 09 53 54  52 09 61 34 2c 20 5b 72  |, #0..STR.a4, [r|
0000aa80  62 2c 20 23 63 62 5f 63  61 6c 6c 65 72 5d 09 3b  |b, #cb_caller].;|
0000aa90  20 61 6e 64 20 64 65 61  63 74 69 76 61 74 65 20  | and deactivate |
0000aaa0  63 75 72 72 65 6e 74 0a  09 42 09 43 6f 45 6e 74  |current..B.CoEnt|
0000aab0  65 72 0a 0a 52 65 73 75  6d 65 43 6f 31 0a 09 4d  |er..ResumeCo1..M|
0000aac0  4f 56 09 61 31 2c 20 61  32 0a 09 4d 4f 56 09 72  |OV.a1, a2..MOV.r|
0000aad0  74 73 2c 20 72 70 0a 09  4c 44 4d 45 44 09 72 74  |ts, rp..LDMED.rt|
0000aae0  73 2c 20 7b 72 6c 2c 20  72 70 2c 20 70 63 7d 5e  |s, {rl, rp, pc}^|
0000aaf0  0a 0a 0a 43 6f 45 72 72  6f 72 0a 09 41 44 52 09  |...CoError..ADR.|
0000ab00  61 31 2c 20 43 6f 45 72  72 4d 65 73 73 0a 43 61  |a1, CoErrMess.Ca|
0000ab10  6c 6c 5f 46 61 75 6c 74  0a 09 4d 4f 56 09 61 31  |ll_Fault..MOV.a1|
0000ab20  2c 20 61 31 2c 20 4c 53  52 20 23 32 0a 09 4c 44  |, a1, LSR #2..LD|
0000ab30  52 09 72 62 2c 20 5b 72  67 2c 20 23 47 5f 46 61  |R.rb, [rg, #G_Fa|
0000ab40  75 6c 74 5d 0a 09 42 4c  09 43 61 6c 6c 47 6c 6f  |ult]..BL.CallGlo|
0000ab50  62 0a 09 42 09 57 69 6e  64 55 70 0a 0a 43 6f 45  |b..B.WindUp..CoE|
0000ab60  72 72 4d 65 73 73 0a 09  3d 09 31 36 2c 22 43 6f  |rrMess..=.16,"Co|
0000ab70  72 6f 75 74 69 6e 65 20  65 72 72 6f 72 22 2c 31  |routine error",1|
0000ab80  30 0a 09 41 4c 49 47 4e  09 34 0a 0a 09 4c 54 4f  |0..ALIGN.4...LTO|
0000ab90  52 47 0a 0a 20 5b 20 61  6f 66 0a 09 45 6e 64 4d  |RG.. [ aof..EndM|
0000aba0  6f 64 75 6c 65 0a 09 41  52 45 41 09 7c 42 43 50  |odule..AREA.|BCP|
0000abb0  4c 24 24 44 61 74 61 7c  0a 20 5d 0a 0a 6c 6f 63  |L$$Data|. ]..loc|
0000abc0  61 6c 44 61 74 61 0a 09  3d 20 22 56 45 52 4e 22  |alData..= "VERN"|
0000abd0  0a 09 3d 20 4c 69 62 72  61 72 79 4d 69 6e 6f 72  |..= LibraryMinor|
0000abe0  56 65 72 73 69 6f 6e 0a  09 3d 20 4c 69 62 72 61  |Version..= Libra|
0000abf0  72 79 4d 61 6a 6f 72 56  65 72 73 69 6f 6e 0a 09  |ryMajorVersion..|
0000ac00  41 4c 49 47 4e 20 34 0a  0a 09 4d 41 43 52 4f 0a  |ALIGN 4...MACRO.|
0000ac10  24 4c 61 62 65 6c 09 56  61 72 69 61 62 6c 65 20  |$Label.Variable |
0000ac20  24 53 69 7a 65 0a 09 4c  43 4c 41 09 54 65 6d 70  |$Size..LCLA.Temp|
0000ac30  61 0a 20 5b 20 22 24 53  69 7a 65 22 3d 22 22 0a  |a. [ "$Size"="".|
0000ac40  54 65 6d 70 61 09 53 45  54 41 09 31 0a 20 7c 0a  |Tempa.SETA.1. |.|
0000ac50  54 65 6d 70 61 09 53 45  54 41 09 24 53 69 7a 65  |Tempa.SETA.$Size|
0000ac60  0a 20 5d 0a 4f 5f 24 4c  61 62 65 6c 20 2a 09 2e  |. ].O_$Label *..|
0000ac70  2d 6c 6f 63 61 6c 44 61  74 61 0a 24 4c 61 62 65  |-localData.$Labe|
0000ac80  6c 09 25 09 26 24 54 65  6d 70 61 2a 34 0a 09 4d  |l.%.&$Tempa*4..M|
0000ac90  45 4e 44 0a 0a 72 65 67  44 75 6d 70 20 09 09 56  |END..regDump ..V|
0000aca0  61 72 69 61 62 6c 65 09  31 36 0a 0a 65 72 72 6f  |ariable.16..erro|
0000acb0  72 42 75 66 66 65 72 09  09 56 61 72 69 61 62 6c  |rBuffer..Variabl|
0000acc0  65 0a 65 72 72 6f 72 4e  75 6d 62 65 72 09 09 56  |e.errorNumber..V|
0000acd0  61 72 69 61 62 6c 65 0a  65 72 72 6f 72 53 74 72  |ariable.errorStr|
0000ace0  69 6e 67 09 09 56 61 72  69 61 62 6c 65 09 32 30  |ing..Variable.20|
0000acf0  0a 0a 6f 6c 64 41 62 6f  72 74 48 61 6e 64 6c 65  |..oldAbortHandle|
0000ad00  72 73 09 56 61 72 69 61  62 6c 65 09 34 0a 0a 6f  |rs.Variable.4..o|
0000ad10  6c 64 43 61 6c 6c 42 61  63 6b 52 65 67 69 73 74  |ldCallBackRegist|
0000ad20  65 72 73 09 56 61 72 69  61 62 6c 65 0a 6f 6c 64  |ers.Variable.old|
0000ad30  43 61 6c 6c 42 61 63 6b  48 61 6e 64 6c 65 72 09  |CallBackHandler.|
0000ad40  56 61 72 69 61 62 6c 65  0a 0a 6f 6c 64 45 72 72  |Variable..oldErr|
0000ad50  6f 72 48 61 6e 64 6c 65  72 20 09 56 61 72 69 61  |orHandler .Varia|
0000ad60  62 6c 65 0a 6f 6c 64 45  72 72 6f 72 42 75 66 66  |ble.oldErrorBuff|
0000ad70  65 72 09 09 56 61 72 69  61 62 6c 65 0a 6f 6c 64  |er..Variable.old|
0000ad80  45 73 63 61 70 65 48 61  6e 64 6c 65 72 09 56 61  |EscapeHandler.Va|
0000ad90  72 69 61 62 6c 65 0a 6f  6c 64 45 76 65 6e 74 48  |riable.oldEventH|
0000ada0  61 6e 64 6c 65 72 20 09  56 61 72 69 61 62 6c 65  |andler .Variable|
0000adb0  0a 0a 6d 79 41 62 6f 72  74 48 61 6e 64 6c 65 72  |..myAbortHandler|
0000adc0  73 20 09 56 61 72 69 61  62 6c 65 09 34 0a 62 65  |s .Variable.4.be|
0000add0  69 6e 67 44 65 62 75 67  67 65 64 09 09 56 61 72  |ingDebugged..Var|
0000ade0  69 61 62 6c 65 0a 0a 65  76 65 6e 74 48 61 6e 64  |iable..eventHand|
0000adf0  6c 65 72 73 09 09 56 61  72 69 61 62 6c 65 09 31  |lers..Variable.1|
0000ae00  31 2a 33 0a 09 09 09 26  09 20 2d 32 0a 65 6e 64  |1*3....&. -2.end|
0000ae10  45 76 65 6e 74 48 61 6e  64 6c 65 72 73 09 56 61  |EventHandlers.Va|
0000ae20  72 69 61 62 6c 65 09 30  0a 0a 66 72 65 65 48 65  |riable.0..freeHe|
0000ae30  61 70 43 68 61 69 6e 09  09 56 61 72 69 61 62 6c  |apChain..Variabl|
0000ae40  65 0a 0a 63 6c 69 45 6e  76 53 61 76 65 09 09 56  |e..cliEnvSave..V|
0000ae50  61 72 69 61 62 6c 65 09  34 0a 63 6c 69 52 31 54  |ariable.4.cliR1T|
0000ae60  6f 52 31 33 53 61 76 65  09 09 56 61 72 69 61 62  |oR13Save..Variab|
0000ae70  6c 65 09 31 33 0a 63 6c  69 53 74 61 74 75 73 09  |le.13.cliStatus.|
0000ae80  09 56 61 72 69 61 62 6c  65 0a 0a 20 5b 20 3a 4c  |.Variable.. [ :L|
0000ae90  4e 4f 54 3a 61 6f 66 0a  20 20 20 20 20 20 20 45  |NOT:aof.       E|
0000aea0  6e 64 4d 6f 64 75 6c 65  0a 20 5d 0a 20 45 4e 44  |ndModule. ]. END|
0000aeb0  0a                                                |.|
0000aeb1