00000:  	jsb  00067 		Key CLR 	Entry Points
00001:  	go to  00277 		Error go to blinking display
00002:  	0 -> s8 		Key e^x 	When a key is hit, the row and column detected form a
00003:  	go to  00005 		Key ln 	6 bit key code and a “key down” signal is raised (status S0).
00004:  	1 -> s5 		Key log 	This is only one hard wired flag S0.
00005:  	1 -> s9 	  	In other machines (Woodstock) more flags are used
00006:  	1 -> s2 		Key x^y 	(PRGM, battery ok, etc).
00007:  	goto   02010 	  	The key code is “token”, a displacement to be added
00010:  	jsb  00264 		Key RCL 	to 0000 to build the entry point address of the code
00011:  	go to  00376 	  	serving the key.
00012:  	go to  00027 		Key STO 	For a math function key (eg. “sin”), the context is preserved
00013:  	go to  00060 		Key ! (rdwn) 	and parameters are stored in the registers ; for a “digit key”
00014:  	stack -> a 		Key x <> y 	(forming a number) the exponent of register A (a[x]) is used ;
00015:  	go to  00331 	  	saved before entering the entry point (eg. “dig6”) and restored after.
00016:  	0 -> a[w] 		Key 1/x 	 Here are from (hp35 keyboard) top to bottom,
00017:  	a + 1 -> a[p] 	  	the key codes (entry points) generated:
00020:  	0 -> b[w]
00021:  	select rom 1 		goto  asn12 	CLR=0, which is also the entry point for PWO (slide ON)
00022: dig6: 	a + 1 -> a[x] 		Key "6" 	e^x = 02, "ln" =  03, "log" = 04, "x^y" = 06
00023: dig5: 	a + 1 -> a[x] 		Key "5"
00024: dig4: 	a + 1 -> a[x] 		Key "4" 	tan = 50, "cos" = 52, "sin" = 53, "arc" = 54, "sqrt(x) = 56
00025:  	go to dig3
00026:  	jsb  00232 		Key "+" 	RCL = 10, "STO" = 12, "Rdwn" = 13, "x<>y" = 14, "1/x" = 16
00027:  	c exchange m 		Relay to "STO" routine
00030:  	m -> c 	  		CLX = 70, "EEX" = 72, "CHS" = 73, "ENTER^ = 76
00031:  	go to  00077
00032: dig3: 	a + 1 -> a[x] 		Key "3" 	"9" = 62, "8" = 63, "7" = 64, "-" = 66,
00033: dig2: 	a + 1 -> a[x] 		Key "2"
00034: dig1: 	a + 1 -> a[x] 		Key "1" 	"6" = 22, "5" = 23, "4" = 24, "+" = 26
00035:  	return
00036:  	3 -> p 			Key "*" (mult) 	"3" = 32, "2" = 33, "1" = 34,"x" = 36
00037:  	0 - c -> c[x]
00040:  	stack -> a 		Pi=42, "." = 43,"0" = 44,"/" = 46
00041:  	go to  00020
00042:  	go to  00164 		Key PI 	The “arc” key is a prefix : it raises flag 10.
00043:  	3 -> p 			Key "," (dec. Point)
00044:  	return 			Key "0' 	The memory locations of missing key codes (11, 15 etc) are used
00045:  	no operation 	  	by the code at the start of the routine)
00046:  	go to  00040 		Key "/" 	e.g. 00076 Key ENTER :
00047:  	1 -> s5 		Relay for "sin" 	c -> stack
00050:  	1 -> s1 		Key ""tan" 	clear status
00051:  	go to  00056 	  	shift right a[w]
00052:  	1 -> s9 		Key "cos" 	jsb fst2zx
00053:  	go to  00047 		Key "sin" 	…/…
00054:  	1 -> s10 		Key "arc"
00055:  	go to  00302
00056:  	0 -> b[w] 		Key SQR 	One exception though: missing key code 45 is a "no operation"
00057:  	goto   01060 	  	the only case on the HP 35 ROM
00060:  	down rotate 		Relay for rotate
00061:  	go to  00333 	  	These entry points must be studied dynamically as part
00062: dig9: 	a + 1 -> a[x] 		Key "9" 	of the "display and wait" routine. This is the paradigm of this class
00063: dig8: 	a + 1 -> a[x] 		Key "8" 	of calculators (Classic, Woodstock, Spice etc.
00064: dig7: 	a + 1 -> a[x] 		Key "7" 	One entry point is not the location where control starts
00065:  	go to dig6 	  	but where it passes to service a key.
00066:  	go to sub0 		Key "-" (sub)
00067:  	clear registers 	Relay for PWO and CLR 	General references are:
00070:  	jsb of12 		Key Clx 	"The key code tokens"
00071:  	go to fst2zx 	  	"The display and wait routine"
00072:  	go to eex2 		Key EEX
00073:  	shift right a[w]	Key CHS 	Math key routines are explained in the dedicated chapter:
00074:  	1 -> s3 		e.g. "ln" is described in "HP 35 Logarithm Algorithm"
00075:  	go to  00166 		Utility routines activated by keys like "ENTER" are
00076:  	c -> stack 		Key ENTER 	described in
00077:  	clear status
00100:  	shift right a[w] 	“Status bit flags”,
00101:  	jsb fst2zx 	  	“Digit Entry”. You should start with "HP35 Operating software", “Overall firmware architecture”.
00102: 		a -> b[w] 		Number format conversion 	Ref : “Output format”
00103:  	0 -> a[xs] 		0102-0113
00104:  	shift left a[ms]	Routines 0102-0113 and 0340-0361 handle the 4 type of display and automatic conversion
00105:	 	a - 1 -> a[x] 	 	in scientific notation (SN):
00106:  	if no carry go to 0340 	1- numbers to be displayed as "100." : 107-346-361
00107:  	if c[xs] = 0 		2- numbers to be displayed as ".01"   : 107-111-346-361
00110:  	 then go to 0346 	3- numbers to be displayed as "1 10-12  : 106-340-346-361
00111:  	a exchange b[ms] 	4- numbers to be displayed as “1012” :106-340-346-361
00112: 		13 -> p 		(results > than 1010 or < are 10-2 automatically converted in SN).
00113: 		go to 0346
  	  	At 0106 the floating-point exponent sign (in A) is tested <> 0 : if no carry (<> 0)
  	  	 control branches at 0340, if carry (fp = 0) goto 0107.
  	  	This is the two SN cases (no carry) forms like : "1 10-12 and “1012”
  	  	At 0107 the normalized exponent signed is tested = 0 or not.
  	  	If = 0 goto 0346 and not follow thru 110 etc.
  	  	This is the two other cases : exp. sign = 0 (0346) forms like “100.” and exp sign <> 0
  	  	 forms like “.01” (decimal point first).
  	  	Code between 0102-0113 is roughly sorting the 4 cases.
  	  	Code between 0340–0361 is building the mask and adjusting floating point
  	  	representation. The loop 0342-0105 is decrementing and SR A and
  	  	decrementing pointer p is doing the SN conversion.
00114:eex7: 	p - 1 -> p 		Exponent building (loop "eex7-eex8")
00115:  	c + 1 -> c[x] 		Mask in B is used (swept from left to right) to build exponent part of C
00116:eex8: 	if b[p] = 0 		in the loop "eex7"-"eex8"
00117:  	then go to eex7
00120:  	1 -> s11 		number has been entered mantissa first (other case is "1 00")
00121:  	shift right a[ms] 	(tested in 0363)
00122:  	a exchange c[m] 	Floating Point in A
00123:  	if s4 = 0 		S4=1 EEX has been pressed, if S4=0 goto "den1"
00124:  	then go to den1 	(flag set in 0362)
00125:  	jsb of14 		Exponent entered with EEX, call output ofrmat
00126:  	go to fst2zx 		go display and wait
00127:of11: 	0 -> c[wp] 		OVER and UNDERFLOW conditions
00130:  	c - 1 -> c[wp] 		Math routines signal their out of limit status (exp C = 900 or 100)
00131:  	0 -> c[xs] 		display is built accordingly
00132:  	a + b -> a[x] 		9.999999999 or 0.
00133:  	if no carry go to of13
00134:of12: 	0 -> c[w] 		CLR and PWO entry points
00135:of13: 	clear status 		Return form maths routine, format the output
00136:  	c -> a[w] 		build the output context (using normalized form in C, make FP in A and mask in B)
00137:of14: 	12 -> p 		Init context
00140:  	a -> b[x]
00141:  	c -> a[x]
00142:  	if c[xs] = 0 		Normal negative or overflow/underflow ?
00143:  	then go to of15
00144:  	0 - c -> c[x]
00145:  	c - 1 -> c[xs]
00146:  	if no carry go to of11 	test for over/underflow
00147:  	5 -> p
00150:of15: 	a exchange c[x]
00151:  	if s4 = 0 		if EEX Not pressed goto 0102 (normal path)
00152:  	then go to l00102
00153:  	a exchange b[x] 	If EEX key pressed
00154:  	0 -> b[x] 		build the "1 00" mask
00155:  	jsb dsp1
00156:  	shift left a[x] 	and fall thru "eex3"
00157:eex3: 	shift right a[w] 	Exponent entry (exponent digits)  Ref : “Digits entry”
00160:  	if p # 12 		from eex2 0360 (see eex2 at 0363)
00161:  	then go to den7 	if S11=0 mantissa entered, 2 cases
00162:  	a exchange c[wp] 	p=12, main case, eex4-eex5-eex6-eex7-eex8-0123-of14-fst2zx
00163:  	go to eex4 		p=3 after a "." -> den7
00164:l00164: jsb l00264 		This is the code for the pi constant
00165:  	select rom 1 		address = 1264
00166:l00166: if s4 = 0 		CHS entry point
00167:  	then go to chs3 	if EEX was pressed S4=1
00170:  	a exchange c[wp] 	negate mantissa in C
00171:  	0 - c - 1 -> c[xs] 	else goto "chs3" main entry point to negate C mantissa
00172:eex4: 	c -> a[w] 		Exponent entry (exponent digits)  Ref : “Digits entry”
00173:  	if c[xs] = 0 		(this is new ROM algorithm, buggy old roms are different))
00174:  	then go to eex5 	2 ways to enter exp digits:
00175:  	0 -> c[xs] 		- sign digits "." digits
00176:  	0 - c -> c[x] 		- sign digits EEX digits sign
00177:eex5: 	13 -> p 		Entry point is eex4 from den6
00200:eex6: 	shift left a[ms]
00201:  	c - 1 -> c[x] 		When no exponent the loop 0204-eex6 preserves leading zeros (ex. "000123")
00202:  	if a[s] >= 1 		The loop "eex8-exx7" actually build the normalized exponent in C
00203:  	then go to eex8 	For numbers enterd with "." the âth is "den6" 0373 0375
00204:  	if a[ms] >= 1 		For numbers entered with EEX the entry poin is "eex2 at 0362
00205:  	then go to eex6
00206:  	0 -> c[x]
00207:den1: 	jsb dsp1 		Data entry (digits & numbers)  Ref : “Digits entry”
00210:  	shift right a[ms] 	A number is entered using numeric key, decimal point “.”, “EEX” key and CHS key.
00211:den7: 	c -> a[s] 		“den2” is the main entry point (the digit just got is in a[x]), pointer p = 12 when entering
00212:den2: 	if p # 12 		digits but p=2 if dp “.” is pressed.
00213:  	then go to den4 	Code between “den2” & “den4” places the new digit in place
00214:  	b -> c[w] 		according the current mask in B.
00215:  	c + 1 -> c[w] 		In "den3" digits are "slided" in place
00216:  	1 -> p 			Exit point is “den5” or “den6” whether dp has been used.
00217:den3: 	shift left a[wp] 	Normal exit thru “den6” updates the current mask (a digit can be part of a number).
00220:  	p + 1 -> p 		A call to “eex4” is made (regular entry point in EEX) to normalized the exponent in C.
00221:  	if c[p] = 0 		If there is a “.” Control goes to “den5” and then “den6”
00222:  	then go to den3 	where the current mask is updated.
00223:den4: 	a exchange c[w] 	This is the normal exit point.
00224:  	if p # 3 		If no “.” control goes to “eex4” to form exponent in C
00225:  	then go to den5
00226:  	0 -> c[x]
00227:  	1 -> s6 		(see "den 5" and "den6" below)
00230:  	go to eex4
00231:sub0: 	0 - c - 1 -> c[s] 	Floating point addition and subtraction (Ref: Floating point Arithmetic)
00232:l00232: stack -> a 		If the operation is a subtraction, the code is exactly the same but entry point is "sub0"
00233:  	0 -> b[w] 		The first action of the code is to drop values from the stack, to have Y in A
00234:  	a + 1 -> a[xs] 		Next B is zeroed
00235:  	a + 1 -> a[xs] 		Exponents of registers A and C are corrected so absolute values can be compared.
00236:  	c + 1 -> c[xs] 		The exponent comparison is by adding two to exponent and sign fields
00237:  	c + 1 -> c[xs] 		of both registers A and C.
00240:  	if a >= c[x] 		At 0240 the comparison is done.
00241:  	then go to add4 	If a[x] > = c[x] (exponent of C smaller then exponent of A), we will simply exchange
00242:  	a exchange c[w] 	both registers, so that the smallest number is always in C and the biggest in A.
00243:add4: 	a exchange c[m]
00244:  	if c[m] = 0 		Mantissa alignment : biggest fraction part will be shifted right (division by 10)
00245:  	then go to add5 	and the exponent of biggest number will be incremented.
00246:  	a exchange c[w]
00247:add5: 	b exchange c[m] 	Next in routine “add4”, exponent and fraction parts of both numbers
00250:add6: 	if a >= c[x] 		are separated. At “add6” fraction part alignment is done and exit at 0276
00251:  	then go to l00276 	when both fractional part are aligned. In routine “add12”,
00252:  	shift right b[w] 	signs are processed to do the “addition” or “subtraction.
00253:  	a + 1 -> a[x]
00254:  	if b[w] = 0
00255:  	then go to l00276 	goto "add12" thru a relay at 0276
00256:  	go to add6
00257:fst3: 	0 -> a[ms] 		Stack handling routine
00260:  	if s3 = 0
00261:  	then go to l00264
00262:  	a - 1 -> a[s] 		If "CHS" flag S3=1
00263:  	0 - c - 1 -> c[s] 	negate C mantissa sign
00264:l00264: if s7 = 0 		S7=1 automatic push
00265:  	then go to fst5 	S7 = 0 : no stack push
00266:  	c -> stack 		stack push
00267:fst5: 	1 -> s7 		mask as done
00270:  	0 -> c[w] 		build mask for a digit "29999…999"
00271:  	c - 1 -> c[w] 		d°
00272:  	0 - c -> c[s] 		d°
00273:  	c + 1 -> c[s] 		d°
00274:  	b exchange c[w]
00275:  	return
00276:l00276: select rom 1 		relay to "add12" addr=1276
00277:l00277: jsb of12 		ERROR entry point
00300:  	1 -> s5 		Set flag for blinking display
00301:  	go to fst2zx 		go to the farm
00302:l00302: shift right a[w] 	DISPLAY AND WAIT FOR A KEY
00303:dsp7: 	c -> a[s] 		ntry point, called from disp1
00304:l00304: 0 -> s8
00305:  	go to dsp8
00306:dsp2: 	c + 1 -> c[xs]
00307:dsp3: 	1 -> s8 		dsp3-dsp5 Main IDLE loop
00310:  	if s5 = 0 		In the middle of it, blink the display
00311:  	then go to dsp5
00312:  	c + 1 -> c[x]
00313:  	if no carry go to dsp2
00314:dsp4: 	display toggle
00315:dsp5: 	if s0 = 0 		No key, so "once around"
00316:  	then go to dsp3
00317:dsp8: 	0 -> s0 		 KEY has been pressed
00320:dsp6: 	p - 1 -> p
00321:  	if p # 12 		disp6-0322 : debounce loop
00322:  	then go to dsp6
00323:  	display off
00324:  	if s8 = 0 		make sure a key is served only once
00325:  	then go to dsp4
00326:  	shift left a[w]
00327:  	0 -> s5
00330:  	keys -> rom address 	jump to token address
00331:l00331: c -> stack 		Exchange x><y entry point
00332:  	a exchange c[w]
00333:l00333: jsb of13 		Return point 	Ref : “Digits entry”
00334:  	1 -> s7
00335:fst2zx: jsb dsp1 		00333 is the main return point when a math routine is completed.
00336:  	jsb fst3 		A call to of13 is made to format the display (A & B with C)
00337:  	go to den2 		Flag 7 is raised to request a stack push.
  		Then back to the “display and wait” loop at “fst2zx”
  	  	When a key is hit, the “return” instruction brings back to 00336 where the stack
  	  	chore is made, before going servicing the key entry.
01340:l00340: shift right a[ms] 	Mask building routines 	Ref : “Output format”
01341:  	p - 1 -> p 		0340-0361
01342:  	if p # 2 		Code between 0340-0345 is run only by SN numbers (FP exponent in A <> 0).
01343:  	then go to l00105 	Numbers are converted if possible to fixed format : 1. 03 -> 1000
01344:  	12 -> p
01345:  	0 -> a[w] 		Note that in the 35 this conversion occurs
01346:l00346: 0 -> a[ms] 		only on math routine return.
01347:  	a + 1 -> a[p]
01350:  	a + 1 -> a[p] 		Code between 0346-0361 is positioning the decimal point
01351:  	2 -> p 			in the mask “.” = “2” and filling the digits to be blanked with “9”.
01352:l00352: p + 1 -> p 		This code decides if exponent is blanked or not :
01353:  	a - 1 -> a[p] 		if entry point is 0346 the exponent in the mask is “999” = blanked.
01354:  	if no carry go to l00357
01355:  	if b[p] = 0
01356:  	then go to l00352
01357:l00357: a + 1 -> a[p]
01360:  	a exchange b[w]
01361:  	return
01362:eex2: 	1 -> s4 		Exponent entry (exponent digits) Ref : “Digits entry” 0362-0365
01363:  	if s11 = 0 		3 cases : Exponent entered with EEX ( eex key fist or after mantissa)
01364:  	then go to dig1 	If EEX key : entry point is “eex2”, If EEX pressed first, goto dig1, to make mask "1 00"
01365:  	go to eex3 		If not (mantissa built first) goto “eex3” to build the exponent. In C and the display mask.
01366:chs3: 	0 - c - 1 -> c[s] 	CHS was used, negate C sign
01367:dsp1: 	0 -> s10 		Entry point in "display and wait a key" loop fom point "fst2zx"
01370:  	go to dsp7 		Route back from math routines : 0333-"of13"-"fst2zx-"dsp1"
01371:den5: 	if s6 = 0 		If s6=0 make room for the decimal point "."
01372:  	then go to den6
01373:  	p - 1 -> p 		If s6=1 make 2 places
01374:den6: 	shift right b[wp]
01375:  	jsb eex4 		and "eex4" will build the mask accordingly
01376:l00376: m -> c 			The code for RCL
01377:  	go to l00333 		Place m into register C and back to the farm
01000: 	  	go to tan13 	Control comes from â€œtan14â€  01377 (Cordic rotations)
01001: 	tan15: 	a exchange b[w] End of Cordic rotations, A=X C=Y (vectors)
01002: 	  	jsb tnm11 	Goto normalize both vector numbers
01003: 	  	stack -> a
01004: 	  	jsb tnm11 	Get the other from the stack
01005: 	  	stack -> a
01006: 	  	if s9 = 0 	If cos case, we need cot(θ) then we exchange X and Y
01007: 	  	then go to tan16 	to compute cot(θ) in place of tan(θ)
01010: 	  	a exchange c[w]
01011: 	tan16: 	if s5 = 0 	If tan(θ) the exit door is â€œasn12â€
01012: 	  	then go to asn12 	Else if  sin or cos :
01013: 	  	0 -> c[s] 	we compute tan calling â€œdiv11â€ X/Y
01014: 	  	jsb div11
01015: 	l01015: c -> stack 	Code for arc sin
01016: 	  	jsb mpy11 	compute tan2 to use in formula sin= tan / SQR (1 + tan2 )
01017: 	  	jsb add10 	â€œadd10â€ makes 1 +  tan2
01020: 	  	jsb sqt11 	get other vector from the stack before calling â€œdiv11â€
01021: 	  	stack -> a
01022: 	asn12: 	jsb div11 	â€œasn12â€ : normal path for  tan(θ) computing A/C or tan/SQR(1 + tan2 )
01023: 	  	if s10 = 0 	if direct trigo returns via â€œrtn12â€ to dsp loop 0333
01024: 	  	then go to rtn12 	or execute a return if came from a jsb in Cordic rotations
01025: 	atn11: 	0 -> a[w] 	arc tan main entry point
01026: 	  	a + 1 -> a[p] 	arc tan(Z) angle Z in C
01027: 	  	a -> b[m] 	B=1
01030: 	  	a exchange c[m] 	The â€œatn12â€ loop aligns A and B according exp of C
01031: 	atn12: 	c - 1 -> c[x]
01032: 	  	shift right b[wp]
01033: 	  	if c[xs] = 0
01034: 	  	then go to atn12 	â€œatn13â€:  A= Z /10  B= X/100  C= exp
01035: 	atn13: 	shift right a[wp]
01036: 	  	c + 1 -> c[x]
01037: 	  	if no carry go to atn13
01040: 	  	shift right a[w] 	A = Z
01041: 	  	shift right b[w] 	B = qj
01042: 	  	c -> stack 		C = X
01043: 	atn14: 	b exchange c[w]
01044: 	  	go to atn18 		Goto Cordic rotations (pseudo division)
01045: 	sqt11: 	b exchange c[w] 	SQR(X) Entry point
01046: 	  	4 -> p	 		A=X B=X C=0
01047: 	  	go to sqt14 		p=4
01050: 	tnm11: 	c -> stack 		Called in tan15 (means â€œto normalizationâ€: relay to nrm21, via add15)
01051: 	  	a exchange c[w] 	A is popped from stack
01052: 	  	if c[p] = 0 		C is pushed, p=12
01053: 	  	then go to tnm12
01054: 	  	0 - c -> c[w]
01055: 	tnm12: 	c -> a[w] 		absolute value of C is copied to A
01056: 	  	b -> c[x] 		format registers to normalize C with std routine â€œnrm21â€
01057: 	  	go to add15
01060: 	  	c -> a[w] 		The BIG SWITCH
01061: 	  	if s1 = 0 	        S1      S5    S9    S10         (S1 = 0 : SQR)
01062: 	  	then go to sqt11 	TAN                        1(S10=0 : direct trigo)
01063: 	  	if s10 = 0 		ARC TAN                    1                          1
01064: 	  	then go to l01155 	SIN                               1        1
01065: 	  	if s5 = 0 		ARC SIN                      1        1                1
01066: 	  	then go to atn11 	COS                              1       1       1
01067: 	  	0 - c - 1 -> c[s] 	ARC COS                     1       1       1        1
01070: 	  	a exchange c[s]
01071: 	  	go to l01015
01072: 	atn15: 	shift right b[wp] 	ARC TAN
01073: 	atn16: 	a - 1 -> a[s] 		1) Cordic rotations to compute the qj â€“ pseudo quotients)
01074: 	  	if no carry go to atn15 To reduce component Y to zero (pseudo division)
01075: 	  	c + 1 -> c[s]
01076: 	  	a exchange b[wp]
01077: 	  	a + c -> c[wp] 		01077 is the rotation
01100: 	  	a exchange b[w]
01101: 	atn18: 	a -> b[w] 		pseudo division entry point is â€œatn18â€
01102: 	  	a - c -> a[wp]
01103: 	  	if no carry go to atn16
01104: 	  	stack -> a 		2) Pseudo multiplication (starting at 01104)
01105: 	  	shift right a[w] 	∑ qj tan-1 10 â€“j
01106: 	  	a exchange c[wp] 	use stack to store intermediate results (top of stack lost)
01107: 	  	a exchange b[w]
01110: 	  	shift left a[wp]
01111: 	  	c -> stack
01112: 	  	a + 1 -> a[s] 		01114 Test for more rotations (max = 5)
01113: 	  	a + 1 -> a[s]
01114: 	  	if no carry go to atn14
01115: 	  	0 -> c[w] 		No more rotations
01116: 	  	0 -> b[x] 		Clear context
01117: 	  	shift right a[ms] 	And compute Y/X
01120: 	  	jsb div14 		If direct trigo S1=1 then after â€œdivâ€ : rtn12 and return at 01121
01121: 	  	c - 1 -> c[p] 		Control gets back here via â€œrtn11â€, â€œrtn12â€ and â€œreturnâ€
01122: 	  	stack -> a
01123: 	  	a exchange c[w] 	Prepare context
01124: 	  	4 -> p
01125: 	  	jsb pqo13 		Call pseudo multiplication PM ( note in pqo13, select rom 2, use the log routines)
01126: 	  	6 -> p 			load constant arc (0.0001) = 0.000099999999666
01127: 	  	jsb pmu11 		and do the PM
01130: 	  	8 -> p 			load arc ( 0.001) = 0.000999999666
01131: 	  	jsb pmu11 		and do the PM
01132: 	  	2 -> p 			load arc ( 0.01) = 0.0099996666866
01133: 	  	load constant 8
01134: 	  	10 -> p
01135: 	  	jsb pmu11 		and do the PM
01136: 	  	jsb atcd1 		load arc ( 0.1) = 0.099668652496
01137: 	  	jsb pmu11 		and do the PM
01140: 	  	jsb atc1 		load arc ( 1) = π / 4
01141: 	  	shift left a[w] 	and do the PM
01142: 	  	jsb pmu11 		Angle in A in radians
01143: 	  	b -> c[w]
01144: 	  	jsb add15 		goto normalize
01145: 	  	jsb atc1 		convert to degree (load π / 4)
01146: 	  	c + c -> c[w] 		double it
01147: 	  	jsb div11 		divide A by π / 2 so a multiplication by 90 will do the job
01150: 	  	if s9 = 0 		If S9 = 0 arc tan, arc sin
01151: 	  	then go to l01154
01152: 	  	0 - c - 1 -> c[s] 	Else itâ€™s â€œarc cosâ€ : negate previous result : - arc sin
01153: 	  	jsb add10 		add it to π / 2 ( arc cos = π / 2 â€“ arc sin)
01154: 	l01154: 0 -> s1 		To return via â€œrtn2â€ at 01160 and in â€œrtn11â€ (after â€œmpy11â€:nrm21,rtn11, rtn12, 0333.
01155: 	l01155: 0 -> c[w] 		Direct Trigo (tan, cos, sin)
01156: 	  	c - 1 -> c[p] 		Build number 90 in C
01157: 	  	c + 1 -> c[x]
01160: 	  	if s1 = 0 		Multiplication in â€œmpy11â€ will convert  to degree
01161: 	  	then go to mpy11
01162: 	  	jsb div11 		θ/90 in (θ/90 x π / 2 = π / 180)
01163: 	  	jsb atc1
01164: 	  	c + c -> c[w]
01165: 	  	jsb mpy11
01166: 	  	jsb atc1 		load π / 4
01167: 	  	c + c -> c[w] 		double
01170: 	  	c + c -> c[w] 		double = π
01171: 	  	jsb rtn11 		exit door when S1=0 (SQR)
01172: 	  	c + c -> c[w] 		double again = 2π
01173: 	  	jsb pre11 		angle prescaling : 0 <= θ < 2π
01174: 	  	jsb atc1 		load π / 4, arc tan(1)
01175: 	  	10 -> p
01176: 	  	jsb pqo11 		pseudo division
01177: 	  	jsb atcd1 		load arc tan(0.1)
01200: 	  	8 -> p
01201: 	  	jsb pqo12 		2nd pdiv
01202: 	  	2 -> p 			load arc tan(0.01)
01203: 	  	load constant 8
01204: 	  	6 -> p 			3th pdiv
01205: 	  	jsb pqo11 		load arc tan(0.001)
01206: 	  	4 -> p 			4th pdiv
01207: 	  	jsb pqo11 		load arc tan(0.0001)
01210: 	  	jsb pqo11 		5th pdiv
01211: 	  	a exchange b[w]
01212: 	  	shift right c[w]
01213: 	  	13 -> p
01214: 	  	load constant 5 	remainder in A, pq in B
01215: 	  	go to tan14 		goto cordic PM 5 times
01216: 	atcd1: 	6 -> p 			Forge constant constant arc tan(0.1)  with pattern â€œ865249â€
01217: 	  	load constant 8 	See note on Cst forging
01220: 	  	load constant 6
01221: 	  	load constant 5
01222: 	  	load constant 2
01223: 	  	load constant 4
01224: 	  	load constant 9
01225: 	rtn11: 	if s1 = 0 		Locally S1 is used to switch return from â€œasn12â€
01226: 	  	then go to rtn12 	via rtn12 and finally to 0333 -> dsp loop
01227: 	  	return 			if S1=1 = trigo, if S1=0 ) ln and e^x ; s1 is set ot zero at 01154
01230: 	add10: 	0 -> a[w] 		Arc cos
01231: 	  	a + 1 -> a[p] 	 	= π / 2 â€“ arc sin
01232: 	  	select rom 0 	  	; -> l00233
01233: 	pmu11: 	select rom 2 	  	WARNING destructured code : read it dynamically
01234: 	pqo11: 	shift left a[w] 	Pseudo division entry point in direct trigo
01235: 	pqo12: 	shift right b[ms]
01236: 	  	b exchange c[w] 	Prepare registers
01237: 	  	go to pqo16
01240: 	pqo15: 	c + 1 -> c[s]
01241: 	pqo16: 	a - b -> a[w] 		(01241) the pseudo division, by repeated subtractions
01242: 	  	if no carry go to pqo15
01243: 	  	a + b -> a[w] 		Restore previous
01244: 	pqo13: 	select rom 2 		goto 02245 (rom 2) â€œpqo23â€ to load constant and do the pm
01245: 	mpy11: 	select rom 2 		Computes tan2   and cot2 in sin and cos formulas
01246: 	div11: 	a - c -> c[x] 		A/C in direct trio (vectors dividing)
01247: 	  	select rom 2
01250: 	sqt15: 	c + 1 -> c[p]
01251: 	sqt16: 	a - c -> a[w] 		12 bit mantissa longhand routine
01252: 	  	if no carry go to sqt15 using a 5delta remainder
01253: 	  	a + c -> a[w]
01254: 	  	shift left a[w]
01255: 	  	p - 1 -> p
01256: 	sqt17: 	shift right c[wp]
01257: 	  	if p # 0
01260: 	  	then go to sqt16
01261: 	  	go to tnm12 		goto normalization
01262: 	div14: 	c + 1 -> c[p] 		p = 12 	Core dividing loop
01263: 	div15: 	a - b -> a[ms] 		C holds subtractions count
01264: 	  	if no carry go to div14 performs division by repeated subtractions
01265: 	  	a + b -> a[ms] 		here we reverse gear : on step too far
01266: 	  	shift left a[ms]
01267: 	  	p - 1 -> p 		sweeps C from 12 to 0
01270: 	  	if p # 0
01271: 	  	then go to div15 	Routine Entry point = 01271 !!
01272: 	  	go to tnm12 		goto normalization
01273: 	sqt12: 	p - 1 -> p
01274: 	  	a + b -> a[ms]
01275: 	  	if no carry go to sqt18 SQR(negative) -> error or loop to build delta remainder
01276: 	  	select rom 0 		go to blinking display 0277
01277: 	add12: 	c - 1 -> c[xs] 		came from 00276
01300: 	  	c - 1 -> c[xs] 		Restore exp C
01301: 	  	0 -> a[x] 		zero exp A
01302: 	  	a - c -> a[s] 		exp comparison
01303: 	  	if a[s] >= 1 		if exp C < exp A
01304: 	  	then go to add13
01305: 	  	select rom 2 		goto core adder 02306
01306: 	add13: 	if a >= b[m] 		else compare fraction part
01307: 	  	then go to add14 	if FP A < FP B then change sign before subtraction
01310: 	  	0 - c - 1 -> c[s]
01311: 	  	a exchange b[w]
01312: 	add14: 	a - b -> a[w] 		simply perform subtraction in the other case
01313: 	add15: 	select rom 2 		goto normalize at "nrm21"
01314: 	atc1: 	0 -> c[w] 		load π / 4
01315: 	  	11 -> p
01316: 	  	load constant 7
01317: 	  	load constant 8
01320: 	  	load constant 5
01321: 	  	load constant 3
01322: 	  	load constant 9
01323: 	  	load constant 8
01324: 	  	load constant 1
01325: 	  	load constant 6
01326: 	  	load constant 3
01327: 	  	load constant 5
01330: 	  	12 -> p
01331: 	  	return
01332: 	rtn12: 	select rom 0 		back to the LOOP 0333
01333: 	sqt18: 	a + b -> a[x] 		mantissa multimplied by 5
01334: 	  	if no carry go to sqt14 p point 5 to 0
01335: 	  	c - 1 -> c[p]
01336: 	sqt14: 	c + 1 -> c[s] 		delta remainder is built
01337: 	  	if p # 0
01340: 	  	then go to sqt12
01341: 	  	a exchange c[x] 	prepare registers for core routine
01342: 	  	0 -> a[x]
01343: 	  	if c[p] >= 1 		A and C are aligned
01344: 	  	then go to sqt13
01345: 	  	shift right a[w]
01346: 	sqt13: 	shift right c[w]
01347: 	  	b exchange c[x]
01350: 	  	0 -> c[x]
01351: 	  	12 -> p
01352: 	  	go to sqt17 		go to core routine
01353: 	pre11: 	select rom 2 		go to prescaling in rom 2 ("pre21")
01354: 	tan18: 	shift right b[wp] 	do the SR twice
01355: 	  	shift right b[wp]
01356: 	tan19: 	c - 1 -> c[s] 		again
01357: 	  	if no carry go to tan18
01360: 	  	a + c -> c[wp] 		no more SR
01361: 	  	a - b -> a[wp] 		X + Z -> Z
01362: 	  	b exchange c[wp] 	A â€“ B -> A
01363: 	tan13: 	b -> c[w] 		Continuation if Cordic rotation
01364: 	  	a - 1 -> a[s] 		update â€œ of times this rotation was made (pqj)
01365: 	  	if no carry go to tan19 check if over
01366: 	  	a exchange c[wp]
01367: 	  	stack -> a
01370: 	  	if b[s] = 0 		if no more rotation for a pqj goto â€œtan15â€ (01001)
01371: 	  	then go to tan15 	next pqj
01372: 	  	shift left a[w]
01373: 	tan14: 	a exchange c[wp] 	entry point in tan cordic rotations
01374: 	  	c -> stack 		Result saved in the stack
01375: 	  	shift right b[wp] 	Prepare for rotation, A = X  B = Y (angle)
01376: 	  	c - 1 -> c[s] 		update #of rotations c[s]
01377: 	  	b exchange c[s] 	continuation at 01000 â€œtan13â€
02000: 	err21: 	select rom 0 		goto blinking display (0001)
02001: 	ln24: 	a exchange b[s] 	Computation of a new constant (2, 1.1, 1.01, 1.001 etc)
02002: 	  	a + 1 -> a[s] 		# SR ++
02003: 	  	shift right c[ms] 	Make room for the next qj
02004: 	  	shift left a[wp] 	align left
02005: 	  	go to ln26
02006: 	xty22: 	stack -> a 		ax  is evaluated as ln(a) . x (see at 02074)
02007: 	  	jsb mpy21
02010: 	  	c -> a[w] 		Main entry point for ex and log
02011: 	  	if s8 = 0 		If S8 = 0 -> ex
02012: 	  	     then go to exp21 	If S8 = 1 -> log (ln)
02013: 	  	0 -> a[w]
02014: 	  	a - c -> a[m] 		Complement X for ln(X)
02015: 	  	if no carry go to err21 Goto error if ln(negative)
02016: 	  	shift right a[w]
02017: 	  	c - 1 -> c[s]
02020: 	  	if no carry go to err21
02021: 	ln25: 	c + 1 -> c[s] 		Prepare registers to compute pseudo quotients q0 q1 â€¦ q5
02022: 	ln26: 	a -> b[w]
02023: 	  	jsb eca22 		Call the "eca" routine to compute qj
02024: 	  	a - 1 -> a[p] 		complementation
02025: 	  	if no carry go to ln25 	one more time for the same constant
02026: 	  	a exchange b[wp]
02027: 	  	a + b -> a[s] 		# of SR x 2
02030: 	  	if no carry go to ln24 	test for 5 constants only
02031: 	  	7 -> p 			Part 2 : pseudo multiplications to compute ∑ qj ln (1 + 10 â€“j)
02032: 	  	jsb pqo23
02033: 	  	8 -> p
02034: 	  	jsb pmu22 		q5 ln(1.00001)
02035: 	  	9 -> p
02036: 	  	jsb pmu21 		q4 ln(1.0001)
02037: 	  	jsb lncd3 	  	             S2     S5     S9
02040: 	  	10 -> p 	  	ln          1         0       1
02041: 	  	jsb pmu21 		q3 ln(1.001) 	log        1        1        0
02042: 	  	jsb lncd2 	  	ex         1         0        1
02043: 	  	11 -> p 	  	xy             1        0        0
02044: 	  	jsb pmu21 		q2 ln(1.01)
02045: 	  	jsb lncd1
02046: 	  	jsb pmu21 		q1 ln(1.1)
02047: 	  	jsb lnc2
02050: 	  	jsb pmu21 		q0 ln 2
02051: 	  	jsb lnc10 		load ln 10
02052: 	  	a exchange c[w]
02053: 	  	a - c -> c[w] 		final sum, result in C
02054: 	  	if b[xs] = 0 		Exponent processing
02055: 	  	then go to ln27
02056: 	  	a - c -> c[w]
02057: 	ln27: 	a exchange b[w]
02060: 	ln28: 	p - 1 -> p 		p=12 on entry (nrm27)
02061: 	  	shift left a[w] 	SL A (A = X)
02062: 	  	if p # 1 		to prepare A and have A sign in 12th position
02063: 	  	then go to ln28 	and A exp digits in 11 and 10th positions
02064: 	  	a exchange c[w] 	A -> C
02065: 	  	if c[s] = 0 		test sign of exponent
02066: 	  	then go to ln29
02067: 	  	0 - c - 1 -> c[m] 	invert if negative
02070: 	ln29: 	c + 1 -> c[x] 		go to normalize C (mantissa in A, exponent in C)
02071: 	  	11 -> p 		(eg if ln(7.3 1043) C = [04300â€¦]
02072: 	  	jsb mpy27
02073: 	  	if s9 = 0 		case xy
02074: 	  	then go to xty22
02075: 	  	if s5 = 0 		log or ln
02076: 	  	then go to rtn21
02077: 	  	jsb lnc10 		if log -> multiply by ln(10)
02100: 	  	jsb mpy22 		return to normalize and loop.
02101: 	  	go to rtn21
02102: 	exp21: 	jsb lnc10 		Load ln(10)
02103: 	  	jsb pre21 		prescaling x between 0 and 1
02104: 	  	jsb lnc2 		pseudo division by repeating subtraction to find the qj
02105: 	  	11 -> p 		load ln(2)
02106: 	  	jsb pqo21 		compute q0 by pseudo division
02107: 	  	jsb lncd1 		load ln(1.1)
02110: 	  	10 -> p
02111: 	  	jsb pqo21 		compute q1 by pseudo division
02112: 	  	jsb lncd2 		load ln(1.01)
02113: 	  	9 -> p
02114: 	  	jsb pqo21 		compute q2 by pseudo division
02115: 	  	jsb lncd3 		load ln(1.001)
02116: 	  	8 -> p
02117: 	  	jsb pqo21 		compute q3 by pseudo division
02120: 	  	jsb pqo21 		load ln(1.0001) compute q4 by pseudo division
02121: 	  	jsb pqo21 		load ln(1.00001) compute q5 by pseudo division
02122: 	  	6 -> p 			precision rectification to avoid algorithm flaw e ln(2.02) = 2
02123: 	  	0 -> a[wp]
02124: 	  	13 -> p 		Part 2 : Pseudo multiplication
02125: 	  	b exchange c[w]
02126: 	  	a exchange c[w]
02127: 	  	load constant 6
02130: 	  	go to exp23 		ex = (1 + r) Π ( 1 + 10-j) qj
02131: 	pre23: 	if s2 = 0 		Trigo prescaling
02132: 	  	then go to pre24 	Θ - 2 π by repeated subtractions until remainder is between 0 and 2 π
02133: 	  	a + 1 -> a[x]
02134: 	pre29: 	if a[xs] >= 1
02135: 	  	then go to pre27
02136: 	pre24: 	a - b -> a[ms] 		Sub in loop
02137: 	  	if no carry go to pre23
02140: 	  	a + b -> a[ms] 		Restore one step too far
02141: 	  	shift left a[w] 	Save accuracy
02142: 	  	c - 1 -> c[x] 		# of decades in C
02143: 	  	if no carry go to pre29
02144: 	pre25: 	shift right a[w]
02145: 	  	0 -> c[wp]
02146: 	  	a exchange c[x]
02147: 	pre26: 	if c[s] = 0 		common part for prescaling trigo end ex
02150: 	  	then go to pre28
02151: 	  	a exchange b[w] 	if sign is negative
02152: 	  	a - b -> a[w] 		exchange A and C, A scaled argument B = ln(10)
02153: 	  	0 - c - 1 -> c[w] 	invert sign
02154: 	pre28: 	shift right a[w] 	Align A then follow thru pqo to compute pseudo quotients.
02155: 	pqo23: 	b exchange c[w] 	Part of pseudo multiplication
02156: 	  	0 -> c[w] 		This routine is use by ln, ex, direct and inverse trigov (s2=0)
02157: 	  	c - 1 -> c[m]
02160: 	  	if s2 = 0
02161: 	  	then go to pqo28
02162: 	  	load constant 4 	The rest of the code use to forge constants with repeated patterns (see note)
02163: 	  	c + 1 -> c[m]
02164: 	  	if no carry go to pqo24
02165: 	pqo27: 	load constant 6
02166: 	pqo28: 	if p # 1
02167: 	  	then go to pqo27
02170: 	  	shift right c[w]
02171: 	pqo24: 	shift right c[w]
02172: 	nrm26: 	if s2 = 0 		Use by ln or trigo
02173: 	  	then go to rtn21 	trigo (S2=0) goto rtn21
02174: 	  	return 			and test S1 to do a "rtn12" or a "return"
02175: 	lncd2: 	7 -> p 			Forge constant see note
02176: 	lnc6: 	load constant 3 	load part of constant
02177: 	  	load constant 3 	ln(1.001) = 0.999500330850
02200: 	  	load constant 0
02201: 	lnc7: 	load constant 8
02202: 	  	load constant 5
02203: 	  	load constant 0
02204: 	  	load constant 9
02205: 	  	go to lnc9
02206: 	exp29: 	jsb eca22 		ex  processing by pseudo multiplication (called by exp21) after computation of pqj
02207: 	  	a + 1 -> a[p]
02210: 	exp22: 	a -> b[w]
02211: 	  	c - 1 -> c[s]
02212: 	  	if no carry go to exp29 loop for the next call to â€œeca22â€
02213: 	  	shift right a[wp] 	A/10
02214: 	  	a exchange c[w]
02215: 	  	shift left a[ms] 	next qj
02216: 	exp23: 	a exchange c[w] 	entry point
02217: 	  	a - 1 -> a[s] 		dec # of SR for a constant
02220: 	  	if no carry go to exp22 test for a next cst
02221: 	  	a exchange b[w] 	No the end
02222: 	  	a + 1 -> a[p] 		Correct mantissa
02223: 	  	jsb nrm21 		Goto normalize
02224: 	rtn21: 	select rom 1 		elay to "rtn11"
02225: 	eca21: 	shift right a[wp] 	Exponent calculation in 	( 1 + 10-j) qj
02226: 	eca22: 	a - 1 -> a[s]
02227: 	  	if no carry go to eca21 do the #of SR for a cst
02230: 	  	0 -> a[s]
02231: 	  	a + b -> a[w] 		thA = A +B == B 1.01 if 2 SR
02232: 	  	return
02233: 	pqo21: 	select rom 1 		relay to "pqo11"
02234: 	pmu21: 	shift right a[w]
02235: 	pmu22: 	b exchange c[w] 	Entry point for ln part 2 (pseudo multiplication)
02236: 	  	go to pmu24
02237: 	pmu23: 	a + b -> a[w] 		do the PM
02240: 	pmu24: 	c - 1 -> c[s] 		dec count
02241: 	  	if no carry go to pmu23
02242: 	  	a exchange c[w] 	keep accuracy
02243: 	  	shift left a[ms]
02244: 	  	a exchange c[w]
02245: 	  	go to pqo23 		another cst ?
02246: 	mpy21: 	3 -> p 			Came from 01245 "mpy11" (pqo)
02247: 	mpy22: 	a + c -> c[x]
02250: 	  	a - c -> c[s]
02251: 	  	if no carry go to div22 entry point for "div"
02252: 	  	0 - c -> c[s]
02253: 	div22: 	a exchange b[m]
02254: 	  	0 -> a[w]
02255: 	  	if p # 12
02256: 	  	then go to mpy27
02257: 	  	if c[m] >= 1 		if FP of X > 0 then div23
02260: 	  	then go to div23
02261: 	  	if s1 = 0 		else blinking display
02262: 	  	then go to err21
02263: 	  	b -> c[wp] 		separate FP and Y
02264: 	  	a - 1 -> a[m] 		and prepare A for repeated subtractions
02265: 	  	c + 1 -> c[xs] 		C holds the count
02266: 	div23: 	b exchange c[wp]
02267: 	  	a exchange c[m]
02270: 	  	select rom 1 		go to  01271
02271: 	lnc2: 	0 -> s8 		load ln(2)
02272: 	  	load constant 6 	0.6931471
02273: 	  	load constant 9
02274: 	  	load constant 3
02275: 	  	load constant 1
02276: 	  	load constant 4
02277: 	  	load constant 7
02300: 	  	load constant 1
02301: 	  	go to lnc8 		+0.000000080553
02302: 	pre27: 	a + 1 -> a[m] 		Part of prescaling for ex
02303: 	  	if no carry go to pre25
02304: 	myp26: 	a + b -> a[w] 		Use by addition (place saving)
02305: 	mpy27: 	c - 1 -> c[p]
02306: 	  	if no carry go to myp26
02307: 	mpy28: 	shift right a[w]
02310: 	  	p + 1 -> p 		Normalization process
02311: 	  	if p # 13
02312: 	  	then go to mpy27 	Right scaling loop
02313: 	  	c + 1 -> c[x]
02314: 	nrm21: 	0 -> a[s] 		FP in A
02315: 	  	12 -> p 		EXP in C
02316: 	  	0 -> b[w] 		Left scaling
02317: 	nrm23: 	if a[p] >= 1 		SLA and adjust EXP
02320: 	  	then go to nrm24
02321: 	  	shift left a[w]
02322: 	  	c - 1 -> c[x]
02323: 	  	if a[w] >= 1
02324: 	  	then go to nrm23 	Left scaling loop
02325: 	  	0 -> c[w]
02326: 	nrm24: 	a -> b[x]
02327: 	  	a + b -> a[w]
02330: 	  	if a[s] >= 1
02331: 	  	then go to mpy28 	Fractionoverflow ?
02332: 	  	a exchange c[m] 	If yes go to right scaling
02333: 	  	c -> a[w] 		result in C
02334: 	  	0 -> b[w] 		zap B
02335: 	nrm27: 	12 -> p 		point to 12
02336: 	  	go to nrm26 		back to the farm via "rtn21" (S1=0) or "return"
02337: 	lncd1: 	9 -> p 			load ln(1.1)
02340: 	  	load constant 3 	=0.99531017980553
02341: 	  	load constant 1
02342: 	  	load constant 0
02343: 	  	load constant 1
02344: 	  	load constant 7
02345: 	  	load constant 9
02346: 	lnc8: 	load constant 8
02347: 	  	load constant 0
02350: 	  	load constant 5
02351: 	  	load constant 5
02352: 	lnc9: 	load constant 3
02353: 	  	go to nrm27 		to to normalize
02354: 	pre21: 	a exchange c[w] 	Entry point for prescaling of ex
02355: 	  	a -> b[w] 		between 0 <= x < 1
02356: 	  	c -> a[m]
02357: 	  	c + c -> c[xs] 		repeated subtractions of ln(10)
02360: 	  	if no carry go to pre24 if positive "pre24"
02361: 	  	c + 1 -> c[xs] 		if negative
02362: 	pre22: 	shift right a[w]
02363: 	  	c + 1 -> c[x]
02364: 	  	if no carry go to pre22
02365: 	  	go to pre26 		go to "prev26" to finish
02366: 	lnc10: 	0 -> c[w] 		load ln(10)
02367: 	  	12 -> p 		2.3025
02370: 	  	load constant 2
02371: 	  	load constant 3
02372: 	  	load constant 0
02373: 	  	load constant 2
02374: 	  	load constant 5
02375: 	  	go to lnc7 		+ .00008509
02376: 	lncd3: 	5 -> p
02377: 	  	go to lnc6 		+ .000000003
