Home » Archimedes archive » Archimedes World » AW-1996-07.adf » !AcornAns_AcornAns » Sound/s/generatorc

Sound/s/generatorc

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 » Archimedes World » AW-1996-07.adf » !AcornAns_AcornAns
Filename: Sound/s/generatorc
Read OK:
File size: 4A56 bytes
Load address: 0000
Exec address: 0000
File contents
; quickdiv_init
; a leaf APCS function
;
; C prototype:
; int quickdiv_init(int divisor)
;
; assembles the C function quickdiv, below, to carry out rapid division by the supplied divisor -
; after calling this fn, carry out a division via quotient=quickdiv(numerator);
;
; eg use:	for (i=0;i<10000;i++) printf("%i", i/n);
; replace with:	quickdiv_init(n); for (i=0;i<10000;i++) printf("%i", quickdiv(i));
;
; nb init executes in about 20 x time of a decent fourier div routine, while quickdiv typically executes
; in under 0.2 x time fdiv routine, thus in above loop calc we make speed saving after loop exceeds ~25
; and for full 10000 limit, get speed increase in div calc of about 4.95
;
; nb2 when in direct comparison with Acorn's division code, note it is optimised for low numerator, and
; will then equal or outperform this code, however once numerator gets bigger than ~2^9 and have loop>~25
; we make savings; these become 300%-600% for numerator ~16 bits or more and large loops.
;
; return codes as for gen below, plus: -7 indicating program error - serious corruption due to code
;								     overflowing quickdiv buffer
;

        EXPORT  quickdiv_init

qinsta  DCB     "quickdiv_init", 0
        ALIGN
qinend  DCD     &ff000000 + qinend - qinsta

quickdiv_init

	STMFD	sp!, {v1-v6, sl, fp, lr}
	ADR	r1, quickdiv
	MOV	r2, #0
	MOV	r3, #12
	MOV	r4, #1
	MOV	r5, #2
	MOV	r6, #3
	BL	gen
	CMP	r0, #0
	LDMLTFD	sp!, {v1-v6, sl, fp, pc}^
	ADR	r1, quickdiv
	ADD	r1, r1, r0
	ADR	r2, quickdivend-8
	CMP	r1, r2
	LDRHI	r0, quickdiv_init_ops+4
	STRHI	r0, quickdiv
	MOVHI	r0, #-7
	LDMHIFD	sp!, {v1-v6, sl, fp, pc}^
	ADR	r2, quickdiv_init_ops
	LDMIA	r2, {r3, r4}
	STMIA	r1!, {r3, r4}
	ADD	r0, r0, #8
	LDMFD	sp!, {v1-v6, sl, fp, pc}^

quickdiv_init_ops
	MOV	r0, r12
	MOVS	pc, lr



; quickdiv
; a leaf APCS function
;
; C prototype:
; int quickdiv(int numerator)
;
; returns numerator/divisor, where divisor was the argument formerly passed to quickdiv_init
; (whose purpose was to assemble this function)
;

        EXPORT  quickdiv

qdnsta  DCB     "quickdiv", 0
        ALIGN
qdnend  DCD     &ff000000 + qdnend - qdnsta

quickdiv

	MOVS	pc, lr
	%	380
quickdivend



;
; Name:	Generator.
;
; Author:
;	Michael Rozdoba, from an algorithm originally based on the work of Samuel K.R. Smith.
;
; Function:
; 	Compile code to carry out rapid assembler divison by an arbitrary constant.
;
; Arguments:
; r0	divisor constant
; r1	ptr to buffer for code (passing 0 indicates no code to be compiled - allows routine to be called to
;	calculate size of buffer required)
; r2	number of numerator register for routine to be compiled
; r3	number of output quotient register
; r4	number of output remainder register
; r5	scratch - work register - not needed if divisor is a valid immediate constant (nb if work supplied in
;	any case, but not needed, it will be ignored - if caller knows it will not be needed, -1 may be
;	passed)
; r6	scratch - sign preservation register (of numerator) - if numerator is known to always be positive
;	may pass -1 to indicate this, which will save use of signpres register & will reduce compiled code
;	size by 6 instructions typically (cf typical code size 20 to 27 instructions, when sign preservation
;	is active, thence reduced to 14 to 21 instructions)
;
;	NB All supplied register numbers (other than work & signpres when not needed & passed as -1) MUST be
;	   distinct.
;
; Returns:
; r0	size of compiled code in bytes
;	a value of size<0 indicates an error occurred during compilation; code as follows:
; -1	generator called with 0 divisor
; -2	work reg needed but not supplied
; -3	invalid register number
; -4	register number clash (the registers must be distinct)
; -5	program error - internal recursion stack exhausted
; -6	program error - fastdivaid logic 3
;
; Additional notes:
;	Assumes a suitable external r13 stack exists.
;

const	RN	r0
cptr	RN	r1
num	RN	r2
outq	RN	r3
outr	RN	r4
work	RN	r5
signpres	RN	r6
t1	RN	r12
fn	RN	r11				;args/results to/from subrouts
t2	RN	r10
t3	RN	r14
t4	RN	r9

ps	RN	r8
pm	RN	r9

stk	RN	r7
stkl	RN	r8

m_v	RN	r7
m_i	RN	r8
m_m	RN	r9
m_r	RN	r10
m_mi	RN	r11
m_ml	RN	r12
m_li	RN	r14

gen	CMP	const, #0
	MVNEQ	r0, #0				;ERROR: 0 divisor
	MOVEQS	pc, lr

	STMFD	sp!, {lr}

	MOV	t1, #1
	RSBMI	const, const, #0
	MOVMI	t1, #-1
	STR	t1, nsignpres

	STR	cptr, initial_cptr

	MOV	fn, const
	BL	powerof2
	STR	fn, power_of_2

	MOV	fn, const
	BL	imop2
	CMP	fn, #-1
	LDRNE	t1, op1
	ORRNE	t1, t1, fn			;insert operand 2
	ORRNE	t1, t1, outr, LSL #12		;       destination reg
	ORRNE	t1, t1, outr, LSL #16		;       operand 1 register
	STRNE	t1, op2				;note, opcode & condition will be added later (as need many)
	MOVEQ	t1, work
	MOVNE	t1, #-1				;t1 = const valid ? -1 : work reg
	CMPEQ	work, #-1
	MOVEQ	r0, #-2
	LDMEQFD	sp!, {pc}^			;ERROR: work reg needed but not supplied
	MOV	work, t1			;either leave work alone, if needed, else reset to -1

	CMP	outq, #0
	CMPGE	outr, #0
	CMPGE	num, #0
	CMPGE	work, #-1
	CMPGE	signpres, #-1
	MOVLT	r0, #-3
	LDMLTFD	sp!, {pc}^			;ERROR: invalid register number
	CMP	outq, #14
	CMPLE	outr, #14
	CMPLE	num, #14
	CMPLE	work, #14
	CMPLE	signpres, #14
	MOVGT	r0, #-3
	LDMGTFD	sp!, {pc}^			;ERROR: invalid register number
	CMP	outq, outr
	CMPNE	outq, num
	CMPNE	outr, num
	MOVEQ	r0, #-4
	LDMEQFD	sp!, {pc}^			;ERROR: register clash
	CMP	outq, signpres
	CMPNE	outr, signpres
	CMPNE	num, signpres
	BNE	l1
	CMP	signpres, #-1
	MOVNE	r0, #-4
	LDMNEFD	sp!, {pc}^			;ERROR: register clash
l1	CMP	outq, work
	CMPNE	outr, work
	CMPNE	num, work
	CMPNE	signpres, work
	BNE	l2
	CMP	work, #-1
	MOVNE	r0, #-4
	LDMNEFD	sp!, {pc}^			;ERROR: register clash
l2
	CMP	const, #1
	BNE	not_one
	CMP	cptr, #0
	MOVEQ	r0, #8
	LDMEQFD	sp!, {pc}^			;return size of code needed to divide by �1
	LDR	t1, op_mov_0
	ORR	t1, t1, outr, LSL #12
	STR	t1, [cptr], #4			;mov outr, #0
	LDR	t2, nsignpres
	CMP	t2, #1
	LDREQ	t1, op_mov_r0
	LDRNE	t1, op_rsb_0
	ORR	t1, t1, outq, LSL #12
	ORREQ	t1, t1, num			;mov outq, num		- if const > 0
	ORRNE	t1, t1, num, LSL #16		;rsb outq, num, #0	- if const < 0
	STR	t1, [cptr], #4
	MOV	r0, #8
	LDMFD	sp!, {pc}^			;return after compiling code to divide by �1
not_one
	CMP	signpres, #-1
	BEQ	not_signpres_1
	CMP	cptr, #0
	ADDEQ	cptr, cptr, #8
	BEQ	not_signpres_1
	LDR	t1, op_ands_sign
	ORR	t1, t1, signpres, LSL #12
	ORR	t1, t1, num, LSL #16
	STR	t1, [cptr], #4			;ands signpres, num, #&80000000
	LDR	t1, op_rsbne_0
	ORR	t1, t1, num, LSL #12
	ORR	t1, t1, num, LSL #16
	STR	t1, [cptr], #4			;rsbne num, num, #0
not_signpres_1
	LDR	t1, power_of_2
	MOV	t2, #1
	MOV	t2, t2, LSL t1
	CMP	const, t2
	BNE	not_a_power_of_2
						;have division by a power of 2
	LDR	t2, initial_cptr
	CMP	t2, #0
	ADDEQ	cptr, cptr, #8
	BEQ	now_restore_signs
	LDR	t2, op_mov_r0
	ORR	t2, t2, outq, LSL #12
	ORR	t2, t2, num			;mov outq, num, lsl #0
	ORR	t2, t2, #2_01 << 5		;changed to lsr #0 (which happens to mean lsr #32)
	ORR	t2, t2, t1, LSL #7
	STR	t2, [cptr], #4			;mov outq, num, lsr #power_of_2 (safe as power tween 1 & 31)
	LDR	t2, op_sub_0_0
	ORR	t2, t2, outr, LSL #12
	ORR	t2, t2, num, LSL #16
	ORR	t2, t2, outq
	ORR	t2, t2, t1, LSL #7
	STR	t2, [cptr], #4			;sub outr, num, outq, LSL #power_of_2
	B	now_restore_signs
not_a_power_of_2
	MOV	t1, #0
	STR	t1, subflag
	CMP	work, #-1
	BEQ	not_work_1
						;now we have to do megamov work, #const   - assuming const<>0
	MOV	m_v, const
	MOV	m_r, #0
m_l1	TST	m_v, #1
	MOVEQ	m_v, m_v, ROR #31
	ADDEQ	m_r, m_r, #1
	BEQ	m_l1
	STMFD	sp!, {m_r}			;to allow t2 (=m_r) to be used as scratch
	MOV	m_i, #0
	MOV	m_m, #1
	MOV	m_ml, #0
m_l2	ADD	m_i, m_i, #1
	MOV	m_m, m_m, LSL #1
	TST	m_v, m_m
	CMPNE	m_i, #32
	BNE	m_l2
	CMP	m_i, #32
	BGE	m_l3
	MOV	m_li, m_i
m_l4	ADD	m_i, m_i, #1
	MOV	m_m, m_m, LSL #1
	TST	m_v, m_m
	BNE	m_l5
	CMP	m_i, #32
	BNE	m_l4
m_l5	SUB	t2, m_i, m_li
	CMP	t2, m_ml
	MOVGT	m_mi, m_li
	MOVGT	m_ml, t2
	CMP	m_i, #32
	BLT	m_l2
m_l3	LDMFD	sp!, {m_r}			;also note m_li now free so can resume use of t3 (=m_li)
	CMP	m_ml, #0
	ADDGT	m_i, m_mi, m_ml
	MOVGT	m_v, m_v, ROR m_i
	RSBGT	m_i, m_i, #32
	ADDGT	m_r, m_r, m_i
	TST	m_r, #1
	MOVNE	m_v, m_v, ROR #31
	ADDNE	m_r, m_r, #1

	AND	m_r, m_r, #31
	AND	m_i, m_v, #255
	LDR	t1, initial_cptr
	CMP	t1, #0
	ADDEQ	cptr, cptr, #4
	LDRNE	t3, op_mov_0
	ORRNE	t3, t3, work, LSL #12
	ORRNE	t3, t3, m_r, LSL #8-1
	ORRNE	t3, t3, m_i
	STRNE	t3, [cptr], #4			;mov work, #m_i ror m_r
m_l6
	MOVS	m_v, m_v, LSR #8
	BEQ	not_work_1
	SUB	m_r, m_r, #8
	AND	m_r, m_r, #31
	ANDS	m_i, m_v, #255
	BEQ	m_l6
	CMP	t1, #0
	ADDEQ	cptr, cptr, #4
	LDRNE	t3, op_orr_0
	ORRNE	t3, t3, work, LSL #12
	ORRNE	t3, t3, work, LSL #16
	ORRNE	t3, t3, m_r, LSL #8-1
	ORRNE	t3, t3, m_i
	STRNE	t3, [cptr], #4			;orr work, work, #m_i ror m_r
	B	m_l6
not_work_1
	LDR	t2, power_of_2
	STR	t2, npower_of_2
	MOV	const, const, LSR t2

	MOV	t1, #1
	MOV	ps, #0				;s% in Basic version
	MOV	pm, #0				;m% in Basic version
calc_repeat
	CMP	t1, const
	SUBGE	t1, t1, const
	ADDGE	ps, ps, #1
	CMP	t1, #0
	BEQ	repeat_calcd
	ADC	t1, t1, t1			;nb above CMP ensures C always set, so this is t1=2*t1+1
	MOV	ps, ps, LSL #1
	ADD	pm, pm, #1
	CMP	pm, #32
	BLE	calc_repeat
repeat_calcd
	MOV	fn, ps
	BL	powerof2
	SUB	t2, t2, fn
	MOV	ps, ps, LSR fn
	STR	t2, power_of_2
	CMP	ps, #1
	BEQ	s_applied
	STR	ps, as
	STR	pm, am
	MOV	fn, ps
	ADR	stk, astk
	ADR	stkl, astk_end
	LDR	t1, op_add_0_0			;calc intermediate instructions used by fastdivaid
	ORR	t4, num, num, LSL #16
	ORR	t4, t4, outq, LSL #12		;data processing args outq, num, num
	ORR	t1, t1, t4
	STR	t1, op_fd1			;add outq, num, num
	LDR	t1, op_add_0_0_lsr
	ORR	t4, t1, t4
	STR	t4, op_fd3			;add outq, num, num, lsr #32
	ORR	t4, num, outq, LSL #16
	ORR	t4, t4, outq, LSL #12		;                args outq, outq, num
	ORR	t1, t1, t4
	STR	t1, op_fd4			;add outq, outq, num, lsr #32
	LDR	t1, op_sub_0_0_lsr
	ORR	t1, t1, t4
	STR	t1, op_fd2			;sub outq, outq, num, lsr #32
	BL	fastdivaid
	LDR	ps, as
	LDR	pm, am
s_applied					;nb t2=power_of_2 may no longer be valid, but ps & pm are
	MOV	fn, ps
	BL	bitpatlen			;fn is now ls%
	ADD	t1, pm, #1
	LDR	t2, initial_cptr
	CMP	t2, #0
	BNE	do_extend
	CMP	t1, #32
	BGE	bits_extended
	CMP	ps, #1
	MOVEQ	ps, #0
pseudo_extend_bits_loop
	ADD	cptr, cptr, #4
	MOV	t1, t1, LSL #1
	CMP	t1, #32
	BLT	pseudo_extend_bits_loop
	B	bits_extended
do_extend
	CMP	t1, #32
	BGE	bits_extended
	LDR	t3, op_add_0_0_lsr
	ORR	t3, t3, outq, LSL #12
	CMP	ps, #1
	MOVEQ	ps, #0
	ORREQ	t2, num, num, LSL #16
	ORRNE	t2, outq, outq, LSL #16
	ORR	t2, t2, t1, LSL #7
	ORR	t2, t3, t2			;if EQ 'add outq, num, num, lsr #t1%'
	STR	t2, [cptr], #4			;else  'add outq, outq, outq, lsr #t1%'
	MOV	t1, t1, LSL #1
	CMP	t1, #32
	BGE	bits_extended
	ORR	t2, outq, outq, LSL #16
	ORR	t3, t3, t2
extend_bits_loop
	ORR	t2, t3, t1, LSL #7
	STR	t2, [cptr], #4			;add outq, outq, outq, lsr #t1%
	MOV	t1, t1, LSL #1
	CMP	t1, #32
	BLT	extend_bits_loop
bits_extended
	LDR	t1, initial_cptr
	CMP	ps, #1
	BNE	large_div_patch_done
	CMP	t1, #0
	ADDEQ	cptr, cptr, #4
	LDRNE	t2, op_mov_r0
	ORRNE	t2, t2, outq, LSL #12
	ORRNE	t2, t2, num
	STRNE	t2, [cptr], #4			;mov outq, num
large_div_patch_done
	LDR	t3, power_of_2
	ADD	t3, t3, pm
	SUB	t3, t3, fn
	ADDS	t3, t3, #2
	BLE	final_shift_done
	CMP	t1, #0
	ADDEQ	cptr, cptr, #4
	LDRNE	t2, op_mov_r0_lsr
	ORRNE	t2, t2, outq, LSL #12
	ORRNE	t2, t2, outq
	ORRNE	t2, t2, t3, LSL #7
	STRNE	t2, [cptr], #4			;mov outq, outq, lsr #power_of_2
final_shift_done
	MOV	fn, const
	ADR	stk, astk
	ADR	stkl, astk_end
	ORR	t1, outq, outq, LSL #16		;calc intermediate instructions used by fastmul
	ORR	t1, t1, outr, LSL #12
	ORR	t2, outr, outq, LSL #16
	ORR	t2, t2, outr, LSL #12
	LDR	t3, op_mov_r0
	ORR	t4, t3, t1
	STR	t4, op_fm1
	ORR	t4, t3, t2
	STR	t4, op_fm2
	LDR	t3, op_add_0_0
	ORR	t4, t3, t1
	STR	t4, op_fm3
	ORR	t4, t3, t2
	STR	t4, op_fm4
	LDR	t3, op_rsb_0_0
	ORR	t4, t3, t1
	STR	t4, op_fm5
	ORR	t4, t3, t2
	STR	t4, op_fm6
	BL	fastmul
	LDR	t4, initial_cptr
	LDR	t3, npower_of_2
	MOV	const, const, LSL t3
	CMP	t4, #0
	ADDEQ	cptr, cptr, #4
	LDRNE	t1, op_subs_0_0
	ORRNE	t1, t1, outr, LSL #12
	ORRNE	t1, t1, num, LSL #16
	ORRNE	t1, t1, outr
	ORRNE	t1, t1, t3, LSL #7
	STRNE	t1, [cptr], #4			;subs outr, num, outr, lsl #npower_of_2 (possibly 0)
	LDR	t1, subflag
	BNE	do_check
	CMP	t1, #0
	ADDEQ	cptr, cptr, #12
	ADDNE	cptr, cptr, #20
	B	now_restore_signs
do_check
	CMP	work, #-1
	BNE	use_work
	CMP	t1, #0
	LDRNE	t1, op_submi_0_n1
	ORRNE	t1, t1, outq, LSL #12
	ORRNE	t1, t1, outq, LSL #16
	STRNE	t1, [cptr], #4			;submi outq, outq, #1
	LDR	t1, op2
	ORRNE	t2, t1, #2_0100<<28		;cond mi
	ORRNE	t2, t2, #2_0100<<21		;opcode add
	STRNE	t2, [cptr], #4			;addmi outr, outr, #const
	ORR	t2, t1, #2_1110<<28		;cond al
	ORR	t2, t2, #2_10101<<20		;opcode cmps
	STR	t2, [cptr], #4			;cmp outr, #const
	LDR	t2, op_addge_0_n1
	ORR	t2, t2, outq, LSL #12
	ORR	t2, t2, outq, LSL #16
	STR	t2, [cptr], #4			;addge outq, outq, #1
	ORR	t2, t1, #2_1010<<28		;cond ge
	ORR	t2, t2, #2_0010<<21		;opcode sub
	STR	t2, [cptr], #4			;subge outr, outr, #const
	B	now_restore_signs
use_work
	CMP	t1, #0
	LDRNE	t1, op_submi_0_n1
	ORRNE	t1, t1, outq, LSL #12
	ORRNE	t1, t1, outq, LSL #16
	STRNE	t1, [cptr], #4			;submi outq, outq, #1
	LDRNE	t1, op_addmi_0_0
	ORRNE	t1, t1, outr, LSL #12
	ORRNE	t1, t1, outr, LSL #16
	ORRNE	t1, t1, work
	STRNE	t1, [cptr], #4			;addmi outr, outr, work
	LDR	t1, op_cmp_0_0
	ORR	t2, t1, outr, LSL #16
	ORR	t2, t2, work
	STR	t2, [cptr], #4			;cmp outr, work
	LDR	t2, op_addge_0_n1
	ORR	t2, t2, outq, LSL #12
	ORR	t2, t2, outq, LSL #16
	STR	t2, [cptr], #4			;addge outq, outq, #1
	LDR	t1, op_subge_0_0
	ORR	t1, t1, outr, LSL #12
	ORR	t1, t1, outr, LSL #16
	ORR	t1, t1, work
	STR	t1, [cptr], #4			;subge outr, outr, work
now_restore_signs
	LDR	t4, initial_cptr
	LDR	t3, nsignpres
	CMP	signpres, #-1
	BNE	signpresd
	CMP	t3, #-1
	BNE	all_done
	CMP	t4, #0
	ADDEQ	cptr, cptr, #4
	LDRNE	t1, op_rsb_0
	ORRNE	t1, t1, outq, LSL #12
	ORRNE	t1, t1, outq, LSL #16
	STRNE	t1, [cptr], #4			;rsb outq, outq, #0
	B	all_done
signpresd
	CMP	t4, #0
	ADDEQ	cptr, cptr, #16
	BEQ	all_done
	LDR	t1, op_teqs_sign
	ORR	t1, t1, signpres, LSL #16
	STR	t1, [cptr], #4			;teqs signpres, #&80000000
	LDR	t2, op_rsbeq_0
	ORR	t1, t2, num, LSL #12
	ORR	t1, t1, num, LSL #16
	STR	t1, [cptr], #4			;rsbeq num, num, #0
	ORR	t1, t2, outr, LSL #12
	ORR	t1, t1, outr, LSL #16
	STR	t1, [cptr], #4			;rsbeq outr, outr, #0
	ORR	t1, t2, outq, LSL #12
	ORR	t1, t1, outq, LSL #16
	CMP	t3, #-1
	ORREQ	t1, t1, #2_0001<<28		;cond ne
	STR	t1, [cptr], #4			;if ne 'rsbeq outq, outq, #0', else flip cond to rsbne
all_done
	LDR	t1, initial_cptr
	SUB	r0, cptr, t1
	LDMFD	sp!, {pc}^

initial_cptr	DCD	0
nsignpres	DCD	0
power_of_2	DCD	0
subflag		DCD	0
npower_of_2	DCD	0
as		DCD	0
am		DCD	0

op1	ANDEQ	r0, r0, #0,0			;used to build op2; note AND, EQ etc chosen as give 0 bits
op2	DCD	0				;will store data processing instruction of form
						;<cond><opcode> [outr],[outr],#[const]
						;NB outr is r4, [outr] means the register whose number is
						;stored in r4 when generator code executed - don't confuse
						;this with register r4 itself.
op_mov_0	MOV	r0, #0,0
op_mov_r0	MOV	r0, r0
op_rsb_0	RSB	r0, r0, #0,0
op_ands_sign	ANDS	r0, r0, #&80000000
op_rsbne_0	RSBNE	r0, r0, #0,0
op_sub_0_0	SUB	r0, r0, r0
op_orr_0	ORR	r0, r0, #0,0
op_add_0_0	ADD	r0, r0, r0
op_sub_0_0_lsr	SUB	r0, r0, r0, LSR #32	;nb LSR #32 represented in bit field by LSR #0
op_add_0_0_lsr	ADD	r0, r0, r0, LSR #32
op_mov_r0_lsr	MOV	r0, r0, LSR #32
op_rsb_0_0	RSB	r0, r0, r0
op_subs_0_0	SUBS	r0, r0, r0
op_submi_0_n1	SUBMI	r0, r0, #1
op_addge_0_n1	ADDGE	r0, r0, #1
op_addmi_0_0	ADDMI	r0, r0, r0
op_cmp_0_0	CMP	r0, r0
op_subge_0_0	SUBGE	r0, r0, r0
op_teqs_sign	TEQS	r0, #&80000000
op_rsbeq_0	RSBEQ	r0, r0, #0,0

op_fd1		DCD	0
op_fd2		DCD	0
op_fd3		DCD	0
op_fd4		DCD	0
op_fm1		DCD	0
op_fm2		DCD	0
op_fm3		DCD	0
op_fm4		DCD	0
op_fm5		DCD	0
op_fm6		DCD	0

astk	%	16*8				;16 entries of 2 words (an empty ascending stack)
astk_end

fastdivaid
	CMP	stk, stkl
	MOVGE	r0, #-5
	LDMGEFD	sp!, {pc}^
	MOV	t4, fn				;t4 holds local const%
	MOV	t1, lr
	BL	bitpatlen			;fn now holds Basic ls%
	SUB	t3, fn, #1
	STMEA	stk!, {t3, t1}			;stack ls%-1 above return address
	ANDS	t2, t4, #3
	CMPNE	t2, #2
	MOVEQ	r0, #-6
	LDMEQFD	sp!, {pc}^
	CMP	t2, #1
	SUBEQ	t4, t4, #1
	ADDNE	t4, t4, #1
	MOVNE	t1, #1
	STRNE	t1, subflag
	MOV	fn, t4
	BL	powerof2
	MOV	t4, t4, LSR fn			;local const = const >>> powerof2(const)
	CMP	t4, #1
	BNE	fda_constoverone
	LDR	t1, initial_cptr
	CMP	t1, #0
	BNE	fda_l1
	CMP	t2, #1				;EQ implies divinst$="ADD"
	ADDEQ	cptr, cptr, #4
	ADDNE	cptr, cptr, #8
	B	fda_exit
fda_l1	LDR	t3, [stk, #-4]			;get back ls%-1
	CMP	t2, #1
	LDRNE	t1, op_fd1
	STRNE	t1, [cptr], #4			;add outq, num, num
	LDRNE	t1, op_fd2
	LDREQ	t1, op_fd3
	ORR	t1, t1, t3, LSL #7
	STR	t1, [cptr], #4			;if NE 'sub outq, outq, num, lsr #ls%-1'
	B	fda_exit			;else  'add outq, num, num, lsr #ls%-1'
fda_constoverone
	CMP	t2, #1
	BEQ	fda_l2
						;const>1 & divinst$="SUB"
	MOV	fn, t4				;first recurse
	BL	fastdivaid
	LDR	t1, initial_cptr
	CMP	t1, #0
	ADDEQ	cptr, cptr, #4
	BEQ	fda_exit
	LDR	fn, [stk, #-4]
	LDR	t1, op_fd2
	ORR	t1, t1, fn, LSL #7
	STR	t1, [cptr], #4
	B	fda_exit
fda_l2						;const>1 & divinst$="ADD"
	MOV	fn, t4				;first recurse
	BL	fastdivaid
	LDR	t1, initial_cptr
	CMP	t1, #0
	ADDEQ	cptr, cptr, #4
	BEQ	fda_exit
	LDR	fn, [stk, #-4]
	LDR	t1, op_fd4
	ORR	t1, t1, fn, LSL #7
	STR	t1, [cptr], #4
fda_exit
	LDMEA	stk!, {fn, t2}			;discard ls%-1 & return
	MOVS	pc, t2

fastmul
	CMP	stk, stkl
	MOVGE	r0, #-5
	LDMGEFD	sp!, {pc}^
	STMEA	stk!, {lr}
	ANDS	t1, fn, #3			;fn holds local const
	CMPNE	t1, #2
	BNE	fm_try_one
	MOV	t4, fn
	BL	powerof2
	STMEA	stk!, {fn}			;return address & n% (fn)  stacked, local const in t4
	MOV	t4, t4, LSR fn
	CMP	t4, #1
	LDREQ	t2, op_fm1
	BEQ	fm_exit
	MOV	fn, t4
	BL	fastmul				;recurse
	LDR	fn, [stk, #-4]
	LDR	t2, op_fm2
	B	fm_exit
fm_try_one
	CMP	t1, #1
	BNE	fm_is_three
	SUB	fn, fn, #1
	MOV	t4, fn
	BL	powerof2
	STMEA	stk!, {fn}			;return address & n% (fn)  stacked, local const in t4
	MOV	t4, t4, LSR fn
	CMP	t4, #1
	LDREQ	t2, op_fm3
	BEQ	fm_exit
	MOV	fn, t4
	BL	fastmul				;recurse
	LDR	fn, [stk, #-4]
	LDR	t2, op_fm4
	B	fm_exit
fm_is_three
	ADD	fn, fn, #1
	MOV	t4, fn
	BL	powerof2
	STMEA	stk!, {fn}			;return address & n% (fn)  stacked, local const in t4
	MOV	t4, t4, LSR fn
	CMP	t4, #1
	LDREQ	t2, op_fm5
	BEQ	fm_exit
	MOV	fn, t4
	BL	fastmul				;recurse
	LDR	fn, [stk, #-4]
	LDR	t2, op_fm6
	B	fm_exit
fm_exit
	LDR	t1, initial_cptr
	CMP	t1, #0
	ADDEQ	cptr, cptr, #4
	ORRNE	t2, t2, fn, LSL #7
	STRNE	t2, [cptr], #4
	LDMEA	stk!, {fn, t2}			;discard n% & return
	MOVS	pc, t2


	GBLA	counter

bitpatlen
	MOVS	t2, fn
	MOV	fn, #0
counter	SETA	31
	WHILE	counter>0
	ADDNE	fn, fn, #1
	MOVNES	t2, t2, LSR #1
	MOVEQS	pc, lr
counter	SETA	counter-1
	WEND
	ADD	fn, fn, #1
	MOVS	pc, lr

imop2
	MOV	t1, #0
counter	SETA	16
	WHILE	counter>0
	BICS	t2, fn, #255
	BEQ	imop2_l1
	MOV	fn, fn, ROR #30
	ADD	t1, t1, #256
counter	SETA	counter-1
	WEND
	MOV	fn, #-1
	MOVS	pc, lr
imop2_l1
	ORR	fn, t1, fn
	MOVS	pc, lr

powerof2
	MOVS	t1, fn
	MOV	fn, #0
	MOVEQS	pc, lr
counter	SETA	31
	WHILE   counter>0
	MOVS	t1, t1, LSR #1
	ADDCC	fn, fn, #1
	MOVCSS	pc, lr
counter	SETA	counter-1
	WEND
	MOVS	pc, lr



	END
00000000  3b 20 71 75 69 63 6b 64  69 76 5f 69 6e 69 74 0a  |; quickdiv_init.|
00000010  3b 20 61 20 6c 65 61 66  20 41 50 43 53 20 66 75  |; a leaf APCS fu|
00000020  6e 63 74 69 6f 6e 0a 3b  0a 3b 20 43 20 70 72 6f  |nction.;.; C pro|
00000030  74 6f 74 79 70 65 3a 0a  3b 20 69 6e 74 20 71 75  |totype:.; int qu|
00000040  69 63 6b 64 69 76 5f 69  6e 69 74 28 69 6e 74 20  |ickdiv_init(int |
00000050  64 69 76 69 73 6f 72 29  0a 3b 0a 3b 20 61 73 73  |divisor).;.; ass|
00000060  65 6d 62 6c 65 73 20 74  68 65 20 43 20 66 75 6e  |embles the C fun|
00000070  63 74 69 6f 6e 20 71 75  69 63 6b 64 69 76 2c 20  |ction quickdiv, |
00000080  62 65 6c 6f 77 2c 20 74  6f 20 63 61 72 72 79 20  |below, to carry |
00000090  6f 75 74 20 72 61 70 69  64 20 64 69 76 69 73 69  |out rapid divisi|
000000a0  6f 6e 20 62 79 20 74 68  65 20 73 75 70 70 6c 69  |on by the suppli|
000000b0  65 64 20 64 69 76 69 73  6f 72 20 2d 0a 3b 20 61  |ed divisor -.; a|
000000c0  66 74 65 72 20 63 61 6c  6c 69 6e 67 20 74 68 69  |fter calling thi|
000000d0  73 20 66 6e 2c 20 63 61  72 72 79 20 6f 75 74 20  |s fn, carry out |
000000e0  61 20 64 69 76 69 73 69  6f 6e 20 76 69 61 20 71  |a division via q|
000000f0  75 6f 74 69 65 6e 74 3d  71 75 69 63 6b 64 69 76  |uotient=quickdiv|
00000100  28 6e 75 6d 65 72 61 74  6f 72 29 3b 0a 3b 0a 3b  |(numerator);.;.;|
00000110  20 65 67 20 75 73 65 3a  09 66 6f 72 20 28 69 3d  | eg use:.for (i=|
00000120  30 3b 69 3c 31 30 30 30  30 3b 69 2b 2b 29 20 70  |0;i<10000;i++) p|
00000130  72 69 6e 74 66 28 22 25  69 22 2c 20 69 2f 6e 29  |rintf("%i", i/n)|
00000140  3b 0a 3b 20 72 65 70 6c  61 63 65 20 77 69 74 68  |;.; replace with|
00000150  3a 09 71 75 69 63 6b 64  69 76 5f 69 6e 69 74 28  |:.quickdiv_init(|
00000160  6e 29 3b 20 66 6f 72 20  28 69 3d 30 3b 69 3c 31  |n); for (i=0;i<1|
00000170  30 30 30 30 3b 69 2b 2b  29 20 70 72 69 6e 74 66  |0000;i++) printf|
00000180  28 22 25 69 22 2c 20 71  75 69 63 6b 64 69 76 28  |("%i", quickdiv(|
00000190  69 29 29 3b 0a 3b 0a 3b  20 6e 62 20 69 6e 69 74  |i));.;.; nb init|
000001a0  20 65 78 65 63 75 74 65  73 20 69 6e 20 61 62 6f  | executes in abo|
000001b0  75 74 20 32 30 20 78 20  74 69 6d 65 20 6f 66 20  |ut 20 x time of |
000001c0  61 20 64 65 63 65 6e 74  20 66 6f 75 72 69 65 72  |a decent fourier|
000001d0  20 64 69 76 20 72 6f 75  74 69 6e 65 2c 20 77 68  | div routine, wh|
000001e0  69 6c 65 20 71 75 69 63  6b 64 69 76 20 74 79 70  |ile quickdiv typ|
000001f0  69 63 61 6c 6c 79 20 65  78 65 63 75 74 65 73 0a  |ically executes.|
00000200  3b 20 69 6e 20 75 6e 64  65 72 20 30 2e 32 20 78  |; in under 0.2 x|
00000210  20 74 69 6d 65 20 66 64  69 76 20 72 6f 75 74 69  | time fdiv routi|
00000220  6e 65 2c 20 74 68 75 73  20 69 6e 20 61 62 6f 76  |ne, thus in abov|
00000230  65 20 6c 6f 6f 70 20 63  61 6c 63 20 77 65 20 6d  |e loop calc we m|
00000240  61 6b 65 20 73 70 65 65  64 20 73 61 76 69 6e 67  |ake speed saving|
00000250  20 61 66 74 65 72 20 6c  6f 6f 70 20 65 78 63 65  | after loop exce|
00000260  65 64 73 20 7e 32 35 0a  3b 20 61 6e 64 20 66 6f  |eds ~25.; and fo|
00000270  72 20 66 75 6c 6c 20 31  30 30 30 30 20 6c 69 6d  |r full 10000 lim|
00000280  69 74 2c 20 67 65 74 20  73 70 65 65 64 20 69 6e  |it, get speed in|
00000290  63 72 65 61 73 65 20 69  6e 20 64 69 76 20 63 61  |crease in div ca|
000002a0  6c 63 20 6f 66 20 61 62  6f 75 74 20 34 2e 39 35  |lc of about 4.95|
000002b0  0a 3b 0a 3b 20 6e 62 32  20 77 68 65 6e 20 69 6e  |.;.; nb2 when in|
000002c0  20 64 69 72 65 63 74 20  63 6f 6d 70 61 72 69 73  | direct comparis|
000002d0  6f 6e 20 77 69 74 68 20  41 63 6f 72 6e 27 73 20  |on with Acorn's |
000002e0  64 69 76 69 73 69 6f 6e  20 63 6f 64 65 2c 20 6e  |division code, n|
000002f0  6f 74 65 20 69 74 20 69  73 20 6f 70 74 69 6d 69  |ote it is optimi|
00000300  73 65 64 20 66 6f 72 20  6c 6f 77 20 6e 75 6d 65  |sed for low nume|
00000310  72 61 74 6f 72 2c 20 61  6e 64 0a 3b 20 77 69 6c  |rator, and.; wil|
00000320  6c 20 74 68 65 6e 20 65  71 75 61 6c 20 6f 72 20  |l then equal or |
00000330  6f 75 74 70 65 72 66 6f  72 6d 20 74 68 69 73 20  |outperform this |
00000340  63 6f 64 65 2c 20 68 6f  77 65 76 65 72 20 6f 6e  |code, however on|
00000350  63 65 20 6e 75 6d 65 72  61 74 6f 72 20 67 65 74  |ce numerator get|
00000360  73 20 62 69 67 67 65 72  20 74 68 61 6e 20 7e 32  |s bigger than ~2|
00000370  5e 39 20 61 6e 64 20 68  61 76 65 20 6c 6f 6f 70  |^9 and have loop|
00000380  3e 7e 32 35 0a 3b 20 77  65 20 6d 61 6b 65 20 73  |>~25.; we make s|
00000390  61 76 69 6e 67 73 3b 20  74 68 65 73 65 20 62 65  |avings; these be|
000003a0  63 6f 6d 65 20 33 30 30  25 2d 36 30 30 25 20 66  |come 300%-600% f|
000003b0  6f 72 20 6e 75 6d 65 72  61 74 6f 72 20 7e 31 36  |or numerator ~16|
000003c0  20 62 69 74 73 20 6f 72  20 6d 6f 72 65 20 61 6e  | bits or more an|
000003d0  64 20 6c 61 72 67 65 20  6c 6f 6f 70 73 2e 0a 3b  |d large loops..;|
000003e0  0a 3b 20 72 65 74 75 72  6e 20 63 6f 64 65 73 20  |.; return codes |
000003f0  61 73 20 66 6f 72 20 67  65 6e 20 62 65 6c 6f 77  |as for gen below|
00000400  2c 20 70 6c 75 73 3a 20  2d 37 20 69 6e 64 69 63  |, plus: -7 indic|
00000410  61 74 69 6e 67 20 70 72  6f 67 72 61 6d 20 65 72  |ating program er|
00000420  72 6f 72 20 2d 20 73 65  72 69 6f 75 73 20 63 6f  |ror - serious co|
00000430  72 72 75 70 74 69 6f 6e  20 64 75 65 20 74 6f 20  |rruption due to |
00000440  63 6f 64 65 0a 3b 09 09  09 09 09 09 09 09 20 20  |code.;........  |
00000450  20 20 20 6f 76 65 72 66  6c 6f 77 69 6e 67 20 71  |   overflowing q|
00000460  75 69 63 6b 64 69 76 20  62 75 66 66 65 72 0a 3b  |uickdiv buffer.;|
00000470  0a 0a 20 20 20 20 20 20  20 20 45 58 50 4f 52 54  |..        EXPORT|
00000480  20 20 71 75 69 63 6b 64  69 76 5f 69 6e 69 74 0a  |  quickdiv_init.|
00000490  0a 71 69 6e 73 74 61 20  20 44 43 42 20 20 20 20  |.qinsta  DCB    |
000004a0  20 22 71 75 69 63 6b 64  69 76 5f 69 6e 69 74 22  | "quickdiv_init"|
000004b0  2c 20 30 0a 20 20 20 20  20 20 20 20 41 4c 49 47  |, 0.        ALIG|
000004c0  4e 0a 71 69 6e 65 6e 64  20 20 44 43 44 20 20 20  |N.qinend  DCD   |
000004d0  20 20 26 66 66 30 30 30  30 30 30 20 2b 20 71 69  |  &ff000000 + qi|
000004e0  6e 65 6e 64 20 2d 20 71  69 6e 73 74 61 0a 0a 71  |nend - qinsta..q|
000004f0  75 69 63 6b 64 69 76 5f  69 6e 69 74 0a 0a 09 53  |uickdiv_init...S|
00000500  54 4d 46 44 09 73 70 21  2c 20 7b 76 31 2d 76 36  |TMFD.sp!, {v1-v6|
00000510  2c 20 73 6c 2c 20 66 70  2c 20 6c 72 7d 0a 09 41  |, sl, fp, lr}..A|
00000520  44 52 09 72 31 2c 20 71  75 69 63 6b 64 69 76 0a  |DR.r1, quickdiv.|
00000530  09 4d 4f 56 09 72 32 2c  20 23 30 0a 09 4d 4f 56  |.MOV.r2, #0..MOV|
00000540  09 72 33 2c 20 23 31 32  0a 09 4d 4f 56 09 72 34  |.r3, #12..MOV.r4|
00000550  2c 20 23 31 0a 09 4d 4f  56 09 72 35 2c 20 23 32  |, #1..MOV.r5, #2|
00000560  0a 09 4d 4f 56 09 72 36  2c 20 23 33 0a 09 42 4c  |..MOV.r6, #3..BL|
00000570  09 67 65 6e 0a 09 43 4d  50 09 72 30 2c 20 23 30  |.gen..CMP.r0, #0|
00000580  0a 09 4c 44 4d 4c 54 46  44 09 73 70 21 2c 20 7b  |..LDMLTFD.sp!, {|
00000590  76 31 2d 76 36 2c 20 73  6c 2c 20 66 70 2c 20 70  |v1-v6, sl, fp, p|
000005a0  63 7d 5e 0a 09 41 44 52  09 72 31 2c 20 71 75 69  |c}^..ADR.r1, qui|
000005b0  63 6b 64 69 76 0a 09 41  44 44 09 72 31 2c 20 72  |ckdiv..ADD.r1, r|
000005c0  31 2c 20 72 30 0a 09 41  44 52 09 72 32 2c 20 71  |1, r0..ADR.r2, q|
000005d0  75 69 63 6b 64 69 76 65  6e 64 2d 38 0a 09 43 4d  |uickdivend-8..CM|
000005e0  50 09 72 31 2c 20 72 32  0a 09 4c 44 52 48 49 09  |P.r1, r2..LDRHI.|
000005f0  72 30 2c 20 71 75 69 63  6b 64 69 76 5f 69 6e 69  |r0, quickdiv_ini|
00000600  74 5f 6f 70 73 2b 34 0a  09 53 54 52 48 49 09 72  |t_ops+4..STRHI.r|
00000610  30 2c 20 71 75 69 63 6b  64 69 76 0a 09 4d 4f 56  |0, quickdiv..MOV|
00000620  48 49 09 72 30 2c 20 23  2d 37 0a 09 4c 44 4d 48  |HI.r0, #-7..LDMH|
00000630  49 46 44 09 73 70 21 2c  20 7b 76 31 2d 76 36 2c  |IFD.sp!, {v1-v6,|
00000640  20 73 6c 2c 20 66 70 2c  20 70 63 7d 5e 0a 09 41  | sl, fp, pc}^..A|
00000650  44 52 09 72 32 2c 20 71  75 69 63 6b 64 69 76 5f  |DR.r2, quickdiv_|
00000660  69 6e 69 74 5f 6f 70 73  0a 09 4c 44 4d 49 41 09  |init_ops..LDMIA.|
00000670  72 32 2c 20 7b 72 33 2c  20 72 34 7d 0a 09 53 54  |r2, {r3, r4}..ST|
00000680  4d 49 41 09 72 31 21 2c  20 7b 72 33 2c 20 72 34  |MIA.r1!, {r3, r4|
00000690  7d 0a 09 41 44 44 09 72  30 2c 20 72 30 2c 20 23  |}..ADD.r0, r0, #|
000006a0  38 0a 09 4c 44 4d 46 44  09 73 70 21 2c 20 7b 76  |8..LDMFD.sp!, {v|
000006b0  31 2d 76 36 2c 20 73 6c  2c 20 66 70 2c 20 70 63  |1-v6, sl, fp, pc|
000006c0  7d 5e 0a 0a 71 75 69 63  6b 64 69 76 5f 69 6e 69  |}^..quickdiv_ini|
000006d0  74 5f 6f 70 73 0a 09 4d  4f 56 09 72 30 2c 20 72  |t_ops..MOV.r0, r|
000006e0  31 32 0a 09 4d 4f 56 53  09 70 63 2c 20 6c 72 0a  |12..MOVS.pc, lr.|
000006f0  0a 0a 0a 3b 20 71 75 69  63 6b 64 69 76 0a 3b 20  |...; quickdiv.; |
00000700  61 20 6c 65 61 66 20 41  50 43 53 20 66 75 6e 63  |a leaf APCS func|
00000710  74 69 6f 6e 0a 3b 0a 3b  20 43 20 70 72 6f 74 6f  |tion.;.; C proto|
00000720  74 79 70 65 3a 0a 3b 20  69 6e 74 20 71 75 69 63  |type:.; int quic|
00000730  6b 64 69 76 28 69 6e 74  20 6e 75 6d 65 72 61 74  |kdiv(int numerat|
00000740  6f 72 29 0a 3b 0a 3b 20  72 65 74 75 72 6e 73 20  |or).;.; returns |
00000750  6e 75 6d 65 72 61 74 6f  72 2f 64 69 76 69 73 6f  |numerator/diviso|
00000760  72 2c 20 77 68 65 72 65  20 64 69 76 69 73 6f 72  |r, where divisor|
00000770  20 77 61 73 20 74 68 65  20 61 72 67 75 6d 65 6e  | was the argumen|
00000780  74 20 66 6f 72 6d 65 72  6c 79 20 70 61 73 73 65  |t formerly passe|
00000790  64 20 74 6f 20 71 75 69  63 6b 64 69 76 5f 69 6e  |d to quickdiv_in|
000007a0  69 74 0a 3b 20 28 77 68  6f 73 65 20 70 75 72 70  |it.; (whose purp|
000007b0  6f 73 65 20 77 61 73 20  74 6f 20 61 73 73 65 6d  |ose was to assem|
000007c0  62 6c 65 20 74 68 69 73  20 66 75 6e 63 74 69 6f  |ble this functio|
000007d0  6e 29 0a 3b 0a 0a 20 20  20 20 20 20 20 20 45 58  |n).;..        EX|
000007e0  50 4f 52 54 20 20 71 75  69 63 6b 64 69 76 0a 0a  |PORT  quickdiv..|
000007f0  71 64 6e 73 74 61 20 20  44 43 42 20 20 20 20 20  |qdnsta  DCB     |
00000800  22 71 75 69 63 6b 64 69  76 22 2c 20 30 0a 20 20  |"quickdiv", 0.  |
00000810  20 20 20 20 20 20 41 4c  49 47 4e 0a 71 64 6e 65  |      ALIGN.qdne|
00000820  6e 64 20 20 44 43 44 20  20 20 20 20 26 66 66 30  |nd  DCD     &ff0|
00000830  30 30 30 30 30 20 2b 20  71 64 6e 65 6e 64 20 2d  |00000 + qdnend -|
00000840  20 71 64 6e 73 74 61 0a  0a 71 75 69 63 6b 64 69  | qdnsta..quickdi|
00000850  76 0a 0a 09 4d 4f 56 53  09 70 63 2c 20 6c 72 0a  |v...MOVS.pc, lr.|
00000860  09 25 09 33 38 30 0a 71  75 69 63 6b 64 69 76 65  |.%.380.quickdive|
00000870  6e 64 0a 0a 0a 0a 3b 0a  3b 20 4e 61 6d 65 3a 09  |nd....;.; Name:.|
00000880  47 65 6e 65 72 61 74 6f  72 2e 0a 3b 0a 3b 20 41  |Generator..;.; A|
00000890  75 74 68 6f 72 3a 0a 3b  09 4d 69 63 68 61 65 6c  |uthor:.;.Michael|
000008a0  20 52 6f 7a 64 6f 62 61  2c 20 66 72 6f 6d 20 61  | Rozdoba, from a|
000008b0  6e 20 61 6c 67 6f 72 69  74 68 6d 20 6f 72 69 67  |n algorithm orig|
000008c0  69 6e 61 6c 6c 79 20 62  61 73 65 64 20 6f 6e 20  |inally based on |
000008d0  74 68 65 20 77 6f 72 6b  20 6f 66 20 53 61 6d 75  |the work of Samu|
000008e0  65 6c 20 4b 2e 52 2e 20  53 6d 69 74 68 2e 0a 3b  |el K.R. Smith..;|
000008f0  0a 3b 20 46 75 6e 63 74  69 6f 6e 3a 0a 3b 20 09  |.; Function:.; .|
00000900  43 6f 6d 70 69 6c 65 20  63 6f 64 65 20 74 6f 20  |Compile code to |
00000910  63 61 72 72 79 20 6f 75  74 20 72 61 70 69 64 20  |carry out rapid |
00000920  61 73 73 65 6d 62 6c 65  72 20 64 69 76 69 73 6f  |assembler diviso|
00000930  6e 20 62 79 20 61 6e 20  61 72 62 69 74 72 61 72  |n by an arbitrar|
00000940  79 20 63 6f 6e 73 74 61  6e 74 2e 0a 3b 0a 3b 20  |y constant..;.; |
00000950  41 72 67 75 6d 65 6e 74  73 3a 0a 3b 20 72 30 09  |Arguments:.; r0.|
00000960  64 69 76 69 73 6f 72 20  63 6f 6e 73 74 61 6e 74  |divisor constant|
00000970  0a 3b 20 72 31 09 70 74  72 20 74 6f 20 62 75 66  |.; r1.ptr to buf|
00000980  66 65 72 20 66 6f 72 20  63 6f 64 65 20 28 70 61  |fer for code (pa|
00000990  73 73 69 6e 67 20 30 20  69 6e 64 69 63 61 74 65  |ssing 0 indicate|
000009a0  73 20 6e 6f 20 63 6f 64  65 20 74 6f 20 62 65 20  |s no code to be |
000009b0  63 6f 6d 70 69 6c 65 64  20 2d 20 61 6c 6c 6f 77  |compiled - allow|
000009c0  73 20 72 6f 75 74 69 6e  65 20 74 6f 20 62 65 20  |s routine to be |
000009d0  63 61 6c 6c 65 64 20 74  6f 0a 3b 09 63 61 6c 63  |called to.;.calc|
000009e0  75 6c 61 74 65 20 73 69  7a 65 20 6f 66 20 62 75  |ulate size of bu|
000009f0  66 66 65 72 20 72 65 71  75 69 72 65 64 29 0a 3b  |ffer required).;|
00000a00  20 72 32 09 6e 75 6d 62  65 72 20 6f 66 20 6e 75  | r2.number of nu|
00000a10  6d 65 72 61 74 6f 72 20  72 65 67 69 73 74 65 72  |merator register|
00000a20  20 66 6f 72 20 72 6f 75  74 69 6e 65 20 74 6f 20  | for routine to |
00000a30  62 65 20 63 6f 6d 70 69  6c 65 64 0a 3b 20 72 33  |be compiled.; r3|
00000a40  09 6e 75 6d 62 65 72 20  6f 66 20 6f 75 74 70 75  |.number of outpu|
00000a50  74 20 71 75 6f 74 69 65  6e 74 20 72 65 67 69 73  |t quotient regis|
00000a60  74 65 72 0a 3b 20 72 34  09 6e 75 6d 62 65 72 20  |ter.; r4.number |
00000a70  6f 66 20 6f 75 74 70 75  74 20 72 65 6d 61 69 6e  |of output remain|
00000a80  64 65 72 20 72 65 67 69  73 74 65 72 0a 3b 20 72  |der register.; r|
00000a90  35 09 73 63 72 61 74 63  68 20 2d 20 77 6f 72 6b  |5.scratch - work|
00000aa0  20 72 65 67 69 73 74 65  72 20 2d 20 6e 6f 74 20  | register - not |
00000ab0  6e 65 65 64 65 64 20 69  66 20 64 69 76 69 73 6f  |needed if diviso|
00000ac0  72 20 69 73 20 61 20 76  61 6c 69 64 20 69 6d 6d  |r is a valid imm|
00000ad0  65 64 69 61 74 65 20 63  6f 6e 73 74 61 6e 74 20  |ediate constant |
00000ae0  28 6e 62 20 69 66 20 77  6f 72 6b 20 73 75 70 70  |(nb if work supp|
00000af0  6c 69 65 64 20 69 6e 0a  3b 09 61 6e 79 20 63 61  |lied in.;.any ca|
00000b00  73 65 2c 20 62 75 74 20  6e 6f 74 20 6e 65 65 64  |se, but not need|
00000b10  65 64 2c 20 69 74 20 77  69 6c 6c 20 62 65 20 69  |ed, it will be i|
00000b20  67 6e 6f 72 65 64 20 2d  20 69 66 20 63 61 6c 6c  |gnored - if call|
00000b30  65 72 20 6b 6e 6f 77 73  20 69 74 20 77 69 6c 6c  |er knows it will|
00000b40  20 6e 6f 74 20 62 65 20  6e 65 65 64 65 64 2c 20  | not be needed, |
00000b50  2d 31 20 6d 61 79 20 62  65 0a 3b 09 70 61 73 73  |-1 may be.;.pass|
00000b60  65 64 29 0a 3b 20 72 36  09 73 63 72 61 74 63 68  |ed).; r6.scratch|
00000b70  20 2d 20 73 69 67 6e 20  70 72 65 73 65 72 76 61  | - sign preserva|
00000b80  74 69 6f 6e 20 72 65 67  69 73 74 65 72 20 28 6f  |tion register (o|
00000b90  66 20 6e 75 6d 65 72 61  74 6f 72 29 20 2d 20 69  |f numerator) - i|
00000ba0  66 20 6e 75 6d 65 72 61  74 6f 72 20 69 73 20 6b  |f numerator is k|
00000bb0  6e 6f 77 6e 20 74 6f 20  61 6c 77 61 79 73 20 62  |nown to always b|
00000bc0  65 20 70 6f 73 69 74 69  76 65 0a 3b 09 6d 61 79  |e positive.;.may|
00000bd0  20 70 61 73 73 20 2d 31  20 74 6f 20 69 6e 64 69  | pass -1 to indi|
00000be0  63 61 74 65 20 74 68 69  73 2c 20 77 68 69 63 68  |cate this, which|
00000bf0  20 77 69 6c 6c 20 73 61  76 65 20 75 73 65 20 6f  | will save use o|
00000c00  66 20 73 69 67 6e 70 72  65 73 20 72 65 67 69 73  |f signpres regis|
00000c10  74 65 72 20 26 20 77 69  6c 6c 20 72 65 64 75 63  |ter & will reduc|
00000c20  65 20 63 6f 6d 70 69 6c  65 64 20 63 6f 64 65 0a  |e compiled code.|
00000c30  3b 09 73 69 7a 65 20 62  79 20 36 20 69 6e 73 74  |;.size by 6 inst|
00000c40  72 75 63 74 69 6f 6e 73  20 74 79 70 69 63 61 6c  |ructions typical|
00000c50  6c 79 20 28 63 66 20 74  79 70 69 63 61 6c 20 63  |ly (cf typical c|
00000c60  6f 64 65 20 73 69 7a 65  20 32 30 20 74 6f 20 32  |ode size 20 to 2|
00000c70  37 20 69 6e 73 74 72 75  63 74 69 6f 6e 73 2c 20  |7 instructions, |
00000c80  77 68 65 6e 20 73 69 67  6e 20 70 72 65 73 65 72  |when sign preser|
00000c90  76 61 74 69 6f 6e 0a 3b  09 69 73 20 61 63 74 69  |vation.;.is acti|
00000ca0  76 65 2c 20 74 68 65 6e  63 65 20 72 65 64 75 63  |ve, thence reduc|
00000cb0  65 64 20 74 6f 20 31 34  20 74 6f 20 32 31 20 69  |ed to 14 to 21 i|
00000cc0  6e 73 74 72 75 63 74 69  6f 6e 73 29 0a 3b 0a 3b  |nstructions).;.;|
00000cd0  09 4e 42 20 41 6c 6c 20  73 75 70 70 6c 69 65 64  |.NB All supplied|
00000ce0  20 72 65 67 69 73 74 65  72 20 6e 75 6d 62 65 72  | register number|
00000cf0  73 20 28 6f 74 68 65 72  20 74 68 61 6e 20 77 6f  |s (other than wo|
00000d00  72 6b 20 26 20 73 69 67  6e 70 72 65 73 20 77 68  |rk & signpres wh|
00000d10  65 6e 20 6e 6f 74 20 6e  65 65 64 65 64 20 26 20  |en not needed & |
00000d20  70 61 73 73 65 64 20 61  73 20 2d 31 29 20 4d 55  |passed as -1) MU|
00000d30  53 54 20 62 65 0a 3b 09  20 20 20 64 69 73 74 69  |ST be.;.   disti|
00000d40  6e 63 74 2e 0a 3b 0a 3b  20 52 65 74 75 72 6e 73  |nct..;.; Returns|
00000d50  3a 0a 3b 20 72 30 09 73  69 7a 65 20 6f 66 20 63  |:.; r0.size of c|
00000d60  6f 6d 70 69 6c 65 64 20  63 6f 64 65 20 69 6e 20  |ompiled code in |
00000d70  62 79 74 65 73 0a 3b 09  61 20 76 61 6c 75 65 20  |bytes.;.a value |
00000d80  6f 66 20 73 69 7a 65 3c  30 20 69 6e 64 69 63 61  |of size<0 indica|
00000d90  74 65 73 20 61 6e 20 65  72 72 6f 72 20 6f 63 63  |tes an error occ|
00000da0  75 72 72 65 64 20 64 75  72 69 6e 67 20 63 6f 6d  |urred during com|
00000db0  70 69 6c 61 74 69 6f 6e  3b 20 63 6f 64 65 20 61  |pilation; code a|
00000dc0  73 20 66 6f 6c 6c 6f 77  73 3a 0a 3b 20 2d 31 09  |s follows:.; -1.|
00000dd0  67 65 6e 65 72 61 74 6f  72 20 63 61 6c 6c 65 64  |generator called|
00000de0  20 77 69 74 68 20 30 20  64 69 76 69 73 6f 72 0a  | with 0 divisor.|
00000df0  3b 20 2d 32 09 77 6f 72  6b 20 72 65 67 20 6e 65  |; -2.work reg ne|
00000e00  65 64 65 64 20 62 75 74  20 6e 6f 74 20 73 75 70  |eded but not sup|
00000e10  70 6c 69 65 64 0a 3b 20  2d 33 09 69 6e 76 61 6c  |plied.; -3.inval|
00000e20  69 64 20 72 65 67 69 73  74 65 72 20 6e 75 6d 62  |id register numb|
00000e30  65 72 0a 3b 20 2d 34 09  72 65 67 69 73 74 65 72  |er.; -4.register|
00000e40  20 6e 75 6d 62 65 72 20  63 6c 61 73 68 20 28 74  | number clash (t|
00000e50  68 65 20 72 65 67 69 73  74 65 72 73 20 6d 75 73  |he registers mus|
00000e60  74 20 62 65 20 64 69 73  74 69 6e 63 74 29 0a 3b  |t be distinct).;|
00000e70  20 2d 35 09 70 72 6f 67  72 61 6d 20 65 72 72 6f  | -5.program erro|
00000e80  72 20 2d 20 69 6e 74 65  72 6e 61 6c 20 72 65 63  |r - internal rec|
00000e90  75 72 73 69 6f 6e 20 73  74 61 63 6b 20 65 78 68  |ursion stack exh|
00000ea0  61 75 73 74 65 64 0a 3b  20 2d 36 09 70 72 6f 67  |austed.; -6.prog|
00000eb0  72 61 6d 20 65 72 72 6f  72 20 2d 20 66 61 73 74  |ram error - fast|
00000ec0  64 69 76 61 69 64 20 6c  6f 67 69 63 20 33 0a 3b  |divaid logic 3.;|
00000ed0  0a 3b 20 41 64 64 69 74  69 6f 6e 61 6c 20 6e 6f  |.; Additional no|
00000ee0  74 65 73 3a 0a 3b 09 41  73 73 75 6d 65 73 20 61  |tes:.;.Assumes a|
00000ef0  20 73 75 69 74 61 62 6c  65 20 65 78 74 65 72 6e  | suitable extern|
00000f00  61 6c 20 72 31 33 20 73  74 61 63 6b 20 65 78 69  |al r13 stack exi|
00000f10  73 74 73 2e 0a 3b 0a 0a  63 6f 6e 73 74 09 52 4e  |sts..;..const.RN|
00000f20  09 72 30 0a 63 70 74 72  09 52 4e 09 72 31 0a 6e  |.r0.cptr.RN.r1.n|
00000f30  75 6d 09 52 4e 09 72 32  0a 6f 75 74 71 09 52 4e  |um.RN.r2.outq.RN|
00000f40  09 72 33 0a 6f 75 74 72  09 52 4e 09 72 34 0a 77  |.r3.outr.RN.r4.w|
00000f50  6f 72 6b 09 52 4e 09 72  35 0a 73 69 67 6e 70 72  |ork.RN.r5.signpr|
00000f60  65 73 09 52 4e 09 72 36  0a 74 31 09 52 4e 09 72  |es.RN.r6.t1.RN.r|
00000f70  31 32 0a 66 6e 09 52 4e  09 72 31 31 09 09 09 09  |12.fn.RN.r11....|
00000f80  3b 61 72 67 73 2f 72 65  73 75 6c 74 73 20 74 6f  |;args/results to|
00000f90  2f 66 72 6f 6d 20 73 75  62 72 6f 75 74 73 0a 74  |/from subrouts.t|
00000fa0  32 09 52 4e 09 72 31 30  0a 74 33 09 52 4e 09 72  |2.RN.r10.t3.RN.r|
00000fb0  31 34 0a 74 34 09 52 4e  09 72 39 0a 0a 70 73 09  |14.t4.RN.r9..ps.|
00000fc0  52 4e 09 72 38 0a 70 6d  09 52 4e 09 72 39 0a 0a  |RN.r8.pm.RN.r9..|
00000fd0  73 74 6b 09 52 4e 09 72  37 0a 73 74 6b 6c 09 52  |stk.RN.r7.stkl.R|
00000fe0  4e 09 72 38 0a 0a 6d 5f  76 09 52 4e 09 72 37 0a  |N.r8..m_v.RN.r7.|
00000ff0  6d 5f 69 09 52 4e 09 72  38 0a 6d 5f 6d 09 52 4e  |m_i.RN.r8.m_m.RN|
00001000  09 72 39 0a 6d 5f 72 09  52 4e 09 72 31 30 0a 6d  |.r9.m_r.RN.r10.m|
00001010  5f 6d 69 09 52 4e 09 72  31 31 0a 6d 5f 6d 6c 09  |_mi.RN.r11.m_ml.|
00001020  52 4e 09 72 31 32 0a 6d  5f 6c 69 09 52 4e 09 72  |RN.r12.m_li.RN.r|
00001030  31 34 0a 0a 67 65 6e 09  43 4d 50 09 63 6f 6e 73  |14..gen.CMP.cons|
00001040  74 2c 20 23 30 0a 09 4d  56 4e 45 51 09 72 30 2c  |t, #0..MVNEQ.r0,|
00001050  20 23 30 09 09 09 09 3b  45 52 52 4f 52 3a 20 30  | #0....;ERROR: 0|
00001060  20 64 69 76 69 73 6f 72  0a 09 4d 4f 56 45 51 53  | divisor..MOVEQS|
00001070  09 70 63 2c 20 6c 72 0a  0a 09 53 54 4d 46 44 09  |.pc, lr...STMFD.|
00001080  73 70 21 2c 20 7b 6c 72  7d 0a 0a 09 4d 4f 56 09  |sp!, {lr}...MOV.|
00001090  74 31 2c 20 23 31 0a 09  52 53 42 4d 49 09 63 6f  |t1, #1..RSBMI.co|
000010a0  6e 73 74 2c 20 63 6f 6e  73 74 2c 20 23 30 0a 09  |nst, const, #0..|
000010b0  4d 4f 56 4d 49 09 74 31  2c 20 23 2d 31 0a 09 53  |MOVMI.t1, #-1..S|
000010c0  54 52 09 74 31 2c 20 6e  73 69 67 6e 70 72 65 73  |TR.t1, nsignpres|
000010d0  0a 0a 09 53 54 52 09 63  70 74 72 2c 20 69 6e 69  |...STR.cptr, ini|
000010e0  74 69 61 6c 5f 63 70 74  72 0a 0a 09 4d 4f 56 09  |tial_cptr...MOV.|
000010f0  66 6e 2c 20 63 6f 6e 73  74 0a 09 42 4c 09 70 6f  |fn, const..BL.po|
00001100  77 65 72 6f 66 32 0a 09  53 54 52 09 66 6e 2c 20  |werof2..STR.fn, |
00001110  70 6f 77 65 72 5f 6f 66  5f 32 0a 0a 09 4d 4f 56  |power_of_2...MOV|
00001120  09 66 6e 2c 20 63 6f 6e  73 74 0a 09 42 4c 09 69  |.fn, const..BL.i|
00001130  6d 6f 70 32 0a 09 43 4d  50 09 66 6e 2c 20 23 2d  |mop2..CMP.fn, #-|
00001140  31 0a 09 4c 44 52 4e 45  09 74 31 2c 20 6f 70 31  |1..LDRNE.t1, op1|
00001150  0a 09 4f 52 52 4e 45 09  74 31 2c 20 74 31 2c 20  |..ORRNE.t1, t1, |
00001160  66 6e 09 09 09 3b 69 6e  73 65 72 74 20 6f 70 65  |fn...;insert ope|
00001170  72 61 6e 64 20 32 0a 09  4f 52 52 4e 45 09 74 31  |rand 2..ORRNE.t1|
00001180  2c 20 74 31 2c 20 6f 75  74 72 2c 20 4c 53 4c 20  |, t1, outr, LSL |
00001190  23 31 32 09 09 3b 20 20  20 20 20 20 20 64 65 73  |#12..;       des|
000011a0  74 69 6e 61 74 69 6f 6e  20 72 65 67 0a 09 4f 52  |tination reg..OR|
000011b0  52 4e 45 09 74 31 2c 20  74 31 2c 20 6f 75 74 72  |RNE.t1, t1, outr|
000011c0  2c 20 4c 53 4c 20 23 31  36 09 09 3b 20 20 20 20  |, LSL #16..;    |
000011d0  20 20 20 6f 70 65 72 61  6e 64 20 31 20 72 65 67  |   operand 1 reg|
000011e0  69 73 74 65 72 0a 09 53  54 52 4e 45 09 74 31 2c  |ister..STRNE.t1,|
000011f0  20 6f 70 32 09 09 09 09  3b 6e 6f 74 65 2c 20 6f  | op2....;note, o|
00001200  70 63 6f 64 65 20 26 20  63 6f 6e 64 69 74 69 6f  |pcode & conditio|
00001210  6e 20 77 69 6c 6c 20 62  65 20 61 64 64 65 64 20  |n will be added |
00001220  6c 61 74 65 72 20 28 61  73 20 6e 65 65 64 20 6d  |later (as need m|
00001230  61 6e 79 29 0a 09 4d 4f  56 45 51 09 74 31 2c 20  |any)..MOVEQ.t1, |
00001240  77 6f 72 6b 0a 09 4d 4f  56 4e 45 09 74 31 2c 20  |work..MOVNE.t1, |
00001250  23 2d 31 09 09 09 09 3b  74 31 20 3d 20 63 6f 6e  |#-1....;t1 = con|
00001260  73 74 20 76 61 6c 69 64  20 3f 20 2d 31 20 3a 20  |st valid ? -1 : |
00001270  77 6f 72 6b 20 72 65 67  0a 09 43 4d 50 45 51 09  |work reg..CMPEQ.|
00001280  77 6f 72 6b 2c 20 23 2d  31 0a 09 4d 4f 56 45 51  |work, #-1..MOVEQ|
00001290  09 72 30 2c 20 23 2d 32  0a 09 4c 44 4d 45 51 46  |.r0, #-2..LDMEQF|
000012a0  44 09 73 70 21 2c 20 7b  70 63 7d 5e 09 09 09 3b  |D.sp!, {pc}^...;|
000012b0  45 52 52 4f 52 3a 20 77  6f 72 6b 20 72 65 67 20  |ERROR: work reg |
000012c0  6e 65 65 64 65 64 20 62  75 74 20 6e 6f 74 20 73  |needed but not s|
000012d0  75 70 70 6c 69 65 64 0a  09 4d 4f 56 09 77 6f 72  |upplied..MOV.wor|
000012e0  6b 2c 20 74 31 09 09 09  3b 65 69 74 68 65 72 20  |k, t1...;either |
000012f0  6c 65 61 76 65 20 77 6f  72 6b 20 61 6c 6f 6e 65  |leave work alone|
00001300  2c 20 69 66 20 6e 65 65  64 65 64 2c 20 65 6c 73  |, if needed, els|
00001310  65 20 72 65 73 65 74 20  74 6f 20 2d 31 0a 0a 09  |e reset to -1...|
00001320  43 4d 50 09 6f 75 74 71  2c 20 23 30 0a 09 43 4d  |CMP.outq, #0..CM|
00001330  50 47 45 09 6f 75 74 72  2c 20 23 30 0a 09 43 4d  |PGE.outr, #0..CM|
00001340  50 47 45 09 6e 75 6d 2c  20 23 30 0a 09 43 4d 50  |PGE.num, #0..CMP|
00001350  47 45 09 77 6f 72 6b 2c  20 23 2d 31 0a 09 43 4d  |GE.work, #-1..CM|
00001360  50 47 45 09 73 69 67 6e  70 72 65 73 2c 20 23 2d  |PGE.signpres, #-|
00001370  31 0a 09 4d 4f 56 4c 54  09 72 30 2c 20 23 2d 33  |1..MOVLT.r0, #-3|
00001380  0a 09 4c 44 4d 4c 54 46  44 09 73 70 21 2c 20 7b  |..LDMLTFD.sp!, {|
00001390  70 63 7d 5e 09 09 09 3b  45 52 52 4f 52 3a 20 69  |pc}^...;ERROR: i|
000013a0  6e 76 61 6c 69 64 20 72  65 67 69 73 74 65 72 20  |nvalid register |
000013b0  6e 75 6d 62 65 72 0a 09  43 4d 50 09 6f 75 74 71  |number..CMP.outq|
000013c0  2c 20 23 31 34 0a 09 43  4d 50 4c 45 09 6f 75 74  |, #14..CMPLE.out|
000013d0  72 2c 20 23 31 34 0a 09  43 4d 50 4c 45 09 6e 75  |r, #14..CMPLE.nu|
000013e0  6d 2c 20 23 31 34 0a 09  43 4d 50 4c 45 09 77 6f  |m, #14..CMPLE.wo|
000013f0  72 6b 2c 20 23 31 34 0a  09 43 4d 50 4c 45 09 73  |rk, #14..CMPLE.s|
00001400  69 67 6e 70 72 65 73 2c  20 23 31 34 0a 09 4d 4f  |ignpres, #14..MO|
00001410  56 47 54 09 72 30 2c 20  23 2d 33 0a 09 4c 44 4d  |VGT.r0, #-3..LDM|
00001420  47 54 46 44 09 73 70 21  2c 20 7b 70 63 7d 5e 09  |GTFD.sp!, {pc}^.|
00001430  09 09 3b 45 52 52 4f 52  3a 20 69 6e 76 61 6c 69  |..;ERROR: invali|
00001440  64 20 72 65 67 69 73 74  65 72 20 6e 75 6d 62 65  |d register numbe|
00001450  72 0a 09 43 4d 50 09 6f  75 74 71 2c 20 6f 75 74  |r..CMP.outq, out|
00001460  72 0a 09 43 4d 50 4e 45  09 6f 75 74 71 2c 20 6e  |r..CMPNE.outq, n|
00001470  75 6d 0a 09 43 4d 50 4e  45 09 6f 75 74 72 2c 20  |um..CMPNE.outr, |
00001480  6e 75 6d 0a 09 4d 4f 56  45 51 09 72 30 2c 20 23  |num..MOVEQ.r0, #|
00001490  2d 34 0a 09 4c 44 4d 45  51 46 44 09 73 70 21 2c  |-4..LDMEQFD.sp!,|
000014a0  20 7b 70 63 7d 5e 09 09  09 3b 45 52 52 4f 52 3a  | {pc}^...;ERROR:|
000014b0  20 72 65 67 69 73 74 65  72 20 63 6c 61 73 68 0a  | register clash.|
000014c0  09 43 4d 50 09 6f 75 74  71 2c 20 73 69 67 6e 70  |.CMP.outq, signp|
000014d0  72 65 73 0a 09 43 4d 50  4e 45 09 6f 75 74 72 2c  |res..CMPNE.outr,|
000014e0  20 73 69 67 6e 70 72 65  73 0a 09 43 4d 50 4e 45  | signpres..CMPNE|
000014f0  09 6e 75 6d 2c 20 73 69  67 6e 70 72 65 73 0a 09  |.num, signpres..|
00001500  42 4e 45 09 6c 31 0a 09  43 4d 50 09 73 69 67 6e  |BNE.l1..CMP.sign|
00001510  70 72 65 73 2c 20 23 2d  31 0a 09 4d 4f 56 4e 45  |pres, #-1..MOVNE|
00001520  09 72 30 2c 20 23 2d 34  0a 09 4c 44 4d 4e 45 46  |.r0, #-4..LDMNEF|
00001530  44 09 73 70 21 2c 20 7b  70 63 7d 5e 09 09 09 3b  |D.sp!, {pc}^...;|
00001540  45 52 52 4f 52 3a 20 72  65 67 69 73 74 65 72 20  |ERROR: register |
00001550  63 6c 61 73 68 0a 6c 31  09 43 4d 50 09 6f 75 74  |clash.l1.CMP.out|
00001560  71 2c 20 77 6f 72 6b 0a  09 43 4d 50 4e 45 09 6f  |q, work..CMPNE.o|
00001570  75 74 72 2c 20 77 6f 72  6b 0a 09 43 4d 50 4e 45  |utr, work..CMPNE|
00001580  09 6e 75 6d 2c 20 77 6f  72 6b 0a 09 43 4d 50 4e  |.num, work..CMPN|
00001590  45 09 73 69 67 6e 70 72  65 73 2c 20 77 6f 72 6b  |E.signpres, work|
000015a0  0a 09 42 4e 45 09 6c 32  0a 09 43 4d 50 09 77 6f  |..BNE.l2..CMP.wo|
000015b0  72 6b 2c 20 23 2d 31 0a  09 4d 4f 56 4e 45 09 72  |rk, #-1..MOVNE.r|
000015c0  30 2c 20 23 2d 34 0a 09  4c 44 4d 4e 45 46 44 09  |0, #-4..LDMNEFD.|
000015d0  73 70 21 2c 20 7b 70 63  7d 5e 09 09 09 3b 45 52  |sp!, {pc}^...;ER|
000015e0  52 4f 52 3a 20 72 65 67  69 73 74 65 72 20 63 6c  |ROR: register cl|
000015f0  61 73 68 0a 6c 32 0a 09  43 4d 50 09 63 6f 6e 73  |ash.l2..CMP.cons|
00001600  74 2c 20 23 31 0a 09 42  4e 45 09 6e 6f 74 5f 6f  |t, #1..BNE.not_o|
00001610  6e 65 0a 09 43 4d 50 09  63 70 74 72 2c 20 23 30  |ne..CMP.cptr, #0|
00001620  0a 09 4d 4f 56 45 51 09  72 30 2c 20 23 38 0a 09  |..MOVEQ.r0, #8..|
00001630  4c 44 4d 45 51 46 44 09  73 70 21 2c 20 7b 70 63  |LDMEQFD.sp!, {pc|
00001640  7d 5e 09 09 09 3b 72 65  74 75 72 6e 20 73 69 7a  |}^...;return siz|
00001650  65 20 6f 66 20 63 6f 64  65 20 6e 65 65 64 65 64  |e of code needed|
00001660  20 74 6f 20 64 69 76 69  64 65 20 62 79 20 b1 31  | to divide by .1|
00001670  0a 09 4c 44 52 09 74 31  2c 20 6f 70 5f 6d 6f 76  |..LDR.t1, op_mov|
00001680  5f 30 0a 09 4f 52 52 09  74 31 2c 20 74 31 2c 20  |_0..ORR.t1, t1, |
00001690  6f 75 74 72 2c 20 4c 53  4c 20 23 31 32 0a 09 53  |outr, LSL #12..S|
000016a0  54 52 09 74 31 2c 20 5b  63 70 74 72 5d 2c 20 23  |TR.t1, [cptr], #|
000016b0  34 09 09 09 3b 6d 6f 76  20 6f 75 74 72 2c 20 23  |4...;mov outr, #|
000016c0  30 0a 09 4c 44 52 09 74  32 2c 20 6e 73 69 67 6e  |0..LDR.t2, nsign|
000016d0  70 72 65 73 0a 09 43 4d  50 09 74 32 2c 20 23 31  |pres..CMP.t2, #1|
000016e0  0a 09 4c 44 52 45 51 09  74 31 2c 20 6f 70 5f 6d  |..LDREQ.t1, op_m|
000016f0  6f 76 5f 72 30 0a 09 4c  44 52 4e 45 09 74 31 2c  |ov_r0..LDRNE.t1,|
00001700  20 6f 70 5f 72 73 62 5f  30 0a 09 4f 52 52 09 74  | op_rsb_0..ORR.t|
00001710  31 2c 20 74 31 2c 20 6f  75 74 71 2c 20 4c 53 4c  |1, t1, outq, LSL|
00001720  20 23 31 32 0a 09 4f 52  52 45 51 09 74 31 2c 20  | #12..ORREQ.t1, |
00001730  74 31 2c 20 6e 75 6d 09  09 09 3b 6d 6f 76 20 6f  |t1, num...;mov o|
00001740  75 74 71 2c 20 6e 75 6d  09 09 2d 20 69 66 20 63  |utq, num..- if c|
00001750  6f 6e 73 74 20 3e 20 30  0a 09 4f 52 52 4e 45 09  |onst > 0..ORRNE.|
00001760  74 31 2c 20 74 31 2c 20  6e 75 6d 2c 20 4c 53 4c  |t1, t1, num, LSL|
00001770  20 23 31 36 09 09 3b 72  73 62 20 6f 75 74 71 2c  | #16..;rsb outq,|
00001780  20 6e 75 6d 2c 20 23 30  09 2d 20 69 66 20 63 6f  | num, #0.- if co|
00001790  6e 73 74 20 3c 20 30 0a  09 53 54 52 09 74 31 2c  |nst < 0..STR.t1,|
000017a0  20 5b 63 70 74 72 5d 2c  20 23 34 0a 09 4d 4f 56  | [cptr], #4..MOV|
000017b0  09 72 30 2c 20 23 38 0a  09 4c 44 4d 46 44 09 73  |.r0, #8..LDMFD.s|
000017c0  70 21 2c 20 7b 70 63 7d  5e 09 09 09 3b 72 65 74  |p!, {pc}^...;ret|
000017d0  75 72 6e 20 61 66 74 65  72 20 63 6f 6d 70 69 6c  |urn after compil|
000017e0  69 6e 67 20 63 6f 64 65  20 74 6f 20 64 69 76 69  |ing code to divi|
000017f0  64 65 20 62 79 20 b1 31  0a 6e 6f 74 5f 6f 6e 65  |de by .1.not_one|
00001800  0a 09 43 4d 50 09 73 69  67 6e 70 72 65 73 2c 20  |..CMP.signpres, |
00001810  23 2d 31 0a 09 42 45 51  09 6e 6f 74 5f 73 69 67  |#-1..BEQ.not_sig|
00001820  6e 70 72 65 73 5f 31 0a  09 43 4d 50 09 63 70 74  |npres_1..CMP.cpt|
00001830  72 2c 20 23 30 0a 09 41  44 44 45 51 09 63 70 74  |r, #0..ADDEQ.cpt|
00001840  72 2c 20 63 70 74 72 2c  20 23 38 0a 09 42 45 51  |r, cptr, #8..BEQ|
00001850  09 6e 6f 74 5f 73 69 67  6e 70 72 65 73 5f 31 0a  |.not_signpres_1.|
00001860  09 4c 44 52 09 74 31 2c  20 6f 70 5f 61 6e 64 73  |.LDR.t1, op_ands|
00001870  5f 73 69 67 6e 0a 09 4f  52 52 09 74 31 2c 20 74  |_sign..ORR.t1, t|
00001880  31 2c 20 73 69 67 6e 70  72 65 73 2c 20 4c 53 4c  |1, signpres, LSL|
00001890  20 23 31 32 0a 09 4f 52  52 09 74 31 2c 20 74 31  | #12..ORR.t1, t1|
000018a0  2c 20 6e 75 6d 2c 20 4c  53 4c 20 23 31 36 0a 09  |, num, LSL #16..|
000018b0  53 54 52 09 74 31 2c 20  5b 63 70 74 72 5d 2c 20  |STR.t1, [cptr], |
000018c0  23 34 09 09 09 3b 61 6e  64 73 20 73 69 67 6e 70  |#4...;ands signp|
000018d0  72 65 73 2c 20 6e 75 6d  2c 20 23 26 38 30 30 30  |res, num, #&8000|
000018e0  30 30 30 30 0a 09 4c 44  52 09 74 31 2c 20 6f 70  |0000..LDR.t1, op|
000018f0  5f 72 73 62 6e 65 5f 30  0a 09 4f 52 52 09 74 31  |_rsbne_0..ORR.t1|
00001900  2c 20 74 31 2c 20 6e 75  6d 2c 20 4c 53 4c 20 23  |, t1, num, LSL #|
00001910  31 32 0a 09 4f 52 52 09  74 31 2c 20 74 31 2c 20  |12..ORR.t1, t1, |
00001920  6e 75 6d 2c 20 4c 53 4c  20 23 31 36 0a 09 53 54  |num, LSL #16..ST|
00001930  52 09 74 31 2c 20 5b 63  70 74 72 5d 2c 20 23 34  |R.t1, [cptr], #4|
00001940  09 09 09 3b 72 73 62 6e  65 20 6e 75 6d 2c 20 6e  |...;rsbne num, n|
00001950  75 6d 2c 20 23 30 0a 6e  6f 74 5f 73 69 67 6e 70  |um, #0.not_signp|
00001960  72 65 73 5f 31 0a 09 4c  44 52 09 74 31 2c 20 70  |res_1..LDR.t1, p|
00001970  6f 77 65 72 5f 6f 66 5f  32 0a 09 4d 4f 56 09 74  |ower_of_2..MOV.t|
00001980  32 2c 20 23 31 0a 09 4d  4f 56 09 74 32 2c 20 74  |2, #1..MOV.t2, t|
00001990  32 2c 20 4c 53 4c 20 74  31 0a 09 43 4d 50 09 63  |2, LSL t1..CMP.c|
000019a0  6f 6e 73 74 2c 20 74 32  0a 09 42 4e 45 09 6e 6f  |onst, t2..BNE.no|
000019b0  74 5f 61 5f 70 6f 77 65  72 5f 6f 66 5f 32 0a 09  |t_a_power_of_2..|
000019c0  09 09 09 09 09 3b 68 61  76 65 20 64 69 76 69 73  |.....;have divis|
000019d0  69 6f 6e 20 62 79 20 61  20 70 6f 77 65 72 20 6f  |ion by a power o|
000019e0  66 20 32 0a 09 4c 44 52  09 74 32 2c 20 69 6e 69  |f 2..LDR.t2, ini|
000019f0  74 69 61 6c 5f 63 70 74  72 0a 09 43 4d 50 09 74  |tial_cptr..CMP.t|
00001a00  32 2c 20 23 30 0a 09 41  44 44 45 51 09 63 70 74  |2, #0..ADDEQ.cpt|
00001a10  72 2c 20 63 70 74 72 2c  20 23 38 0a 09 42 45 51  |r, cptr, #8..BEQ|
00001a20  09 6e 6f 77 5f 72 65 73  74 6f 72 65 5f 73 69 67  |.now_restore_sig|
00001a30  6e 73 0a 09 4c 44 52 09  74 32 2c 20 6f 70 5f 6d  |ns..LDR.t2, op_m|
00001a40  6f 76 5f 72 30 0a 09 4f  52 52 09 74 32 2c 20 74  |ov_r0..ORR.t2, t|
00001a50  32 2c 20 6f 75 74 71 2c  20 4c 53 4c 20 23 31 32  |2, outq, LSL #12|
00001a60  0a 09 4f 52 52 09 74 32  2c 20 74 32 2c 20 6e 75  |..ORR.t2, t2, nu|
00001a70  6d 09 09 09 3b 6d 6f 76  20 6f 75 74 71 2c 20 6e  |m...;mov outq, n|
00001a80  75 6d 2c 20 6c 73 6c 20  23 30 0a 09 4f 52 52 09  |um, lsl #0..ORR.|
00001a90  74 32 2c 20 74 32 2c 20  23 32 5f 30 31 20 3c 3c  |t2, t2, #2_01 <<|
00001aa0  20 35 09 09 3b 63 68 61  6e 67 65 64 20 74 6f 20  | 5..;changed to |
00001ab0  6c 73 72 20 23 30 20 28  77 68 69 63 68 20 68 61  |lsr #0 (which ha|
00001ac0  70 70 65 6e 73 20 74 6f  20 6d 65 61 6e 20 6c 73  |ppens to mean ls|
00001ad0  72 20 23 33 32 29 0a 09  4f 52 52 09 74 32 2c 20  |r #32)..ORR.t2, |
00001ae0  74 32 2c 20 74 31 2c 20  4c 53 4c 20 23 37 0a 09  |t2, t1, LSL #7..|
00001af0  53 54 52 09 74 32 2c 20  5b 63 70 74 72 5d 2c 20  |STR.t2, [cptr], |
00001b00  23 34 09 09 09 3b 6d 6f  76 20 6f 75 74 71 2c 20  |#4...;mov outq, |
00001b10  6e 75 6d 2c 20 6c 73 72  20 23 70 6f 77 65 72 5f  |num, lsr #power_|
00001b20  6f 66 5f 32 20 28 73 61  66 65 20 61 73 20 70 6f  |of_2 (safe as po|
00001b30  77 65 72 20 74 77 65 65  6e 20 31 20 26 20 33 31  |wer tween 1 & 31|
00001b40  29 0a 09 4c 44 52 09 74  32 2c 20 6f 70 5f 73 75  |)..LDR.t2, op_su|
00001b50  62 5f 30 5f 30 0a 09 4f  52 52 09 74 32 2c 20 74  |b_0_0..ORR.t2, t|
00001b60  32 2c 20 6f 75 74 72 2c  20 4c 53 4c 20 23 31 32  |2, outr, LSL #12|
00001b70  0a 09 4f 52 52 09 74 32  2c 20 74 32 2c 20 6e 75  |..ORR.t2, t2, nu|
00001b80  6d 2c 20 4c 53 4c 20 23  31 36 0a 09 4f 52 52 09  |m, LSL #16..ORR.|
00001b90  74 32 2c 20 74 32 2c 20  6f 75 74 71 0a 09 4f 52  |t2, t2, outq..OR|
00001ba0  52 09 74 32 2c 20 74 32  2c 20 74 31 2c 20 4c 53  |R.t2, t2, t1, LS|
00001bb0  4c 20 23 37 0a 09 53 54  52 09 74 32 2c 20 5b 63  |L #7..STR.t2, [c|
00001bc0  70 74 72 5d 2c 20 23 34  09 09 09 3b 73 75 62 20  |ptr], #4...;sub |
00001bd0  6f 75 74 72 2c 20 6e 75  6d 2c 20 6f 75 74 71 2c  |outr, num, outq,|
00001be0  20 4c 53 4c 20 23 70 6f  77 65 72 5f 6f 66 5f 32  | LSL #power_of_2|
00001bf0  0a 09 42 09 6e 6f 77 5f  72 65 73 74 6f 72 65 5f  |..B.now_restore_|
00001c00  73 69 67 6e 73 0a 6e 6f  74 5f 61 5f 70 6f 77 65  |signs.not_a_powe|
00001c10  72 5f 6f 66 5f 32 0a 09  4d 4f 56 09 74 31 2c 20  |r_of_2..MOV.t1, |
00001c20  23 30 0a 09 53 54 52 09  74 31 2c 20 73 75 62 66  |#0..STR.t1, subf|
00001c30  6c 61 67 0a 09 43 4d 50  09 77 6f 72 6b 2c 20 23  |lag..CMP.work, #|
00001c40  2d 31 0a 09 42 45 51 09  6e 6f 74 5f 77 6f 72 6b  |-1..BEQ.not_work|
00001c50  5f 31 0a 09 09 09 09 09  09 3b 6e 6f 77 20 77 65  |_1.......;now we|
00001c60  20 68 61 76 65 20 74 6f  20 64 6f 20 6d 65 67 61  | have to do mega|
00001c70  6d 6f 76 20 77 6f 72 6b  2c 20 23 63 6f 6e 73 74  |mov work, #const|
00001c80  20 20 20 2d 20 61 73 73  75 6d 69 6e 67 20 63 6f  |   - assuming co|
00001c90  6e 73 74 3c 3e 30 0a 09  4d 4f 56 09 6d 5f 76 2c  |nst<>0..MOV.m_v,|
00001ca0  20 63 6f 6e 73 74 0a 09  4d 4f 56 09 6d 5f 72 2c  | const..MOV.m_r,|
00001cb0  20 23 30 0a 6d 5f 6c 31  09 54 53 54 09 6d 5f 76  | #0.m_l1.TST.m_v|
00001cc0  2c 20 23 31 0a 09 4d 4f  56 45 51 09 6d 5f 76 2c  |, #1..MOVEQ.m_v,|
00001cd0  20 6d 5f 76 2c 20 52 4f  52 20 23 33 31 0a 09 41  | m_v, ROR #31..A|
00001ce0  44 44 45 51 09 6d 5f 72  2c 20 6d 5f 72 2c 20 23  |DDEQ.m_r, m_r, #|
00001cf0  31 0a 09 42 45 51 09 6d  5f 6c 31 0a 09 53 54 4d  |1..BEQ.m_l1..STM|
00001d00  46 44 09 73 70 21 2c 20  7b 6d 5f 72 7d 09 09 09  |FD.sp!, {m_r}...|
00001d10  3b 74 6f 20 61 6c 6c 6f  77 20 74 32 20 28 3d 6d  |;to allow t2 (=m|
00001d20  5f 72 29 20 74 6f 20 62  65 20 75 73 65 64 20 61  |_r) to be used a|
00001d30  73 20 73 63 72 61 74 63  68 0a 09 4d 4f 56 09 6d  |s scratch..MOV.m|
00001d40  5f 69 2c 20 23 30 0a 09  4d 4f 56 09 6d 5f 6d 2c  |_i, #0..MOV.m_m,|
00001d50  20 23 31 0a 09 4d 4f 56  09 6d 5f 6d 6c 2c 20 23  | #1..MOV.m_ml, #|
00001d60  30 0a 6d 5f 6c 32 09 41  44 44 09 6d 5f 69 2c 20  |0.m_l2.ADD.m_i, |
00001d70  6d 5f 69 2c 20 23 31 0a  09 4d 4f 56 09 6d 5f 6d  |m_i, #1..MOV.m_m|
00001d80  2c 20 6d 5f 6d 2c 20 4c  53 4c 20 23 31 0a 09 54  |, m_m, LSL #1..T|
00001d90  53 54 09 6d 5f 76 2c 20  6d 5f 6d 0a 09 43 4d 50  |ST.m_v, m_m..CMP|
00001da0  4e 45 09 6d 5f 69 2c 20  23 33 32 0a 09 42 4e 45  |NE.m_i, #32..BNE|
00001db0  09 6d 5f 6c 32 0a 09 43  4d 50 09 6d 5f 69 2c 20  |.m_l2..CMP.m_i, |
00001dc0  23 33 32 0a 09 42 47 45  09 6d 5f 6c 33 0a 09 4d  |#32..BGE.m_l3..M|
00001dd0  4f 56 09 6d 5f 6c 69 2c  20 6d 5f 69 0a 6d 5f 6c  |OV.m_li, m_i.m_l|
00001de0  34 09 41 44 44 09 6d 5f  69 2c 20 6d 5f 69 2c 20  |4.ADD.m_i, m_i, |
00001df0  23 31 0a 09 4d 4f 56 09  6d 5f 6d 2c 20 6d 5f 6d  |#1..MOV.m_m, m_m|
00001e00  2c 20 4c 53 4c 20 23 31  0a 09 54 53 54 09 6d 5f  |, LSL #1..TST.m_|
00001e10  76 2c 20 6d 5f 6d 0a 09  42 4e 45 09 6d 5f 6c 35  |v, m_m..BNE.m_l5|
00001e20  0a 09 43 4d 50 09 6d 5f  69 2c 20 23 33 32 0a 09  |..CMP.m_i, #32..|
00001e30  42 4e 45 09 6d 5f 6c 34  0a 6d 5f 6c 35 09 53 55  |BNE.m_l4.m_l5.SU|
00001e40  42 09 74 32 2c 20 6d 5f  69 2c 20 6d 5f 6c 69 0a  |B.t2, m_i, m_li.|
00001e50  09 43 4d 50 09 74 32 2c  20 6d 5f 6d 6c 0a 09 4d  |.CMP.t2, m_ml..M|
00001e60  4f 56 47 54 09 6d 5f 6d  69 2c 20 6d 5f 6c 69 0a  |OVGT.m_mi, m_li.|
00001e70  09 4d 4f 56 47 54 09 6d  5f 6d 6c 2c 20 74 32 0a  |.MOVGT.m_ml, t2.|
00001e80  09 43 4d 50 09 6d 5f 69  2c 20 23 33 32 0a 09 42  |.CMP.m_i, #32..B|
00001e90  4c 54 09 6d 5f 6c 32 0a  6d 5f 6c 33 09 4c 44 4d  |LT.m_l2.m_l3.LDM|
00001ea0  46 44 09 73 70 21 2c 20  7b 6d 5f 72 7d 09 09 09  |FD.sp!, {m_r}...|
00001eb0  3b 61 6c 73 6f 20 6e 6f  74 65 20 6d 5f 6c 69 20  |;also note m_li |
00001ec0  6e 6f 77 20 66 72 65 65  20 73 6f 20 63 61 6e 20  |now free so can |
00001ed0  72 65 73 75 6d 65 20 75  73 65 20 6f 66 20 74 33  |resume use of t3|
00001ee0  20 28 3d 6d 5f 6c 69 29  0a 09 43 4d 50 09 6d 5f  | (=m_li)..CMP.m_|
00001ef0  6d 6c 2c 20 23 30 0a 09  41 44 44 47 54 09 6d 5f  |ml, #0..ADDGT.m_|
00001f00  69 2c 20 6d 5f 6d 69 2c  20 6d 5f 6d 6c 0a 09 4d  |i, m_mi, m_ml..M|
00001f10  4f 56 47 54 09 6d 5f 76  2c 20 6d 5f 76 2c 20 52  |OVGT.m_v, m_v, R|
00001f20  4f 52 20 6d 5f 69 0a 09  52 53 42 47 54 09 6d 5f  |OR m_i..RSBGT.m_|
00001f30  69 2c 20 6d 5f 69 2c 20  23 33 32 0a 09 41 44 44  |i, m_i, #32..ADD|
00001f40  47 54 09 6d 5f 72 2c 20  6d 5f 72 2c 20 6d 5f 69  |GT.m_r, m_r, m_i|
00001f50  0a 09 54 53 54 09 6d 5f  72 2c 20 23 31 0a 09 4d  |..TST.m_r, #1..M|
00001f60  4f 56 4e 45 09 6d 5f 76  2c 20 6d 5f 76 2c 20 52  |OVNE.m_v, m_v, R|
00001f70  4f 52 20 23 33 31 0a 09  41 44 44 4e 45 09 6d 5f  |OR #31..ADDNE.m_|
00001f80  72 2c 20 6d 5f 72 2c 20  23 31 0a 0a 09 41 4e 44  |r, m_r, #1...AND|
00001f90  09 6d 5f 72 2c 20 6d 5f  72 2c 20 23 33 31 0a 09  |.m_r, m_r, #31..|
00001fa0  41 4e 44 09 6d 5f 69 2c  20 6d 5f 76 2c 20 23 32  |AND.m_i, m_v, #2|
00001fb0  35 35 0a 09 4c 44 52 09  74 31 2c 20 69 6e 69 74  |55..LDR.t1, init|
00001fc0  69 61 6c 5f 63 70 74 72  0a 09 43 4d 50 09 74 31  |ial_cptr..CMP.t1|
00001fd0  2c 20 23 30 0a 09 41 44  44 45 51 09 63 70 74 72  |, #0..ADDEQ.cptr|
00001fe0  2c 20 63 70 74 72 2c 20  23 34 0a 09 4c 44 52 4e  |, cptr, #4..LDRN|
00001ff0  45 09 74 33 2c 20 6f 70  5f 6d 6f 76 5f 30 0a 09  |E.t3, op_mov_0..|
00002000  4f 52 52 4e 45 09 74 33  2c 20 74 33 2c 20 77 6f  |ORRNE.t3, t3, wo|
00002010  72 6b 2c 20 4c 53 4c 20  23 31 32 0a 09 4f 52 52  |rk, LSL #12..ORR|
00002020  4e 45 09 74 33 2c 20 74  33 2c 20 6d 5f 72 2c 20  |NE.t3, t3, m_r, |
00002030  4c 53 4c 20 23 38 2d 31  0a 09 4f 52 52 4e 45 09  |LSL #8-1..ORRNE.|
00002040  74 33 2c 20 74 33 2c 20  6d 5f 69 0a 09 53 54 52  |t3, t3, m_i..STR|
00002050  4e 45 09 74 33 2c 20 5b  63 70 74 72 5d 2c 20 23  |NE.t3, [cptr], #|
00002060  34 09 09 09 3b 6d 6f 76  20 77 6f 72 6b 2c 20 23  |4...;mov work, #|
00002070  6d 5f 69 20 72 6f 72 20  6d 5f 72 0a 6d 5f 6c 36  |m_i ror m_r.m_l6|
00002080  0a 09 4d 4f 56 53 09 6d  5f 76 2c 20 6d 5f 76 2c  |..MOVS.m_v, m_v,|
00002090  20 4c 53 52 20 23 38 0a  09 42 45 51 09 6e 6f 74  | LSR #8..BEQ.not|
000020a0  5f 77 6f 72 6b 5f 31 0a  09 53 55 42 09 6d 5f 72  |_work_1..SUB.m_r|
000020b0  2c 20 6d 5f 72 2c 20 23  38 0a 09 41 4e 44 09 6d  |, m_r, #8..AND.m|
000020c0  5f 72 2c 20 6d 5f 72 2c  20 23 33 31 0a 09 41 4e  |_r, m_r, #31..AN|
000020d0  44 53 09 6d 5f 69 2c 20  6d 5f 76 2c 20 23 32 35  |DS.m_i, m_v, #25|
000020e0  35 0a 09 42 45 51 09 6d  5f 6c 36 0a 09 43 4d 50  |5..BEQ.m_l6..CMP|
000020f0  09 74 31 2c 20 23 30 0a  09 41 44 44 45 51 09 63  |.t1, #0..ADDEQ.c|
00002100  70 74 72 2c 20 63 70 74  72 2c 20 23 34 0a 09 4c  |ptr, cptr, #4..L|
00002110  44 52 4e 45 09 74 33 2c  20 6f 70 5f 6f 72 72 5f  |DRNE.t3, op_orr_|
00002120  30 0a 09 4f 52 52 4e 45  09 74 33 2c 20 74 33 2c  |0..ORRNE.t3, t3,|
00002130  20 77 6f 72 6b 2c 20 4c  53 4c 20 23 31 32 0a 09  | work, LSL #12..|
00002140  4f 52 52 4e 45 09 74 33  2c 20 74 33 2c 20 77 6f  |ORRNE.t3, t3, wo|
00002150  72 6b 2c 20 4c 53 4c 20  23 31 36 0a 09 4f 52 52  |rk, LSL #16..ORR|
00002160  4e 45 09 74 33 2c 20 74  33 2c 20 6d 5f 72 2c 20  |NE.t3, t3, m_r, |
00002170  4c 53 4c 20 23 38 2d 31  0a 09 4f 52 52 4e 45 09  |LSL #8-1..ORRNE.|
00002180  74 33 2c 20 74 33 2c 20  6d 5f 69 0a 09 53 54 52  |t3, t3, m_i..STR|
00002190  4e 45 09 74 33 2c 20 5b  63 70 74 72 5d 2c 20 23  |NE.t3, [cptr], #|
000021a0  34 09 09 09 3b 6f 72 72  20 77 6f 72 6b 2c 20 77  |4...;orr work, w|
000021b0  6f 72 6b 2c 20 23 6d 5f  69 20 72 6f 72 20 6d 5f  |ork, #m_i ror m_|
000021c0  72 0a 09 42 09 6d 5f 6c  36 0a 6e 6f 74 5f 77 6f  |r..B.m_l6.not_wo|
000021d0  72 6b 5f 31 0a 09 4c 44  52 09 74 32 2c 20 70 6f  |rk_1..LDR.t2, po|
000021e0  77 65 72 5f 6f 66 5f 32  0a 09 53 54 52 09 74 32  |wer_of_2..STR.t2|
000021f0  2c 20 6e 70 6f 77 65 72  5f 6f 66 5f 32 0a 09 4d  |, npower_of_2..M|
00002200  4f 56 09 63 6f 6e 73 74  2c 20 63 6f 6e 73 74 2c  |OV.const, const,|
00002210  20 4c 53 52 20 74 32 0a  0a 09 4d 4f 56 09 74 31  | LSR t2...MOV.t1|
00002220  2c 20 23 31 0a 09 4d 4f  56 09 70 73 2c 20 23 30  |, #1..MOV.ps, #0|
00002230  09 09 09 09 3b 73 25 20  69 6e 20 42 61 73 69 63  |....;s% in Basic|
00002240  20 76 65 72 73 69 6f 6e  0a 09 4d 4f 56 09 70 6d  | version..MOV.pm|
00002250  2c 20 23 30 09 09 09 09  3b 6d 25 20 69 6e 20 42  |, #0....;m% in B|
00002260  61 73 69 63 20 76 65 72  73 69 6f 6e 0a 63 61 6c  |asic version.cal|
00002270  63 5f 72 65 70 65 61 74  0a 09 43 4d 50 09 74 31  |c_repeat..CMP.t1|
00002280  2c 20 63 6f 6e 73 74 0a  09 53 55 42 47 45 09 74  |, const..SUBGE.t|
00002290  31 2c 20 74 31 2c 20 63  6f 6e 73 74 0a 09 41 44  |1, t1, const..AD|
000022a0  44 47 45 09 70 73 2c 20  70 73 2c 20 23 31 0a 09  |DGE.ps, ps, #1..|
000022b0  43 4d 50 09 74 31 2c 20  23 30 0a 09 42 45 51 09  |CMP.t1, #0..BEQ.|
000022c0  72 65 70 65 61 74 5f 63  61 6c 63 64 0a 09 41 44  |repeat_calcd..AD|
000022d0  43 09 74 31 2c 20 74 31  2c 20 74 31 09 09 09 3b  |C.t1, t1, t1...;|
000022e0  6e 62 20 61 62 6f 76 65  20 43 4d 50 20 65 6e 73  |nb above CMP ens|
000022f0  75 72 65 73 20 43 20 61  6c 77 61 79 73 20 73 65  |ures C always se|
00002300  74 2c 20 73 6f 20 74 68  69 73 20 69 73 20 74 31  |t, so this is t1|
00002310  3d 32 2a 74 31 2b 31 0a  09 4d 4f 56 09 70 73 2c  |=2*t1+1..MOV.ps,|
00002320  20 70 73 2c 20 4c 53 4c  20 23 31 0a 09 41 44 44  | ps, LSL #1..ADD|
00002330  09 70 6d 2c 20 70 6d 2c  20 23 31 0a 09 43 4d 50  |.pm, pm, #1..CMP|
00002340  09 70 6d 2c 20 23 33 32  0a 09 42 4c 45 09 63 61  |.pm, #32..BLE.ca|
00002350  6c 63 5f 72 65 70 65 61  74 0a 72 65 70 65 61 74  |lc_repeat.repeat|
00002360  5f 63 61 6c 63 64 0a 09  4d 4f 56 09 66 6e 2c 20  |_calcd..MOV.fn, |
00002370  70 73 0a 09 42 4c 09 70  6f 77 65 72 6f 66 32 0a  |ps..BL.powerof2.|
00002380  09 53 55 42 09 74 32 2c  20 74 32 2c 20 66 6e 0a  |.SUB.t2, t2, fn.|
00002390  09 4d 4f 56 09 70 73 2c  20 70 73 2c 20 4c 53 52  |.MOV.ps, ps, LSR|
000023a0  20 66 6e 0a 09 53 54 52  09 74 32 2c 20 70 6f 77  | fn..STR.t2, pow|
000023b0  65 72 5f 6f 66 5f 32 0a  09 43 4d 50 09 70 73 2c  |er_of_2..CMP.ps,|
000023c0  20 23 31 0a 09 42 45 51  09 73 5f 61 70 70 6c 69  | #1..BEQ.s_appli|
000023d0  65 64 0a 09 53 54 52 09  70 73 2c 20 61 73 0a 09  |ed..STR.ps, as..|
000023e0  53 54 52 09 70 6d 2c 20  61 6d 0a 09 4d 4f 56 09  |STR.pm, am..MOV.|
000023f0  66 6e 2c 20 70 73 0a 09  41 44 52 09 73 74 6b 2c  |fn, ps..ADR.stk,|
00002400  20 61 73 74 6b 0a 09 41  44 52 09 73 74 6b 6c 2c  | astk..ADR.stkl,|
00002410  20 61 73 74 6b 5f 65 6e  64 0a 09 4c 44 52 09 74  | astk_end..LDR.t|
00002420  31 2c 20 6f 70 5f 61 64  64 5f 30 5f 30 09 09 09  |1, op_add_0_0...|
00002430  3b 63 61 6c 63 20 69 6e  74 65 72 6d 65 64 69 61  |;calc intermedia|
00002440  74 65 20 69 6e 73 74 72  75 63 74 69 6f 6e 73 20  |te instructions |
00002450  75 73 65 64 20 62 79 20  66 61 73 74 64 69 76 61  |used by fastdiva|
00002460  69 64 0a 09 4f 52 52 09  74 34 2c 20 6e 75 6d 2c  |id..ORR.t4, num,|
00002470  20 6e 75 6d 2c 20 4c 53  4c 20 23 31 36 0a 09 4f  | num, LSL #16..O|
00002480  52 52 09 74 34 2c 20 74  34 2c 20 6f 75 74 71 2c  |RR.t4, t4, outq,|
00002490  20 4c 53 4c 20 23 31 32  09 09 3b 64 61 74 61 20  | LSL #12..;data |
000024a0  70 72 6f 63 65 73 73 69  6e 67 20 61 72 67 73 20  |processing args |
000024b0  6f 75 74 71 2c 20 6e 75  6d 2c 20 6e 75 6d 0a 09  |outq, num, num..|
000024c0  4f 52 52 09 74 31 2c 20  74 31 2c 20 74 34 0a 09  |ORR.t1, t1, t4..|
000024d0  53 54 52 09 74 31 2c 20  6f 70 5f 66 64 31 09 09  |STR.t1, op_fd1..|
000024e0  09 3b 61 64 64 20 6f 75  74 71 2c 20 6e 75 6d 2c  |.;add outq, num,|
000024f0  20 6e 75 6d 0a 09 4c 44  52 09 74 31 2c 20 6f 70  | num..LDR.t1, op|
00002500  5f 61 64 64 5f 30 5f 30  5f 6c 73 72 0a 09 4f 52  |_add_0_0_lsr..OR|
00002510  52 09 74 34 2c 20 74 31  2c 20 74 34 0a 09 53 54  |R.t4, t1, t4..ST|
00002520  52 09 74 34 2c 20 6f 70  5f 66 64 33 09 09 09 3b  |R.t4, op_fd3...;|
00002530  61 64 64 20 6f 75 74 71  2c 20 6e 75 6d 2c 20 6e  |add outq, num, n|
00002540  75 6d 2c 20 6c 73 72 20  23 33 32 0a 09 4f 52 52  |um, lsr #32..ORR|
00002550  09 74 34 2c 20 6e 75 6d  2c 20 6f 75 74 71 2c 20  |.t4, num, outq, |
00002560  4c 53 4c 20 23 31 36 0a  09 4f 52 52 09 74 34 2c  |LSL #16..ORR.t4,|
00002570  20 74 34 2c 20 6f 75 74  71 2c 20 4c 53 4c 20 23  | t4, outq, LSL #|
00002580  31 32 09 09 3b 20 20 20  20 20 20 20 20 20 20 20  |12..;           |
00002590  20 20 20 20 20 61 72 67  73 20 6f 75 74 71 2c 20  |     args outq, |
000025a0  6f 75 74 71 2c 20 6e 75  6d 0a 09 4f 52 52 09 74  |outq, num..ORR.t|
000025b0  31 2c 20 74 31 2c 20 74  34 0a 09 53 54 52 09 74  |1, t1, t4..STR.t|
000025c0  31 2c 20 6f 70 5f 66 64  34 09 09 09 3b 61 64 64  |1, op_fd4...;add|
000025d0  20 6f 75 74 71 2c 20 6f  75 74 71 2c 20 6e 75 6d  | outq, outq, num|
000025e0  2c 20 6c 73 72 20 23 33  32 0a 09 4c 44 52 09 74  |, lsr #32..LDR.t|
000025f0  31 2c 20 6f 70 5f 73 75  62 5f 30 5f 30 5f 6c 73  |1, op_sub_0_0_ls|
00002600  72 0a 09 4f 52 52 09 74  31 2c 20 74 31 2c 20 74  |r..ORR.t1, t1, t|
00002610  34 0a 09 53 54 52 09 74  31 2c 20 6f 70 5f 66 64  |4..STR.t1, op_fd|
00002620  32 09 09 09 3b 73 75 62  20 6f 75 74 71 2c 20 6f  |2...;sub outq, o|
00002630  75 74 71 2c 20 6e 75 6d  2c 20 6c 73 72 20 23 33  |utq, num, lsr #3|
00002640  32 0a 09 42 4c 09 66 61  73 74 64 69 76 61 69 64  |2..BL.fastdivaid|
00002650  0a 09 4c 44 52 09 70 73  2c 20 61 73 0a 09 4c 44  |..LDR.ps, as..LD|
00002660  52 09 70 6d 2c 20 61 6d  0a 73 5f 61 70 70 6c 69  |R.pm, am.s_appli|
00002670  65 64 09 09 09 09 09 3b  6e 62 20 74 32 3d 70 6f  |ed.....;nb t2=po|
00002680  77 65 72 5f 6f 66 5f 32  20 6d 61 79 20 6e 6f 20  |wer_of_2 may no |
00002690  6c 6f 6e 67 65 72 20 62  65 20 76 61 6c 69 64 2c  |longer be valid,|
000026a0  20 62 75 74 20 70 73 20  26 20 70 6d 20 61 72 65  | but ps & pm are|
000026b0  0a 09 4d 4f 56 09 66 6e  2c 20 70 73 0a 09 42 4c  |..MOV.fn, ps..BL|
000026c0  09 62 69 74 70 61 74 6c  65 6e 09 09 09 3b 66 6e  |.bitpatlen...;fn|
000026d0  20 69 73 20 6e 6f 77 20  6c 73 25 0a 09 41 44 44  | is now ls%..ADD|
000026e0  09 74 31 2c 20 70 6d 2c  20 23 31 0a 09 4c 44 52  |.t1, pm, #1..LDR|
000026f0  09 74 32 2c 20 69 6e 69  74 69 61 6c 5f 63 70 74  |.t2, initial_cpt|
00002700  72 0a 09 43 4d 50 09 74  32 2c 20 23 30 0a 09 42  |r..CMP.t2, #0..B|
00002710  4e 45 09 64 6f 5f 65 78  74 65 6e 64 0a 09 43 4d  |NE.do_extend..CM|
00002720  50 09 74 31 2c 20 23 33  32 0a 09 42 47 45 09 62  |P.t1, #32..BGE.b|
00002730  69 74 73 5f 65 78 74 65  6e 64 65 64 0a 09 43 4d  |its_extended..CM|
00002740  50 09 70 73 2c 20 23 31  0a 09 4d 4f 56 45 51 09  |P.ps, #1..MOVEQ.|
00002750  70 73 2c 20 23 30 0a 70  73 65 75 64 6f 5f 65 78  |ps, #0.pseudo_ex|
00002760  74 65 6e 64 5f 62 69 74  73 5f 6c 6f 6f 70 0a 09  |tend_bits_loop..|
00002770  41 44 44 09 63 70 74 72  2c 20 63 70 74 72 2c 20  |ADD.cptr, cptr, |
00002780  23 34 0a 09 4d 4f 56 09  74 31 2c 20 74 31 2c 20  |#4..MOV.t1, t1, |
00002790  4c 53 4c 20 23 31 0a 09  43 4d 50 09 74 31 2c 20  |LSL #1..CMP.t1, |
000027a0  23 33 32 0a 09 42 4c 54  09 70 73 65 75 64 6f 5f  |#32..BLT.pseudo_|
000027b0  65 78 74 65 6e 64 5f 62  69 74 73 5f 6c 6f 6f 70  |extend_bits_loop|
000027c0  0a 09 42 09 62 69 74 73  5f 65 78 74 65 6e 64 65  |..B.bits_extende|
000027d0  64 0a 64 6f 5f 65 78 74  65 6e 64 0a 09 43 4d 50  |d.do_extend..CMP|
000027e0  09 74 31 2c 20 23 33 32  0a 09 42 47 45 09 62 69  |.t1, #32..BGE.bi|
000027f0  74 73 5f 65 78 74 65 6e  64 65 64 0a 09 4c 44 52  |ts_extended..LDR|
00002800  09 74 33 2c 20 6f 70 5f  61 64 64 5f 30 5f 30 5f  |.t3, op_add_0_0_|
00002810  6c 73 72 0a 09 4f 52 52  09 74 33 2c 20 74 33 2c  |lsr..ORR.t3, t3,|
00002820  20 6f 75 74 71 2c 20 4c  53 4c 20 23 31 32 0a 09  | outq, LSL #12..|
00002830  43 4d 50 09 70 73 2c 20  23 31 0a 09 4d 4f 56 45  |CMP.ps, #1..MOVE|
00002840  51 09 70 73 2c 20 23 30  0a 09 4f 52 52 45 51 09  |Q.ps, #0..ORREQ.|
00002850  74 32 2c 20 6e 75 6d 2c  20 6e 75 6d 2c 20 4c 53  |t2, num, num, LS|
00002860  4c 20 23 31 36 0a 09 4f  52 52 4e 45 09 74 32 2c  |L #16..ORRNE.t2,|
00002870  20 6f 75 74 71 2c 20 6f  75 74 71 2c 20 4c 53 4c  | outq, outq, LSL|
00002880  20 23 31 36 0a 09 4f 52  52 09 74 32 2c 20 74 32  | #16..ORR.t2, t2|
00002890  2c 20 74 31 2c 20 4c 53  4c 20 23 37 0a 09 4f 52  |, t1, LSL #7..OR|
000028a0  52 09 74 32 2c 20 74 33  2c 20 74 32 09 09 09 3b  |R.t2, t3, t2...;|
000028b0  69 66 20 45 51 20 27 61  64 64 20 6f 75 74 71 2c  |if EQ 'add outq,|
000028c0  20 6e 75 6d 2c 20 6e 75  6d 2c 20 6c 73 72 20 23  | num, num, lsr #|
000028d0  74 31 25 27 0a 09 53 54  52 09 74 32 2c 20 5b 63  |t1%'..STR.t2, [c|
000028e0  70 74 72 5d 2c 20 23 34  09 09 09 3b 65 6c 73 65  |ptr], #4...;else|
000028f0  20 20 27 61 64 64 20 6f  75 74 71 2c 20 6f 75 74  |  'add outq, out|
00002900  71 2c 20 6f 75 74 71 2c  20 6c 73 72 20 23 74 31  |q, outq, lsr #t1|
00002910  25 27 0a 09 4d 4f 56 09  74 31 2c 20 74 31 2c 20  |%'..MOV.t1, t1, |
00002920  4c 53 4c 20 23 31 0a 09  43 4d 50 09 74 31 2c 20  |LSL #1..CMP.t1, |
00002930  23 33 32 0a 09 42 47 45  09 62 69 74 73 5f 65 78  |#32..BGE.bits_ex|
00002940  74 65 6e 64 65 64 0a 09  4f 52 52 09 74 32 2c 20  |tended..ORR.t2, |
00002950  6f 75 74 71 2c 20 6f 75  74 71 2c 20 4c 53 4c 20  |outq, outq, LSL |
00002960  23 31 36 0a 09 4f 52 52  09 74 33 2c 20 74 33 2c  |#16..ORR.t3, t3,|
00002970  20 74 32 0a 65 78 74 65  6e 64 5f 62 69 74 73 5f  | t2.extend_bits_|
00002980  6c 6f 6f 70 0a 09 4f 52  52 09 74 32 2c 20 74 33  |loop..ORR.t2, t3|
00002990  2c 20 74 31 2c 20 4c 53  4c 20 23 37 0a 09 53 54  |, t1, LSL #7..ST|
000029a0  52 09 74 32 2c 20 5b 63  70 74 72 5d 2c 20 23 34  |R.t2, [cptr], #4|
000029b0  09 09 09 3b 61 64 64 20  6f 75 74 71 2c 20 6f 75  |...;add outq, ou|
000029c0  74 71 2c 20 6f 75 74 71  2c 20 6c 73 72 20 23 74  |tq, outq, lsr #t|
000029d0  31 25 0a 09 4d 4f 56 09  74 31 2c 20 74 31 2c 20  |1%..MOV.t1, t1, |
000029e0  4c 53 4c 20 23 31 0a 09  43 4d 50 09 74 31 2c 20  |LSL #1..CMP.t1, |
000029f0  23 33 32 0a 09 42 4c 54  09 65 78 74 65 6e 64 5f  |#32..BLT.extend_|
00002a00  62 69 74 73 5f 6c 6f 6f  70 0a 62 69 74 73 5f 65  |bits_loop.bits_e|
00002a10  78 74 65 6e 64 65 64 0a  09 4c 44 52 09 74 31 2c  |xtended..LDR.t1,|
00002a20  20 69 6e 69 74 69 61 6c  5f 63 70 74 72 0a 09 43  | initial_cptr..C|
00002a30  4d 50 09 70 73 2c 20 23  31 0a 09 42 4e 45 09 6c  |MP.ps, #1..BNE.l|
00002a40  61 72 67 65 5f 64 69 76  5f 70 61 74 63 68 5f 64  |arge_div_patch_d|
00002a50  6f 6e 65 0a 09 43 4d 50  09 74 31 2c 20 23 30 0a  |one..CMP.t1, #0.|
00002a60  09 41 44 44 45 51 09 63  70 74 72 2c 20 63 70 74  |.ADDEQ.cptr, cpt|
00002a70  72 2c 20 23 34 0a 09 4c  44 52 4e 45 09 74 32 2c  |r, #4..LDRNE.t2,|
00002a80  20 6f 70 5f 6d 6f 76 5f  72 30 0a 09 4f 52 52 4e  | op_mov_r0..ORRN|
00002a90  45 09 74 32 2c 20 74 32  2c 20 6f 75 74 71 2c 20  |E.t2, t2, outq, |
00002aa0  4c 53 4c 20 23 31 32 0a  09 4f 52 52 4e 45 09 74  |LSL #12..ORRNE.t|
00002ab0  32 2c 20 74 32 2c 20 6e  75 6d 0a 09 53 54 52 4e  |2, t2, num..STRN|
00002ac0  45 09 74 32 2c 20 5b 63  70 74 72 5d 2c 20 23 34  |E.t2, [cptr], #4|
00002ad0  09 09 09 3b 6d 6f 76 20  6f 75 74 71 2c 20 6e 75  |...;mov outq, nu|
00002ae0  6d 0a 6c 61 72 67 65 5f  64 69 76 5f 70 61 74 63  |m.large_div_patc|
00002af0  68 5f 64 6f 6e 65 0a 09  4c 44 52 09 74 33 2c 20  |h_done..LDR.t3, |
00002b00  70 6f 77 65 72 5f 6f 66  5f 32 0a 09 41 44 44 09  |power_of_2..ADD.|
00002b10  74 33 2c 20 74 33 2c 20  70 6d 0a 09 53 55 42 09  |t3, t3, pm..SUB.|
00002b20  74 33 2c 20 74 33 2c 20  66 6e 0a 09 41 44 44 53  |t3, t3, fn..ADDS|
00002b30  09 74 33 2c 20 74 33 2c  20 23 32 0a 09 42 4c 45  |.t3, t3, #2..BLE|
00002b40  09 66 69 6e 61 6c 5f 73  68 69 66 74 5f 64 6f 6e  |.final_shift_don|
00002b50  65 0a 09 43 4d 50 09 74  31 2c 20 23 30 0a 09 41  |e..CMP.t1, #0..A|
00002b60  44 44 45 51 09 63 70 74  72 2c 20 63 70 74 72 2c  |DDEQ.cptr, cptr,|
00002b70  20 23 34 0a 09 4c 44 52  4e 45 09 74 32 2c 20 6f  | #4..LDRNE.t2, o|
00002b80  70 5f 6d 6f 76 5f 72 30  5f 6c 73 72 0a 09 4f 52  |p_mov_r0_lsr..OR|
00002b90  52 4e 45 09 74 32 2c 20  74 32 2c 20 6f 75 74 71  |RNE.t2, t2, outq|
00002ba0  2c 20 4c 53 4c 20 23 31  32 0a 09 4f 52 52 4e 45  |, LSL #12..ORRNE|
00002bb0  09 74 32 2c 20 74 32 2c  20 6f 75 74 71 0a 09 4f  |.t2, t2, outq..O|
00002bc0  52 52 4e 45 09 74 32 2c  20 74 32 2c 20 74 33 2c  |RRNE.t2, t2, t3,|
00002bd0  20 4c 53 4c 20 23 37 0a  09 53 54 52 4e 45 09 74  | LSL #7..STRNE.t|
00002be0  32 2c 20 5b 63 70 74 72  5d 2c 20 23 34 09 09 09  |2, [cptr], #4...|
00002bf0  3b 6d 6f 76 20 6f 75 74  71 2c 20 6f 75 74 71 2c  |;mov outq, outq,|
00002c00  20 6c 73 72 20 23 70 6f  77 65 72 5f 6f 66 5f 32  | lsr #power_of_2|
00002c10  0a 66 69 6e 61 6c 5f 73  68 69 66 74 5f 64 6f 6e  |.final_shift_don|
00002c20  65 0a 09 4d 4f 56 09 66  6e 2c 20 63 6f 6e 73 74  |e..MOV.fn, const|
00002c30  0a 09 41 44 52 09 73 74  6b 2c 20 61 73 74 6b 0a  |..ADR.stk, astk.|
00002c40  09 41 44 52 09 73 74 6b  6c 2c 20 61 73 74 6b 5f  |.ADR.stkl, astk_|
00002c50  65 6e 64 0a 09 4f 52 52  09 74 31 2c 20 6f 75 74  |end..ORR.t1, out|
00002c60  71 2c 20 6f 75 74 71 2c  20 4c 53 4c 20 23 31 36  |q, outq, LSL #16|
00002c70  09 09 3b 63 61 6c 63 20  69 6e 74 65 72 6d 65 64  |..;calc intermed|
00002c80  69 61 74 65 20 69 6e 73  74 72 75 63 74 69 6f 6e  |iate instruction|
00002c90  73 20 75 73 65 64 20 62  79 20 66 61 73 74 6d 75  |s used by fastmu|
00002ca0  6c 0a 09 4f 52 52 09 74  31 2c 20 74 31 2c 20 6f  |l..ORR.t1, t1, o|
00002cb0  75 74 72 2c 20 4c 53 4c  20 23 31 32 0a 09 4f 52  |utr, LSL #12..OR|
00002cc0  52 09 74 32 2c 20 6f 75  74 72 2c 20 6f 75 74 71  |R.t2, outr, outq|
00002cd0  2c 20 4c 53 4c 20 23 31  36 0a 09 4f 52 52 09 74  |, LSL #16..ORR.t|
00002ce0  32 2c 20 74 32 2c 20 6f  75 74 72 2c 20 4c 53 4c  |2, t2, outr, LSL|
00002cf0  20 23 31 32 0a 09 4c 44  52 09 74 33 2c 20 6f 70  | #12..LDR.t3, op|
00002d00  5f 6d 6f 76 5f 72 30 0a  09 4f 52 52 09 74 34 2c  |_mov_r0..ORR.t4,|
00002d10  20 74 33 2c 20 74 31 0a  09 53 54 52 09 74 34 2c  | t3, t1..STR.t4,|
00002d20  20 6f 70 5f 66 6d 31 0a  09 4f 52 52 09 74 34 2c  | op_fm1..ORR.t4,|
00002d30  20 74 33 2c 20 74 32 0a  09 53 54 52 09 74 34 2c  | t3, t2..STR.t4,|
00002d40  20 6f 70 5f 66 6d 32 0a  09 4c 44 52 09 74 33 2c  | op_fm2..LDR.t3,|
00002d50  20 6f 70 5f 61 64 64 5f  30 5f 30 0a 09 4f 52 52  | op_add_0_0..ORR|
00002d60  09 74 34 2c 20 74 33 2c  20 74 31 0a 09 53 54 52  |.t4, t3, t1..STR|
00002d70  09 74 34 2c 20 6f 70 5f  66 6d 33 0a 09 4f 52 52  |.t4, op_fm3..ORR|
00002d80  09 74 34 2c 20 74 33 2c  20 74 32 0a 09 53 54 52  |.t4, t3, t2..STR|
00002d90  09 74 34 2c 20 6f 70 5f  66 6d 34 0a 09 4c 44 52  |.t4, op_fm4..LDR|
00002da0  09 74 33 2c 20 6f 70 5f  72 73 62 5f 30 5f 30 0a  |.t3, op_rsb_0_0.|
00002db0  09 4f 52 52 09 74 34 2c  20 74 33 2c 20 74 31 0a  |.ORR.t4, t3, t1.|
00002dc0  09 53 54 52 09 74 34 2c  20 6f 70 5f 66 6d 35 0a  |.STR.t4, op_fm5.|
00002dd0  09 4f 52 52 09 74 34 2c  20 74 33 2c 20 74 32 0a  |.ORR.t4, t3, t2.|
00002de0  09 53 54 52 09 74 34 2c  20 6f 70 5f 66 6d 36 0a  |.STR.t4, op_fm6.|
00002df0  09 42 4c 09 66 61 73 74  6d 75 6c 0a 09 4c 44 52  |.BL.fastmul..LDR|
00002e00  09 74 34 2c 20 69 6e 69  74 69 61 6c 5f 63 70 74  |.t4, initial_cpt|
00002e10  72 0a 09 4c 44 52 09 74  33 2c 20 6e 70 6f 77 65  |r..LDR.t3, npowe|
00002e20  72 5f 6f 66 5f 32 0a 09  4d 4f 56 09 63 6f 6e 73  |r_of_2..MOV.cons|
00002e30  74 2c 20 63 6f 6e 73 74  2c 20 4c 53 4c 20 74 33  |t, const, LSL t3|
00002e40  0a 09 43 4d 50 09 74 34  2c 20 23 30 0a 09 41 44  |..CMP.t4, #0..AD|
00002e50  44 45 51 09 63 70 74 72  2c 20 63 70 74 72 2c 20  |DEQ.cptr, cptr, |
00002e60  23 34 0a 09 4c 44 52 4e  45 09 74 31 2c 20 6f 70  |#4..LDRNE.t1, op|
00002e70  5f 73 75 62 73 5f 30 5f  30 0a 09 4f 52 52 4e 45  |_subs_0_0..ORRNE|
00002e80  09 74 31 2c 20 74 31 2c  20 6f 75 74 72 2c 20 4c  |.t1, t1, outr, L|
00002e90  53 4c 20 23 31 32 0a 09  4f 52 52 4e 45 09 74 31  |SL #12..ORRNE.t1|
00002ea0  2c 20 74 31 2c 20 6e 75  6d 2c 20 4c 53 4c 20 23  |, t1, num, LSL #|
00002eb0  31 36 0a 09 4f 52 52 4e  45 09 74 31 2c 20 74 31  |16..ORRNE.t1, t1|
00002ec0  2c 20 6f 75 74 72 0a 09  4f 52 52 4e 45 09 74 31  |, outr..ORRNE.t1|
00002ed0  2c 20 74 31 2c 20 74 33  2c 20 4c 53 4c 20 23 37  |, t1, t3, LSL #7|
00002ee0  0a 09 53 54 52 4e 45 09  74 31 2c 20 5b 63 70 74  |..STRNE.t1, [cpt|
00002ef0  72 5d 2c 20 23 34 09 09  09 3b 73 75 62 73 20 6f  |r], #4...;subs o|
00002f00  75 74 72 2c 20 6e 75 6d  2c 20 6f 75 74 72 2c 20  |utr, num, outr, |
00002f10  6c 73 6c 20 23 6e 70 6f  77 65 72 5f 6f 66 5f 32  |lsl #npower_of_2|
00002f20  20 28 70 6f 73 73 69 62  6c 79 20 30 29 0a 09 4c  | (possibly 0)..L|
00002f30  44 52 09 74 31 2c 20 73  75 62 66 6c 61 67 0a 09  |DR.t1, subflag..|
00002f40  42 4e 45 09 64 6f 5f 63  68 65 63 6b 0a 09 43 4d  |BNE.do_check..CM|
00002f50  50 09 74 31 2c 20 23 30  0a 09 41 44 44 45 51 09  |P.t1, #0..ADDEQ.|
00002f60  63 70 74 72 2c 20 63 70  74 72 2c 20 23 31 32 0a  |cptr, cptr, #12.|
00002f70  09 41 44 44 4e 45 09 63  70 74 72 2c 20 63 70 74  |.ADDNE.cptr, cpt|
00002f80  72 2c 20 23 32 30 0a 09  42 09 6e 6f 77 5f 72 65  |r, #20..B.now_re|
00002f90  73 74 6f 72 65 5f 73 69  67 6e 73 0a 64 6f 5f 63  |store_signs.do_c|
00002fa0  68 65 63 6b 0a 09 43 4d  50 09 77 6f 72 6b 2c 20  |heck..CMP.work, |
00002fb0  23 2d 31 0a 09 42 4e 45  09 75 73 65 5f 77 6f 72  |#-1..BNE.use_wor|
00002fc0  6b 0a 09 43 4d 50 09 74  31 2c 20 23 30 0a 09 4c  |k..CMP.t1, #0..L|
00002fd0  44 52 4e 45 09 74 31 2c  20 6f 70 5f 73 75 62 6d  |DRNE.t1, op_subm|
00002fe0  69 5f 30 5f 6e 31 0a 09  4f 52 52 4e 45 09 74 31  |i_0_n1..ORRNE.t1|
00002ff0  2c 20 74 31 2c 20 6f 75  74 71 2c 20 4c 53 4c 20  |, t1, outq, LSL |
00003000  23 31 32 0a 09 4f 52 52  4e 45 09 74 31 2c 20 74  |#12..ORRNE.t1, t|
00003010  31 2c 20 6f 75 74 71 2c  20 4c 53 4c 20 23 31 36  |1, outq, LSL #16|
00003020  0a 09 53 54 52 4e 45 09  74 31 2c 20 5b 63 70 74  |..STRNE.t1, [cpt|
00003030  72 5d 2c 20 23 34 09 09  09 3b 73 75 62 6d 69 20  |r], #4...;submi |
00003040  6f 75 74 71 2c 20 6f 75  74 71 2c 20 23 31 0a 09  |outq, outq, #1..|
00003050  4c 44 52 09 74 31 2c 20  6f 70 32 0a 09 4f 52 52  |LDR.t1, op2..ORR|
00003060  4e 45 09 74 32 2c 20 74  31 2c 20 23 32 5f 30 31  |NE.t2, t1, #2_01|
00003070  30 30 3c 3c 32 38 09 09  3b 63 6f 6e 64 20 6d 69  |00<<28..;cond mi|
00003080  0a 09 4f 52 52 4e 45 09  74 32 2c 20 74 32 2c 20  |..ORRNE.t2, t2, |
00003090  23 32 5f 30 31 30 30 3c  3c 32 31 09 09 3b 6f 70  |#2_0100<<21..;op|
000030a0  63 6f 64 65 20 61 64 64  0a 09 53 54 52 4e 45 09  |code add..STRNE.|
000030b0  74 32 2c 20 5b 63 70 74  72 5d 2c 20 23 34 09 09  |t2, [cptr], #4..|
000030c0  09 3b 61 64 64 6d 69 20  6f 75 74 72 2c 20 6f 75  |.;addmi outr, ou|
000030d0  74 72 2c 20 23 63 6f 6e  73 74 0a 09 4f 52 52 09  |tr, #const..ORR.|
000030e0  74 32 2c 20 74 31 2c 20  23 32 5f 31 31 31 30 3c  |t2, t1, #2_1110<|
000030f0  3c 32 38 09 09 3b 63 6f  6e 64 20 61 6c 0a 09 4f  |<28..;cond al..O|
00003100  52 52 09 74 32 2c 20 74  32 2c 20 23 32 5f 31 30  |RR.t2, t2, #2_10|
00003110  31 30 31 3c 3c 32 30 09  09 3b 6f 70 63 6f 64 65  |101<<20..;opcode|
00003120  20 63 6d 70 73 0a 09 53  54 52 09 74 32 2c 20 5b  | cmps..STR.t2, [|
00003130  63 70 74 72 5d 2c 20 23  34 09 09 09 3b 63 6d 70  |cptr], #4...;cmp|
00003140  20 6f 75 74 72 2c 20 23  63 6f 6e 73 74 0a 09 4c  | outr, #const..L|
00003150  44 52 09 74 32 2c 20 6f  70 5f 61 64 64 67 65 5f  |DR.t2, op_addge_|
00003160  30 5f 6e 31 0a 09 4f 52  52 09 74 32 2c 20 74 32  |0_n1..ORR.t2, t2|
00003170  2c 20 6f 75 74 71 2c 20  4c 53 4c 20 23 31 32 0a  |, outq, LSL #12.|
00003180  09 4f 52 52 09 74 32 2c  20 74 32 2c 20 6f 75 74  |.ORR.t2, t2, out|
00003190  71 2c 20 4c 53 4c 20 23  31 36 0a 09 53 54 52 09  |q, LSL #16..STR.|
000031a0  74 32 2c 20 5b 63 70 74  72 5d 2c 20 23 34 09 09  |t2, [cptr], #4..|
000031b0  09 3b 61 64 64 67 65 20  6f 75 74 71 2c 20 6f 75  |.;addge outq, ou|
000031c0  74 71 2c 20 23 31 0a 09  4f 52 52 09 74 32 2c 20  |tq, #1..ORR.t2, |
000031d0  74 31 2c 20 23 32 5f 31  30 31 30 3c 3c 32 38 09  |t1, #2_1010<<28.|
000031e0  09 3b 63 6f 6e 64 20 67  65 0a 09 4f 52 52 09 74  |.;cond ge..ORR.t|
000031f0  32 2c 20 74 32 2c 20 23  32 5f 30 30 31 30 3c 3c  |2, t2, #2_0010<<|
00003200  32 31 09 09 3b 6f 70 63  6f 64 65 20 73 75 62 0a  |21..;opcode sub.|
00003210  09 53 54 52 09 74 32 2c  20 5b 63 70 74 72 5d 2c  |.STR.t2, [cptr],|
00003220  20 23 34 09 09 09 3b 73  75 62 67 65 20 6f 75 74  | #4...;subge out|
00003230  72 2c 20 6f 75 74 72 2c  20 23 63 6f 6e 73 74 0a  |r, outr, #const.|
00003240  09 42 09 6e 6f 77 5f 72  65 73 74 6f 72 65 5f 73  |.B.now_restore_s|
00003250  69 67 6e 73 0a 75 73 65  5f 77 6f 72 6b 0a 09 43  |igns.use_work..C|
00003260  4d 50 09 74 31 2c 20 23  30 0a 09 4c 44 52 4e 45  |MP.t1, #0..LDRNE|
00003270  09 74 31 2c 20 6f 70 5f  73 75 62 6d 69 5f 30 5f  |.t1, op_submi_0_|
00003280  6e 31 0a 09 4f 52 52 4e  45 09 74 31 2c 20 74 31  |n1..ORRNE.t1, t1|
00003290  2c 20 6f 75 74 71 2c 20  4c 53 4c 20 23 31 32 0a  |, outq, LSL #12.|
000032a0  09 4f 52 52 4e 45 09 74  31 2c 20 74 31 2c 20 6f  |.ORRNE.t1, t1, o|
000032b0  75 74 71 2c 20 4c 53 4c  20 23 31 36 0a 09 53 54  |utq, LSL #16..ST|
000032c0  52 4e 45 09 74 31 2c 20  5b 63 70 74 72 5d 2c 20  |RNE.t1, [cptr], |
000032d0  23 34 09 09 09 3b 73 75  62 6d 69 20 6f 75 74 71  |#4...;submi outq|
000032e0  2c 20 6f 75 74 71 2c 20  23 31 0a 09 4c 44 52 4e  |, outq, #1..LDRN|
000032f0  45 09 74 31 2c 20 6f 70  5f 61 64 64 6d 69 5f 30  |E.t1, op_addmi_0|
00003300  5f 30 0a 09 4f 52 52 4e  45 09 74 31 2c 20 74 31  |_0..ORRNE.t1, t1|
00003310  2c 20 6f 75 74 72 2c 20  4c 53 4c 20 23 31 32 0a  |, outr, LSL #12.|
00003320  09 4f 52 52 4e 45 09 74  31 2c 20 74 31 2c 20 6f  |.ORRNE.t1, t1, o|
00003330  75 74 72 2c 20 4c 53 4c  20 23 31 36 0a 09 4f 52  |utr, LSL #16..OR|
00003340  52 4e 45 09 74 31 2c 20  74 31 2c 20 77 6f 72 6b  |RNE.t1, t1, work|
00003350  0a 09 53 54 52 4e 45 09  74 31 2c 20 5b 63 70 74  |..STRNE.t1, [cpt|
00003360  72 5d 2c 20 23 34 09 09  09 3b 61 64 64 6d 69 20  |r], #4...;addmi |
00003370  6f 75 74 72 2c 20 6f 75  74 72 2c 20 77 6f 72 6b  |outr, outr, work|
00003380  0a 09 4c 44 52 09 74 31  2c 20 6f 70 5f 63 6d 70  |..LDR.t1, op_cmp|
00003390  5f 30 5f 30 0a 09 4f 52  52 09 74 32 2c 20 74 31  |_0_0..ORR.t2, t1|
000033a0  2c 20 6f 75 74 72 2c 20  4c 53 4c 20 23 31 36 0a  |, outr, LSL #16.|
000033b0  09 4f 52 52 09 74 32 2c  20 74 32 2c 20 77 6f 72  |.ORR.t2, t2, wor|
000033c0  6b 0a 09 53 54 52 09 74  32 2c 20 5b 63 70 74 72  |k..STR.t2, [cptr|
000033d0  5d 2c 20 23 34 09 09 09  3b 63 6d 70 20 6f 75 74  |], #4...;cmp out|
000033e0  72 2c 20 77 6f 72 6b 0a  09 4c 44 52 09 74 32 2c  |r, work..LDR.t2,|
000033f0  20 6f 70 5f 61 64 64 67  65 5f 30 5f 6e 31 0a 09  | op_addge_0_n1..|
00003400  4f 52 52 09 74 32 2c 20  74 32 2c 20 6f 75 74 71  |ORR.t2, t2, outq|
00003410  2c 20 4c 53 4c 20 23 31  32 0a 09 4f 52 52 09 74  |, LSL #12..ORR.t|
00003420  32 2c 20 74 32 2c 20 6f  75 74 71 2c 20 4c 53 4c  |2, t2, outq, LSL|
00003430  20 23 31 36 0a 09 53 54  52 09 74 32 2c 20 5b 63  | #16..STR.t2, [c|
00003440  70 74 72 5d 2c 20 23 34  09 09 09 3b 61 64 64 67  |ptr], #4...;addg|
00003450  65 20 6f 75 74 71 2c 20  6f 75 74 71 2c 20 23 31  |e outq, outq, #1|
00003460  0a 09 4c 44 52 09 74 31  2c 20 6f 70 5f 73 75 62  |..LDR.t1, op_sub|
00003470  67 65 5f 30 5f 30 0a 09  4f 52 52 09 74 31 2c 20  |ge_0_0..ORR.t1, |
00003480  74 31 2c 20 6f 75 74 72  2c 20 4c 53 4c 20 23 31  |t1, outr, LSL #1|
00003490  32 0a 09 4f 52 52 09 74  31 2c 20 74 31 2c 20 6f  |2..ORR.t1, t1, o|
000034a0  75 74 72 2c 20 4c 53 4c  20 23 31 36 0a 09 4f 52  |utr, LSL #16..OR|
000034b0  52 09 74 31 2c 20 74 31  2c 20 77 6f 72 6b 0a 09  |R.t1, t1, work..|
000034c0  53 54 52 09 74 31 2c 20  5b 63 70 74 72 5d 2c 20  |STR.t1, [cptr], |
000034d0  23 34 09 09 09 3b 73 75  62 67 65 20 6f 75 74 72  |#4...;subge outr|
000034e0  2c 20 6f 75 74 72 2c 20  77 6f 72 6b 0a 6e 6f 77  |, outr, work.now|
000034f0  5f 72 65 73 74 6f 72 65  5f 73 69 67 6e 73 0a 09  |_restore_signs..|
00003500  4c 44 52 09 74 34 2c 20  69 6e 69 74 69 61 6c 5f  |LDR.t4, initial_|
00003510  63 70 74 72 0a 09 4c 44  52 09 74 33 2c 20 6e 73  |cptr..LDR.t3, ns|
00003520  69 67 6e 70 72 65 73 0a  09 43 4d 50 09 73 69 67  |ignpres..CMP.sig|
00003530  6e 70 72 65 73 2c 20 23  2d 31 0a 09 42 4e 45 09  |npres, #-1..BNE.|
00003540  73 69 67 6e 70 72 65 73  64 0a 09 43 4d 50 09 74  |signpresd..CMP.t|
00003550  33 2c 20 23 2d 31 0a 09  42 4e 45 09 61 6c 6c 5f  |3, #-1..BNE.all_|
00003560  64 6f 6e 65 0a 09 43 4d  50 09 74 34 2c 20 23 30  |done..CMP.t4, #0|
00003570  0a 09 41 44 44 45 51 09  63 70 74 72 2c 20 63 70  |..ADDEQ.cptr, cp|
00003580  74 72 2c 20 23 34 0a 09  4c 44 52 4e 45 09 74 31  |tr, #4..LDRNE.t1|
00003590  2c 20 6f 70 5f 72 73 62  5f 30 0a 09 4f 52 52 4e  |, op_rsb_0..ORRN|
000035a0  45 09 74 31 2c 20 74 31  2c 20 6f 75 74 71 2c 20  |E.t1, t1, outq, |
000035b0  4c 53 4c 20 23 31 32 0a  09 4f 52 52 4e 45 09 74  |LSL #12..ORRNE.t|
000035c0  31 2c 20 74 31 2c 20 6f  75 74 71 2c 20 4c 53 4c  |1, t1, outq, LSL|
000035d0  20 23 31 36 0a 09 53 54  52 4e 45 09 74 31 2c 20  | #16..STRNE.t1, |
000035e0  5b 63 70 74 72 5d 2c 20  23 34 09 09 09 3b 72 73  |[cptr], #4...;rs|
000035f0  62 20 6f 75 74 71 2c 20  6f 75 74 71 2c 20 23 30  |b outq, outq, #0|
00003600  0a 09 42 09 61 6c 6c 5f  64 6f 6e 65 0a 73 69 67  |..B.all_done.sig|
00003610  6e 70 72 65 73 64 0a 09  43 4d 50 09 74 34 2c 20  |npresd..CMP.t4, |
00003620  23 30 0a 09 41 44 44 45  51 09 63 70 74 72 2c 20  |#0..ADDEQ.cptr, |
00003630  63 70 74 72 2c 20 23 31  36 0a 09 42 45 51 09 61  |cptr, #16..BEQ.a|
00003640  6c 6c 5f 64 6f 6e 65 0a  09 4c 44 52 09 74 31 2c  |ll_done..LDR.t1,|
00003650  20 6f 70 5f 74 65 71 73  5f 73 69 67 6e 0a 09 4f  | op_teqs_sign..O|
00003660  52 52 09 74 31 2c 20 74  31 2c 20 73 69 67 6e 70  |RR.t1, t1, signp|
00003670  72 65 73 2c 20 4c 53 4c  20 23 31 36 0a 09 53 54  |res, LSL #16..ST|
00003680  52 09 74 31 2c 20 5b 63  70 74 72 5d 2c 20 23 34  |R.t1, [cptr], #4|
00003690  09 09 09 3b 74 65 71 73  20 73 69 67 6e 70 72 65  |...;teqs signpre|
000036a0  73 2c 20 23 26 38 30 30  30 30 30 30 30 0a 09 4c  |s, #&80000000..L|
000036b0  44 52 09 74 32 2c 20 6f  70 5f 72 73 62 65 71 5f  |DR.t2, op_rsbeq_|
000036c0  30 0a 09 4f 52 52 09 74  31 2c 20 74 32 2c 20 6e  |0..ORR.t1, t2, n|
000036d0  75 6d 2c 20 4c 53 4c 20  23 31 32 0a 09 4f 52 52  |um, LSL #12..ORR|
000036e0  09 74 31 2c 20 74 31 2c  20 6e 75 6d 2c 20 4c 53  |.t1, t1, num, LS|
000036f0  4c 20 23 31 36 0a 09 53  54 52 09 74 31 2c 20 5b  |L #16..STR.t1, [|
00003700  63 70 74 72 5d 2c 20 23  34 09 09 09 3b 72 73 62  |cptr], #4...;rsb|
00003710  65 71 20 6e 75 6d 2c 20  6e 75 6d 2c 20 23 30 0a  |eq num, num, #0.|
00003720  09 4f 52 52 09 74 31 2c  20 74 32 2c 20 6f 75 74  |.ORR.t1, t2, out|
00003730  72 2c 20 4c 53 4c 20 23  31 32 0a 09 4f 52 52 09  |r, LSL #12..ORR.|
00003740  74 31 2c 20 74 31 2c 20  6f 75 74 72 2c 20 4c 53  |t1, t1, outr, LS|
00003750  4c 20 23 31 36 0a 09 53  54 52 09 74 31 2c 20 5b  |L #16..STR.t1, [|
00003760  63 70 74 72 5d 2c 20 23  34 09 09 09 3b 72 73 62  |cptr], #4...;rsb|
00003770  65 71 20 6f 75 74 72 2c  20 6f 75 74 72 2c 20 23  |eq outr, outr, #|
00003780  30 0a 09 4f 52 52 09 74  31 2c 20 74 32 2c 20 6f  |0..ORR.t1, t2, o|
00003790  75 74 71 2c 20 4c 53 4c  20 23 31 32 0a 09 4f 52  |utq, LSL #12..OR|
000037a0  52 09 74 31 2c 20 74 31  2c 20 6f 75 74 71 2c 20  |R.t1, t1, outq, |
000037b0  4c 53 4c 20 23 31 36 0a  09 43 4d 50 09 74 33 2c  |LSL #16..CMP.t3,|
000037c0  20 23 2d 31 0a 09 4f 52  52 45 51 09 74 31 2c 20  | #-1..ORREQ.t1, |
000037d0  74 31 2c 20 23 32 5f 30  30 30 31 3c 3c 32 38 09  |t1, #2_0001<<28.|
000037e0  09 3b 63 6f 6e 64 20 6e  65 0a 09 53 54 52 09 74  |.;cond ne..STR.t|
000037f0  31 2c 20 5b 63 70 74 72  5d 2c 20 23 34 09 09 09  |1, [cptr], #4...|
00003800  3b 69 66 20 6e 65 20 27  72 73 62 65 71 20 6f 75  |;if ne 'rsbeq ou|
00003810  74 71 2c 20 6f 75 74 71  2c 20 23 30 27 2c 20 65  |tq, outq, #0', e|
00003820  6c 73 65 20 66 6c 69 70  20 63 6f 6e 64 20 74 6f  |lse flip cond to|
00003830  20 72 73 62 6e 65 0a 61  6c 6c 5f 64 6f 6e 65 0a  | rsbne.all_done.|
00003840  09 4c 44 52 09 74 31 2c  20 69 6e 69 74 69 61 6c  |.LDR.t1, initial|
00003850  5f 63 70 74 72 0a 09 53  55 42 09 72 30 2c 20 63  |_cptr..SUB.r0, c|
00003860  70 74 72 2c 20 74 31 0a  09 4c 44 4d 46 44 09 73  |ptr, t1..LDMFD.s|
00003870  70 21 2c 20 7b 70 63 7d  5e 0a 0a 69 6e 69 74 69  |p!, {pc}^..initi|
00003880  61 6c 5f 63 70 74 72 09  44 43 44 09 30 0a 6e 73  |al_cptr.DCD.0.ns|
00003890  69 67 6e 70 72 65 73 09  44 43 44 09 30 0a 70 6f  |ignpres.DCD.0.po|
000038a0  77 65 72 5f 6f 66 5f 32  09 44 43 44 09 30 0a 73  |wer_of_2.DCD.0.s|
000038b0  75 62 66 6c 61 67 09 09  44 43 44 09 30 0a 6e 70  |ubflag..DCD.0.np|
000038c0  6f 77 65 72 5f 6f 66 5f  32 09 44 43 44 09 30 0a  |ower_of_2.DCD.0.|
000038d0  61 73 09 09 44 43 44 09  30 0a 61 6d 09 09 44 43  |as..DCD.0.am..DC|
000038e0  44 09 30 0a 0a 6f 70 31  09 41 4e 44 45 51 09 72  |D.0..op1.ANDEQ.r|
000038f0  30 2c 20 72 30 2c 20 23  30 2c 30 09 09 09 3b 75  |0, r0, #0,0...;u|
00003900  73 65 64 20 74 6f 20 62  75 69 6c 64 20 6f 70 32  |sed to build op2|
00003910  3b 20 6e 6f 74 65 20 41  4e 44 2c 20 45 51 20 65  |; note AND, EQ e|
00003920  74 63 20 63 68 6f 73 65  6e 20 61 73 20 67 69 76  |tc chosen as giv|
00003930  65 20 30 20 62 69 74 73  0a 6f 70 32 09 44 43 44  |e 0 bits.op2.DCD|
00003940  09 30 09 09 09 09 3b 77  69 6c 6c 20 73 74 6f 72  |.0....;will stor|
00003950  65 20 64 61 74 61 20 70  72 6f 63 65 73 73 69 6e  |e data processin|
00003960  67 20 69 6e 73 74 72 75  63 74 69 6f 6e 20 6f 66  |g instruction of|
00003970  20 66 6f 72 6d 0a 09 09  09 09 09 09 3b 3c 63 6f  | form.......;<co|
00003980  6e 64 3e 3c 6f 70 63 6f  64 65 3e 20 5b 6f 75 74  |nd><opcode> [out|
00003990  72 5d 2c 5b 6f 75 74 72  5d 2c 23 5b 63 6f 6e 73  |r],[outr],#[cons|
000039a0  74 5d 0a 09 09 09 09 09  09 3b 4e 42 20 6f 75 74  |t].......;NB out|
000039b0  72 20 69 73 20 72 34 2c  20 5b 6f 75 74 72 5d 20  |r is r4, [outr] |
000039c0  6d 65 61 6e 73 20 74 68  65 20 72 65 67 69 73 74  |means the regist|
000039d0  65 72 20 77 68 6f 73 65  20 6e 75 6d 62 65 72 20  |er whose number |
000039e0  69 73 0a 09 09 09 09 09  09 3b 73 74 6f 72 65 64  |is.......;stored|
000039f0  20 69 6e 20 72 34 20 77  68 65 6e 20 67 65 6e 65  | in r4 when gene|
00003a00  72 61 74 6f 72 20 63 6f  64 65 20 65 78 65 63 75  |rator code execu|
00003a10  74 65 64 20 2d 20 64 6f  6e 27 74 20 63 6f 6e 66  |ted - don't conf|
00003a20  75 73 65 0a 09 09 09 09  09 09 3b 74 68 69 73 20  |use.......;this |
00003a30  77 69 74 68 20 72 65 67  69 73 74 65 72 20 72 34  |with register r4|
00003a40  20 69 74 73 65 6c 66 2e  0a 6f 70 5f 6d 6f 76 5f  | itself..op_mov_|
00003a50  30 09 4d 4f 56 09 72 30  2c 20 23 30 2c 30 0a 6f  |0.MOV.r0, #0,0.o|
00003a60  70 5f 6d 6f 76 5f 72 30  09 4d 4f 56 09 72 30 2c  |p_mov_r0.MOV.r0,|
00003a70  20 72 30 0a 6f 70 5f 72  73 62 5f 30 09 52 53 42  | r0.op_rsb_0.RSB|
00003a80  09 72 30 2c 20 72 30 2c  20 23 30 2c 30 0a 6f 70  |.r0, r0, #0,0.op|
00003a90  5f 61 6e 64 73 5f 73 69  67 6e 09 41 4e 44 53 09  |_ands_sign.ANDS.|
00003aa0  72 30 2c 20 72 30 2c 20  23 26 38 30 30 30 30 30  |r0, r0, #&800000|
00003ab0  30 30 0a 6f 70 5f 72 73  62 6e 65 5f 30 09 52 53  |00.op_rsbne_0.RS|
00003ac0  42 4e 45 09 72 30 2c 20  72 30 2c 20 23 30 2c 30  |BNE.r0, r0, #0,0|
00003ad0  0a 6f 70 5f 73 75 62 5f  30 5f 30 09 53 55 42 09  |.op_sub_0_0.SUB.|
00003ae0  72 30 2c 20 72 30 2c 20  72 30 0a 6f 70 5f 6f 72  |r0, r0, r0.op_or|
00003af0  72 5f 30 09 4f 52 52 09  72 30 2c 20 72 30 2c 20  |r_0.ORR.r0, r0, |
00003b00  23 30 2c 30 0a 6f 70 5f  61 64 64 5f 30 5f 30 09  |#0,0.op_add_0_0.|
00003b10  41 44 44 09 72 30 2c 20  72 30 2c 20 72 30 0a 6f  |ADD.r0, r0, r0.o|
00003b20  70 5f 73 75 62 5f 30 5f  30 5f 6c 73 72 09 53 55  |p_sub_0_0_lsr.SU|
00003b30  42 09 72 30 2c 20 72 30  2c 20 72 30 2c 20 4c 53  |B.r0, r0, r0, LS|
00003b40  52 20 23 33 32 09 3b 6e  62 20 4c 53 52 20 23 33  |R #32.;nb LSR #3|
00003b50  32 20 72 65 70 72 65 73  65 6e 74 65 64 20 69 6e  |2 represented in|
00003b60  20 62 69 74 20 66 69 65  6c 64 20 62 79 20 4c 53  | bit field by LS|
00003b70  52 20 23 30 0a 6f 70 5f  61 64 64 5f 30 5f 30 5f  |R #0.op_add_0_0_|
00003b80  6c 73 72 09 41 44 44 09  72 30 2c 20 72 30 2c 20  |lsr.ADD.r0, r0, |
00003b90  72 30 2c 20 4c 53 52 20  23 33 32 0a 6f 70 5f 6d  |r0, LSR #32.op_m|
00003ba0  6f 76 5f 72 30 5f 6c 73  72 09 4d 4f 56 09 72 30  |ov_r0_lsr.MOV.r0|
00003bb0  2c 20 72 30 2c 20 4c 53  52 20 23 33 32 0a 6f 70  |, r0, LSR #32.op|
00003bc0  5f 72 73 62 5f 30 5f 30  09 52 53 42 09 72 30 2c  |_rsb_0_0.RSB.r0,|
00003bd0  20 72 30 2c 20 72 30 0a  6f 70 5f 73 75 62 73 5f  | r0, r0.op_subs_|
00003be0  30 5f 30 09 53 55 42 53  09 72 30 2c 20 72 30 2c  |0_0.SUBS.r0, r0,|
00003bf0  20 72 30 0a 6f 70 5f 73  75 62 6d 69 5f 30 5f 6e  | r0.op_submi_0_n|
00003c00  31 09 53 55 42 4d 49 09  72 30 2c 20 72 30 2c 20  |1.SUBMI.r0, r0, |
00003c10  23 31 0a 6f 70 5f 61 64  64 67 65 5f 30 5f 6e 31  |#1.op_addge_0_n1|
00003c20  09 41 44 44 47 45 09 72  30 2c 20 72 30 2c 20 23  |.ADDGE.r0, r0, #|
00003c30  31 0a 6f 70 5f 61 64 64  6d 69 5f 30 5f 30 09 41  |1.op_addmi_0_0.A|
00003c40  44 44 4d 49 09 72 30 2c  20 72 30 2c 20 72 30 0a  |DDMI.r0, r0, r0.|
00003c50  6f 70 5f 63 6d 70 5f 30  5f 30 09 43 4d 50 09 72  |op_cmp_0_0.CMP.r|
00003c60  30 2c 20 72 30 0a 6f 70  5f 73 75 62 67 65 5f 30  |0, r0.op_subge_0|
00003c70  5f 30 09 53 55 42 47 45  09 72 30 2c 20 72 30 2c  |_0.SUBGE.r0, r0,|
00003c80  20 72 30 0a 6f 70 5f 74  65 71 73 5f 73 69 67 6e  | r0.op_teqs_sign|
00003c90  09 54 45 51 53 09 72 30  2c 20 23 26 38 30 30 30  |.TEQS.r0, #&8000|
00003ca0  30 30 30 30 0a 6f 70 5f  72 73 62 65 71 5f 30 09  |0000.op_rsbeq_0.|
00003cb0  52 53 42 45 51 09 72 30  2c 20 72 30 2c 20 23 30  |RSBEQ.r0, r0, #0|
00003cc0  2c 30 0a 0a 6f 70 5f 66  64 31 09 09 44 43 44 09  |,0..op_fd1..DCD.|
00003cd0  30 0a 6f 70 5f 66 64 32  09 09 44 43 44 09 30 0a  |0.op_fd2..DCD.0.|
00003ce0  6f 70 5f 66 64 33 09 09  44 43 44 09 30 0a 6f 70  |op_fd3..DCD.0.op|
00003cf0  5f 66 64 34 09 09 44 43  44 09 30 0a 6f 70 5f 66  |_fd4..DCD.0.op_f|
00003d00  6d 31 09 09 44 43 44 09  30 0a 6f 70 5f 66 6d 32  |m1..DCD.0.op_fm2|
00003d10  09 09 44 43 44 09 30 0a  6f 70 5f 66 6d 33 09 09  |..DCD.0.op_fm3..|
00003d20  44 43 44 09 30 0a 6f 70  5f 66 6d 34 09 09 44 43  |DCD.0.op_fm4..DC|
00003d30  44 09 30 0a 6f 70 5f 66  6d 35 09 09 44 43 44 09  |D.0.op_fm5..DCD.|
00003d40  30 0a 6f 70 5f 66 6d 36  09 09 44 43 44 09 30 0a  |0.op_fm6..DCD.0.|
00003d50  0a 61 73 74 6b 09 25 09  31 36 2a 38 09 09 09 09  |.astk.%.16*8....|
00003d60  3b 31 36 20 65 6e 74 72  69 65 73 20 6f 66 20 32  |;16 entries of 2|
00003d70  20 77 6f 72 64 73 20 28  61 6e 20 65 6d 70 74 79  | words (an empty|
00003d80  20 61 73 63 65 6e 64 69  6e 67 20 73 74 61 63 6b  | ascending stack|
00003d90  29 0a 61 73 74 6b 5f 65  6e 64 0a 0a 66 61 73 74  |).astk_end..fast|
00003da0  64 69 76 61 69 64 0a 09  43 4d 50 09 73 74 6b 2c  |divaid..CMP.stk,|
00003db0  20 73 74 6b 6c 0a 09 4d  4f 56 47 45 09 72 30 2c  | stkl..MOVGE.r0,|
00003dc0  20 23 2d 35 0a 09 4c 44  4d 47 45 46 44 09 73 70  | #-5..LDMGEFD.sp|
00003dd0  21 2c 20 7b 70 63 7d 5e  0a 09 4d 4f 56 09 74 34  |!, {pc}^..MOV.t4|
00003de0  2c 20 66 6e 09 09 09 09  3b 74 34 20 68 6f 6c 64  |, fn....;t4 hold|
00003df0  73 20 6c 6f 63 61 6c 20  63 6f 6e 73 74 25 0a 09  |s local const%..|
00003e00  4d 4f 56 09 74 31 2c 20  6c 72 0a 09 42 4c 09 62  |MOV.t1, lr..BL.b|
00003e10  69 74 70 61 74 6c 65 6e  09 09 09 3b 66 6e 20 6e  |itpatlen...;fn n|
00003e20  6f 77 20 68 6f 6c 64 73  20 42 61 73 69 63 20 6c  |ow holds Basic l|
00003e30  73 25 0a 09 53 55 42 09  74 33 2c 20 66 6e 2c 20  |s%..SUB.t3, fn, |
00003e40  23 31 0a 09 53 54 4d 45  41 09 73 74 6b 21 2c 20  |#1..STMEA.stk!, |
00003e50  7b 74 33 2c 20 74 31 7d  09 09 09 3b 73 74 61 63  |{t3, t1}...;stac|
00003e60  6b 20 6c 73 25 2d 31 20  61 62 6f 76 65 20 72 65  |k ls%-1 above re|
00003e70  74 75 72 6e 20 61 64 64  72 65 73 73 0a 09 41 4e  |turn address..AN|
00003e80  44 53 09 74 32 2c 20 74  34 2c 20 23 33 0a 09 43  |DS.t2, t4, #3..C|
00003e90  4d 50 4e 45 09 74 32 2c  20 23 32 0a 09 4d 4f 56  |MPNE.t2, #2..MOV|
00003ea0  45 51 09 72 30 2c 20 23  2d 36 0a 09 4c 44 4d 45  |EQ.r0, #-6..LDME|
00003eb0  51 46 44 09 73 70 21 2c  20 7b 70 63 7d 5e 0a 09  |QFD.sp!, {pc}^..|
00003ec0  43 4d 50 09 74 32 2c 20  23 31 0a 09 53 55 42 45  |CMP.t2, #1..SUBE|
00003ed0  51 09 74 34 2c 20 74 34  2c 20 23 31 0a 09 41 44  |Q.t4, t4, #1..AD|
00003ee0  44 4e 45 09 74 34 2c 20  74 34 2c 20 23 31 0a 09  |DNE.t4, t4, #1..|
00003ef0  4d 4f 56 4e 45 09 74 31  2c 20 23 31 0a 09 53 54  |MOVNE.t1, #1..ST|
00003f00  52 4e 45 09 74 31 2c 20  73 75 62 66 6c 61 67 0a  |RNE.t1, subflag.|
00003f10  09 4d 4f 56 09 66 6e 2c  20 74 34 0a 09 42 4c 09  |.MOV.fn, t4..BL.|
00003f20  70 6f 77 65 72 6f 66 32  0a 09 4d 4f 56 09 74 34  |powerof2..MOV.t4|
00003f30  2c 20 74 34 2c 20 4c 53  52 20 66 6e 09 09 09 3b  |, t4, LSR fn...;|
00003f40  6c 6f 63 61 6c 20 63 6f  6e 73 74 20 3d 20 63 6f  |local const = co|
00003f50  6e 73 74 20 3e 3e 3e 20  70 6f 77 65 72 6f 66 32  |nst >>> powerof2|
00003f60  28 63 6f 6e 73 74 29 0a  09 43 4d 50 09 74 34 2c  |(const)..CMP.t4,|
00003f70  20 23 31 0a 09 42 4e 45  09 66 64 61 5f 63 6f 6e  | #1..BNE.fda_con|
00003f80  73 74 6f 76 65 72 6f 6e  65 0a 09 4c 44 52 09 74  |stoverone..LDR.t|
00003f90  31 2c 20 69 6e 69 74 69  61 6c 5f 63 70 74 72 0a  |1, initial_cptr.|
00003fa0  09 43 4d 50 09 74 31 2c  20 23 30 0a 09 42 4e 45  |.CMP.t1, #0..BNE|
00003fb0  09 66 64 61 5f 6c 31 0a  09 43 4d 50 09 74 32 2c  |.fda_l1..CMP.t2,|
00003fc0  20 23 31 09 09 09 09 3b  45 51 20 69 6d 70 6c 69  | #1....;EQ impli|
00003fd0  65 73 20 64 69 76 69 6e  73 74 24 3d 22 41 44 44  |es divinst$="ADD|
00003fe0  22 0a 09 41 44 44 45 51  09 63 70 74 72 2c 20 63  |"..ADDEQ.cptr, c|
00003ff0  70 74 72 2c 20 23 34 0a  09 41 44 44 4e 45 09 63  |ptr, #4..ADDNE.c|
00004000  70 74 72 2c 20 63 70 74  72 2c 20 23 38 0a 09 42  |ptr, cptr, #8..B|
00004010  09 66 64 61 5f 65 78 69  74 0a 66 64 61 5f 6c 31  |.fda_exit.fda_l1|
00004020  09 4c 44 52 09 74 33 2c  20 5b 73 74 6b 2c 20 23  |.LDR.t3, [stk, #|
00004030  2d 34 5d 09 09 09 3b 67  65 74 20 62 61 63 6b 20  |-4]...;get back |
00004040  6c 73 25 2d 31 0a 09 43  4d 50 09 74 32 2c 20 23  |ls%-1..CMP.t2, #|
00004050  31 0a 09 4c 44 52 4e 45  09 74 31 2c 20 6f 70 5f  |1..LDRNE.t1, op_|
00004060  66 64 31 0a 09 53 54 52  4e 45 09 74 31 2c 20 5b  |fd1..STRNE.t1, [|
00004070  63 70 74 72 5d 2c 20 23  34 09 09 09 3b 61 64 64  |cptr], #4...;add|
00004080  20 6f 75 74 71 2c 20 6e  75 6d 2c 20 6e 75 6d 0a  | outq, num, num.|
00004090  09 4c 44 52 4e 45 09 74  31 2c 20 6f 70 5f 66 64  |.LDRNE.t1, op_fd|
000040a0  32 0a 09 4c 44 52 45 51  09 74 31 2c 20 6f 70 5f  |2..LDREQ.t1, op_|
000040b0  66 64 33 0a 09 4f 52 52  09 74 31 2c 20 74 31 2c  |fd3..ORR.t1, t1,|
000040c0  20 74 33 2c 20 4c 53 4c  20 23 37 0a 09 53 54 52  | t3, LSL #7..STR|
000040d0  09 74 31 2c 20 5b 63 70  74 72 5d 2c 20 23 34 09  |.t1, [cptr], #4.|
000040e0  09 09 3b 69 66 20 4e 45  20 27 73 75 62 20 6f 75  |..;if NE 'sub ou|
000040f0  74 71 2c 20 6f 75 74 71  2c 20 6e 75 6d 2c 20 6c  |tq, outq, num, l|
00004100  73 72 20 23 6c 73 25 2d  31 27 0a 09 42 09 66 64  |sr #ls%-1'..B.fd|
00004110  61 5f 65 78 69 74 09 09  09 3b 65 6c 73 65 20 20  |a_exit...;else  |
00004120  27 61 64 64 20 6f 75 74  71 2c 20 6e 75 6d 2c 20  |'add outq, num, |
00004130  6e 75 6d 2c 20 6c 73 72  20 23 6c 73 25 2d 31 27  |num, lsr #ls%-1'|
00004140  0a 66 64 61 5f 63 6f 6e  73 74 6f 76 65 72 6f 6e  |.fda_constoveron|
00004150  65 0a 09 43 4d 50 09 74  32 2c 20 23 31 0a 09 42  |e..CMP.t2, #1..B|
00004160  45 51 09 66 64 61 5f 6c  32 0a 09 09 09 09 09 09  |EQ.fda_l2.......|
00004170  3b 63 6f 6e 73 74 3e 31  20 26 20 64 69 76 69 6e  |;const>1 & divin|
00004180  73 74 24 3d 22 53 55 42  22 0a 09 4d 4f 56 09 66  |st$="SUB"..MOV.f|
00004190  6e 2c 20 74 34 09 09 09  09 3b 66 69 72 73 74 20  |n, t4....;first |
000041a0  72 65 63 75 72 73 65 0a  09 42 4c 09 66 61 73 74  |recurse..BL.fast|
000041b0  64 69 76 61 69 64 0a 09  4c 44 52 09 74 31 2c 20  |divaid..LDR.t1, |
000041c0  69 6e 69 74 69 61 6c 5f  63 70 74 72 0a 09 43 4d  |initial_cptr..CM|
000041d0  50 09 74 31 2c 20 23 30  0a 09 41 44 44 45 51 09  |P.t1, #0..ADDEQ.|
000041e0  63 70 74 72 2c 20 63 70  74 72 2c 20 23 34 0a 09  |cptr, cptr, #4..|
000041f0  42 45 51 09 66 64 61 5f  65 78 69 74 0a 09 4c 44  |BEQ.fda_exit..LD|
00004200  52 09 66 6e 2c 20 5b 73  74 6b 2c 20 23 2d 34 5d  |R.fn, [stk, #-4]|
00004210  0a 09 4c 44 52 09 74 31  2c 20 6f 70 5f 66 64 32  |..LDR.t1, op_fd2|
00004220  0a 09 4f 52 52 09 74 31  2c 20 74 31 2c 20 66 6e  |..ORR.t1, t1, fn|
00004230  2c 20 4c 53 4c 20 23 37  0a 09 53 54 52 09 74 31  |, LSL #7..STR.t1|
00004240  2c 20 5b 63 70 74 72 5d  2c 20 23 34 0a 09 42 09  |, [cptr], #4..B.|
00004250  66 64 61 5f 65 78 69 74  0a 66 64 61 5f 6c 32 09  |fda_exit.fda_l2.|
00004260  09 09 09 09 09 3b 63 6f  6e 73 74 3e 31 20 26 20  |.....;const>1 & |
00004270  64 69 76 69 6e 73 74 24  3d 22 41 44 44 22 0a 09  |divinst$="ADD"..|
00004280  4d 4f 56 09 66 6e 2c 20  74 34 09 09 09 09 3b 66  |MOV.fn, t4....;f|
00004290  69 72 73 74 20 72 65 63  75 72 73 65 0a 09 42 4c  |irst recurse..BL|
000042a0  09 66 61 73 74 64 69 76  61 69 64 0a 09 4c 44 52  |.fastdivaid..LDR|
000042b0  09 74 31 2c 20 69 6e 69  74 69 61 6c 5f 63 70 74  |.t1, initial_cpt|
000042c0  72 0a 09 43 4d 50 09 74  31 2c 20 23 30 0a 09 41  |r..CMP.t1, #0..A|
000042d0  44 44 45 51 09 63 70 74  72 2c 20 63 70 74 72 2c  |DDEQ.cptr, cptr,|
000042e0  20 23 34 0a 09 42 45 51  09 66 64 61 5f 65 78 69  | #4..BEQ.fda_exi|
000042f0  74 0a 09 4c 44 52 09 66  6e 2c 20 5b 73 74 6b 2c  |t..LDR.fn, [stk,|
00004300  20 23 2d 34 5d 0a 09 4c  44 52 09 74 31 2c 20 6f  | #-4]..LDR.t1, o|
00004310  70 5f 66 64 34 0a 09 4f  52 52 09 74 31 2c 20 74  |p_fd4..ORR.t1, t|
00004320  31 2c 20 66 6e 2c 20 4c  53 4c 20 23 37 0a 09 53  |1, fn, LSL #7..S|
00004330  54 52 09 74 31 2c 20 5b  63 70 74 72 5d 2c 20 23  |TR.t1, [cptr], #|
00004340  34 0a 66 64 61 5f 65 78  69 74 0a 09 4c 44 4d 45  |4.fda_exit..LDME|
00004350  41 09 73 74 6b 21 2c 20  7b 66 6e 2c 20 74 32 7d  |A.stk!, {fn, t2}|
00004360  09 09 09 3b 64 69 73 63  61 72 64 20 6c 73 25 2d  |...;discard ls%-|
00004370  31 20 26 20 72 65 74 75  72 6e 0a 09 4d 4f 56 53  |1 & return..MOVS|
00004380  09 70 63 2c 20 74 32 0a  0a 66 61 73 74 6d 75 6c  |.pc, t2..fastmul|
00004390  0a 09 43 4d 50 09 73 74  6b 2c 20 73 74 6b 6c 0a  |..CMP.stk, stkl.|
000043a0  09 4d 4f 56 47 45 09 72  30 2c 20 23 2d 35 0a 09  |.MOVGE.r0, #-5..|
000043b0  4c 44 4d 47 45 46 44 09  73 70 21 2c 20 7b 70 63  |LDMGEFD.sp!, {pc|
000043c0  7d 5e 0a 09 53 54 4d 45  41 09 73 74 6b 21 2c 20  |}^..STMEA.stk!, |
000043d0  7b 6c 72 7d 0a 09 41 4e  44 53 09 74 31 2c 20 66  |{lr}..ANDS.t1, f|
000043e0  6e 2c 20 23 33 09 09 09  3b 66 6e 20 68 6f 6c 64  |n, #3...;fn hold|
000043f0  73 20 6c 6f 63 61 6c 20  63 6f 6e 73 74 0a 09 43  |s local const..C|
00004400  4d 50 4e 45 09 74 31 2c  20 23 32 0a 09 42 4e 45  |MPNE.t1, #2..BNE|
00004410  09 66 6d 5f 74 72 79 5f  6f 6e 65 0a 09 4d 4f 56  |.fm_try_one..MOV|
00004420  09 74 34 2c 20 66 6e 0a  09 42 4c 09 70 6f 77 65  |.t4, fn..BL.powe|
00004430  72 6f 66 32 0a 09 53 54  4d 45 41 09 73 74 6b 21  |rof2..STMEA.stk!|
00004440  2c 20 7b 66 6e 7d 09 09  09 3b 72 65 74 75 72 6e  |, {fn}...;return|
00004450  20 61 64 64 72 65 73 73  20 26 20 6e 25 20 28 66  | address & n% (f|
00004460  6e 29 20 20 73 74 61 63  6b 65 64 2c 20 6c 6f 63  |n)  stacked, loc|
00004470  61 6c 20 63 6f 6e 73 74  20 69 6e 20 74 34 0a 09  |al const in t4..|
00004480  4d 4f 56 09 74 34 2c 20  74 34 2c 20 4c 53 52 20  |MOV.t4, t4, LSR |
00004490  66 6e 0a 09 43 4d 50 09  74 34 2c 20 23 31 0a 09  |fn..CMP.t4, #1..|
000044a0  4c 44 52 45 51 09 74 32  2c 20 6f 70 5f 66 6d 31  |LDREQ.t2, op_fm1|
000044b0  0a 09 42 45 51 09 66 6d  5f 65 78 69 74 0a 09 4d  |..BEQ.fm_exit..M|
000044c0  4f 56 09 66 6e 2c 20 74  34 0a 09 42 4c 09 66 61  |OV.fn, t4..BL.fa|
000044d0  73 74 6d 75 6c 09 09 09  09 3b 72 65 63 75 72 73  |stmul....;recurs|
000044e0  65 0a 09 4c 44 52 09 66  6e 2c 20 5b 73 74 6b 2c  |e..LDR.fn, [stk,|
000044f0  20 23 2d 34 5d 0a 09 4c  44 52 09 74 32 2c 20 6f  | #-4]..LDR.t2, o|
00004500  70 5f 66 6d 32 0a 09 42  09 66 6d 5f 65 78 69 74  |p_fm2..B.fm_exit|
00004510  0a 66 6d 5f 74 72 79 5f  6f 6e 65 0a 09 43 4d 50  |.fm_try_one..CMP|
00004520  09 74 31 2c 20 23 31 0a  09 42 4e 45 09 66 6d 5f  |.t1, #1..BNE.fm_|
00004530  69 73 5f 74 68 72 65 65  0a 09 53 55 42 09 66 6e  |is_three..SUB.fn|
00004540  2c 20 66 6e 2c 20 23 31  0a 09 4d 4f 56 09 74 34  |, fn, #1..MOV.t4|
00004550  2c 20 66 6e 0a 09 42 4c  09 70 6f 77 65 72 6f 66  |, fn..BL.powerof|
00004560  32 0a 09 53 54 4d 45 41  09 73 74 6b 21 2c 20 7b  |2..STMEA.stk!, {|
00004570  66 6e 7d 09 09 09 3b 72  65 74 75 72 6e 20 61 64  |fn}...;return ad|
00004580  64 72 65 73 73 20 26 20  6e 25 20 28 66 6e 29 20  |dress & n% (fn) |
00004590  20 73 74 61 63 6b 65 64  2c 20 6c 6f 63 61 6c 20  | stacked, local |
000045a0  63 6f 6e 73 74 20 69 6e  20 74 34 0a 09 4d 4f 56  |const in t4..MOV|
000045b0  09 74 34 2c 20 74 34 2c  20 4c 53 52 20 66 6e 0a  |.t4, t4, LSR fn.|
000045c0  09 43 4d 50 09 74 34 2c  20 23 31 0a 09 4c 44 52  |.CMP.t4, #1..LDR|
000045d0  45 51 09 74 32 2c 20 6f  70 5f 66 6d 33 0a 09 42  |EQ.t2, op_fm3..B|
000045e0  45 51 09 66 6d 5f 65 78  69 74 0a 09 4d 4f 56 09  |EQ.fm_exit..MOV.|
000045f0  66 6e 2c 20 74 34 0a 09  42 4c 09 66 61 73 74 6d  |fn, t4..BL.fastm|
00004600  75 6c 09 09 09 09 3b 72  65 63 75 72 73 65 0a 09  |ul....;recurse..|
00004610  4c 44 52 09 66 6e 2c 20  5b 73 74 6b 2c 20 23 2d  |LDR.fn, [stk, #-|
00004620  34 5d 0a 09 4c 44 52 09  74 32 2c 20 6f 70 5f 66  |4]..LDR.t2, op_f|
00004630  6d 34 0a 09 42 09 66 6d  5f 65 78 69 74 0a 66 6d  |m4..B.fm_exit.fm|
00004640  5f 69 73 5f 74 68 72 65  65 0a 09 41 44 44 09 66  |_is_three..ADD.f|
00004650  6e 2c 20 66 6e 2c 20 23  31 0a 09 4d 4f 56 09 74  |n, fn, #1..MOV.t|
00004660  34 2c 20 66 6e 0a 09 42  4c 09 70 6f 77 65 72 6f  |4, fn..BL.powero|
00004670  66 32 0a 09 53 54 4d 45  41 09 73 74 6b 21 2c 20  |f2..STMEA.stk!, |
00004680  7b 66 6e 7d 09 09 09 3b  72 65 74 75 72 6e 20 61  |{fn}...;return a|
00004690  64 64 72 65 73 73 20 26  20 6e 25 20 28 66 6e 29  |ddress & n% (fn)|
000046a0  20 20 73 74 61 63 6b 65  64 2c 20 6c 6f 63 61 6c  |  stacked, local|
000046b0  20 63 6f 6e 73 74 20 69  6e 20 74 34 0a 09 4d 4f  | const in t4..MO|
000046c0  56 09 74 34 2c 20 74 34  2c 20 4c 53 52 20 66 6e  |V.t4, t4, LSR fn|
000046d0  0a 09 43 4d 50 09 74 34  2c 20 23 31 0a 09 4c 44  |..CMP.t4, #1..LD|
000046e0  52 45 51 09 74 32 2c 20  6f 70 5f 66 6d 35 0a 09  |REQ.t2, op_fm5..|
000046f0  42 45 51 09 66 6d 5f 65  78 69 74 0a 09 4d 4f 56  |BEQ.fm_exit..MOV|
00004700  09 66 6e 2c 20 74 34 0a  09 42 4c 09 66 61 73 74  |.fn, t4..BL.fast|
00004710  6d 75 6c 09 09 09 09 3b  72 65 63 75 72 73 65 0a  |mul....;recurse.|
00004720  09 4c 44 52 09 66 6e 2c  20 5b 73 74 6b 2c 20 23  |.LDR.fn, [stk, #|
00004730  2d 34 5d 0a 09 4c 44 52  09 74 32 2c 20 6f 70 5f  |-4]..LDR.t2, op_|
00004740  66 6d 36 0a 09 42 09 66  6d 5f 65 78 69 74 0a 66  |fm6..B.fm_exit.f|
00004750  6d 5f 65 78 69 74 0a 09  4c 44 52 09 74 31 2c 20  |m_exit..LDR.t1, |
00004760  69 6e 69 74 69 61 6c 5f  63 70 74 72 0a 09 43 4d  |initial_cptr..CM|
00004770  50 09 74 31 2c 20 23 30  0a 09 41 44 44 45 51 09  |P.t1, #0..ADDEQ.|
00004780  63 70 74 72 2c 20 63 70  74 72 2c 20 23 34 0a 09  |cptr, cptr, #4..|
00004790  4f 52 52 4e 45 09 74 32  2c 20 74 32 2c 20 66 6e  |ORRNE.t2, t2, fn|
000047a0  2c 20 4c 53 4c 20 23 37  0a 09 53 54 52 4e 45 09  |, LSL #7..STRNE.|
000047b0  74 32 2c 20 5b 63 70 74  72 5d 2c 20 23 34 0a 09  |t2, [cptr], #4..|
000047c0  4c 44 4d 45 41 09 73 74  6b 21 2c 20 7b 66 6e 2c  |LDMEA.stk!, {fn,|
000047d0  20 74 32 7d 09 09 09 3b  64 69 73 63 61 72 64 20  | t2}...;discard |
000047e0  6e 25 20 26 20 72 65 74  75 72 6e 0a 09 4d 4f 56  |n% & return..MOV|
000047f0  53 09 70 63 2c 20 74 32  0a 0a 0a 09 47 42 4c 41  |S.pc, t2....GBLA|
00004800  09 63 6f 75 6e 74 65 72  0a 0a 62 69 74 70 61 74  |.counter..bitpat|
00004810  6c 65 6e 0a 09 4d 4f 56  53 09 74 32 2c 20 66 6e  |len..MOVS.t2, fn|
00004820  0a 09 4d 4f 56 09 66 6e  2c 20 23 30 0a 63 6f 75  |..MOV.fn, #0.cou|
00004830  6e 74 65 72 09 53 45 54  41 09 33 31 0a 09 57 48  |nter.SETA.31..WH|
00004840  49 4c 45 09 63 6f 75 6e  74 65 72 3e 30 0a 09 41  |ILE.counter>0..A|
00004850  44 44 4e 45 09 66 6e 2c  20 66 6e 2c 20 23 31 0a  |DDNE.fn, fn, #1.|
00004860  09 4d 4f 56 4e 45 53 09  74 32 2c 20 74 32 2c 20  |.MOVNES.t2, t2, |
00004870  4c 53 52 20 23 31 0a 09  4d 4f 56 45 51 53 09 70  |LSR #1..MOVEQS.p|
00004880  63 2c 20 6c 72 0a 63 6f  75 6e 74 65 72 09 53 45  |c, lr.counter.SE|
00004890  54 41 09 63 6f 75 6e 74  65 72 2d 31 0a 09 57 45  |TA.counter-1..WE|
000048a0  4e 44 0a 09 41 44 44 09  66 6e 2c 20 66 6e 2c 20  |ND..ADD.fn, fn, |
000048b0  23 31 0a 09 4d 4f 56 53  09 70 63 2c 20 6c 72 0a  |#1..MOVS.pc, lr.|
000048c0  0a 69 6d 6f 70 32 0a 09  4d 4f 56 09 74 31 2c 20  |.imop2..MOV.t1, |
000048d0  23 30 0a 63 6f 75 6e 74  65 72 09 53 45 54 41 09  |#0.counter.SETA.|
000048e0  31 36 0a 09 57 48 49 4c  45 09 63 6f 75 6e 74 65  |16..WHILE.counte|
000048f0  72 3e 30 0a 09 42 49 43  53 09 74 32 2c 20 66 6e  |r>0..BICS.t2, fn|
00004900  2c 20 23 32 35 35 0a 09  42 45 51 09 69 6d 6f 70  |, #255..BEQ.imop|
00004910  32 5f 6c 31 0a 09 4d 4f  56 09 66 6e 2c 20 66 6e  |2_l1..MOV.fn, fn|
00004920  2c 20 52 4f 52 20 23 33  30 0a 09 41 44 44 09 74  |, ROR #30..ADD.t|
00004930  31 2c 20 74 31 2c 20 23  32 35 36 0a 63 6f 75 6e  |1, t1, #256.coun|
00004940  74 65 72 09 53 45 54 41  09 63 6f 75 6e 74 65 72  |ter.SETA.counter|
00004950  2d 31 0a 09 57 45 4e 44  0a 09 4d 4f 56 09 66 6e  |-1..WEND..MOV.fn|
00004960  2c 20 23 2d 31 0a 09 4d  4f 56 53 09 70 63 2c 20  |, #-1..MOVS.pc, |
00004970  6c 72 0a 69 6d 6f 70 32  5f 6c 31 0a 09 4f 52 52  |lr.imop2_l1..ORR|
00004980  09 66 6e 2c 20 74 31 2c  20 66 6e 0a 09 4d 4f 56  |.fn, t1, fn..MOV|
00004990  53 09 70 63 2c 20 6c 72  0a 0a 70 6f 77 65 72 6f  |S.pc, lr..powero|
000049a0  66 32 0a 09 4d 4f 56 53  09 74 31 2c 20 66 6e 0a  |f2..MOVS.t1, fn.|
000049b0  09 4d 4f 56 09 66 6e 2c  20 23 30 0a 09 4d 4f 56  |.MOV.fn, #0..MOV|
000049c0  45 51 53 09 70 63 2c 20  6c 72 0a 63 6f 75 6e 74  |EQS.pc, lr.count|
000049d0  65 72 09 53 45 54 41 09  33 31 0a 09 57 48 49 4c  |er.SETA.31..WHIL|
000049e0  45 20 20 20 63 6f 75 6e  74 65 72 3e 30 0a 09 4d  |E   counter>0..M|
000049f0  4f 56 53 09 74 31 2c 20  74 31 2c 20 4c 53 52 20  |OVS.t1, t1, LSR |
00004a00  23 31 0a 09 41 44 44 43  43 09 66 6e 2c 20 66 6e  |#1..ADDCC.fn, fn|
00004a10  2c 20 23 31 0a 09 4d 4f  56 43 53 53 09 70 63 2c  |, #1..MOVCSS.pc,|
00004a20  20 6c 72 0a 63 6f 75 6e  74 65 72 09 53 45 54 41  | lr.counter.SETA|
00004a30  09 63 6f 75 6e 74 65 72  2d 31 0a 09 57 45 4e 44  |.counter-1..WEND|
00004a40  0a 09 4d 4f 56 53 09 70  63 2c 20 6c 72 0a 0a 0a  |..MOVS.pc, lr...|
00004a50  0a 09 45 4e 44 0a                                 |..END.|
00004a56