RE: (HP71B) ASM question
Information: new word for the "HP41&71" community "DSE"
That was a hard nut: FRAC15 dont like a number like 0,xxxxxx therefore it must be tested if it is a number of type 0,xxxxxx instead of using FRAC15 for all numbers.
Code:
=IF12A EQU #0C739 return where the decimal point is. Out is the number in P. Page 1412 If E<0, P =14 etc.
* alter A,B,C(A),P,CARRY
Comments/remarks are welcome.
Code:
****************************************************************
* DSE : decrement value
* HP41 like; manual page 163; decrement and skip if equal
* It decrement sss and would "skip", what we can interpret as
* put a NO/false (0) in the integer stack, if it becomes equal or less than eee
* (ssss,eeeii in X) X DSE return 0 (false) if ssss <= eee
* -1 (true) if ssss > eee
* use: 20.01001 X DSE >> output .. X: 19.010010000 .. 0 OK { 0 }
* this value can be saved into any variable Z T or FVARX
* then FVARX DSE can be used
*
* use cases for testing:
* 0.0 X DSE -1.0 in X & 0 in integ stack
* 20.00020 X DSE 0.00020 in X & 0 in integ stack
* 20.010010000 X DSE 19.010010000 in X & -1 in integer stack
* 20.010001234 X DSE 19.010001234 in X & -1 in integer stack
* 20.010023456 X DSE 18.010023456 in X & -1 in integer stack
* 0.010023456 X DSE -2.010023456 in X & 0 in integer stack
* 1.010023456 X DSE -1.010023456 in X & 0 in integer stack
* 20.010103456 X DSE 10.010103456 in X & 0 in integer stack
* 10.010103456 X DSE 0.010103456 in X & 0 in integer stack
* -10.0000566666 X DSE -15.000056667 in X & 0 OK { 0 }
* -10.000000000 X DSE FS. . >> X: -11.000000000 >> 0 OK { 0 }
* 0.010003456 X DSE FS. . >> -1.010003456 .. 0 OK { 0 }
* 1.0200234567 X DSE FS. . >> -1.020023457 .. 0 OK { 0 }
* 0.00000345678 X DSE FS. . >> -1.00000345678 .. 0 OK { 0 }
* 0.01002 X DSE FS. . >> -2.01002 0
* 0.01 X DSE FS. . >> -1.01 0
* 0.00002 X DSE FS. . >> -2.00002 0
*
* tested 07 Oct 2024
****************************************************************
WORD 'DSE'
* GOSBVL =uMODES necessary?
GOSBVL =SAVEFP
C=DAT1 A copy data at address in D1 into C(A)
R0=C copy C(A) into R0
CD0EX exchange C(A) with D0 pointer
A=DAT0 W value ssss,eeeiixxx into A
*
* saving the original value of the float variable
*
R1=A value ssss,eeeiixxx into >> R1 <<
*
* ssss or sssseee or sssseeeii = 0 seems to be an issue because the numbers after ii , are gone.
* lets consider that case to bypass later calculations
* >> FRAC15 dont like something like 0,xxxx
*
* 10000 in (C)
C=0 W
P= 14
C=C+1 P
P= 0
LCHEX 5 just retracting 5x 1 in X was not making it
*
A=R1 seems to make it better; see %OF, too
* = upload A after C prior MV DV ADD..
SETDEC
GOSBVL =MP2-12 sssseeeii,xxx into (A,B)
GOSBVL =CLRFRC sssseeeii,000 into (A,B)
GOSBVL =uRESD1 into (C)
R2=C sssseeeii,000 into R2
C=0 W
P= 14
C=C+1 P
P= 0
LCHEX 998 0,01 now in C
*
A=R2 sssseeeii,000 into A
SETDEC
GOSBVL =MP2-12 sssseee,ii000 into (A,B)
GOSBVL =CLRFRC sssseee,00000 into (A,B); carry set if ii=00
*
GONC nadd0 if 0,ii000 # 0,00 then dont add one
*
* BRANCH: ii is ZERO .. then add ONE
*
A=R2 sssseee00,000 into A
C=0 W
P= 14
C=C+1 P 1 in Register C
C=A S it makes -1 if A<0; +1 if A>0
A=R2 sssseee00,000 into A
GOSBVL =AD2-12 sssseee01,000 in (A,B)
GOSBVL =uRESD1 sssseee01,000 into (C)
R2=C sssseee01,000 into (R2)
*
* BRANCH: ii IS NOT ZERO from here
*
nadd0 C=0 W
P= 14
C=C+1 P
P= 0
LCHEX 998 0,01 now in C
A=R2 from here, sssseeeii,000 into A
SETDEC
GOSBVL =MP2-12 sssseee,ii000 into (A,B)
GOSBVL =FRAC15 0,ii000 in (A,B). ii#00 for sure here issue there if sssseee = 0?
GOSBVL =uRESD1 into (C)
A=C W 0,ii000 into A
P= 15
A=0 P +0,ii000 in (A)
SETDEC
A=-A-1 S A = -0,ii000
R2=A -0,ii000 in R2 now
C=0 W
P= 14
C=C+1 P
P= 0
LCHEX 2 100 in C
A=R2 -0,ii000 in (A)
*
SETDEC dont forget this before MP DV .. 2-12
GOSBVL =MP2-12 -ii,000 into (A,B)
GOSBVL =uRESD1 -ii,000 into (C)
*
R2=C -ii,000 into (R2)
*
* ssss could be zero and could make an issue later with the use of FRAC15
* which is not necessary in case this is already 0,eeeiixxxx
*
A=R1 ssss,eeeiixxx into A
GOSBVL =IF12A
?P# 14 test if A is like 0,eeeiixxx which means ssss = 0
GOYES SNZ ssss is NOT ZERO (tested)
*
* BRANCH: ssss is ZERO; -ii is from here definitively NOT ZERO
*
C=R1 0,eeeiixxx is in C now (ssss is Zero tested before)
A=R2 -ii,000 (which is NOT ZERO) into A
C=A S (C) should have the same sign than (A)
GOSBVL =AD2-12 value (ssss=zero)-ii,eeeiixx in (A,B)
GOSBVL =uRESD1 in C
R1=C
GOTO WEI
*
* Branch: ssss is not ZERO (tested)
*
SNZ A=R1 A is like ssss,eeeiixxx
GOSBVL =SPLITA A into (A,B)
GOSBVL =CLRFRC ssss,00 into (A,B)
GOSBVL =uRESD1 ssss,00 into (C)
A=R2 -ii,000 into (A)
SETDEC dont forget this before MP DV .. 2-12
GOSBVL =AD2-12 value ssss-ii,00 in (A,B)
GOSBVL =uRESD1 ssss-ii,00 in C
A=C W ssss-ii,00 in A
R2=C ssss-ii,00 in R2
*
?A#0 M (ssss-ii) not ZERO ?
GOYES WEIT goto WEIT if (ssss-ii) not zero
*
* BRANCH: (ssss-ii) is ZERO
*
A=0 W necessary(?)
R2=A necessary(?)
*
A=R1 ssss,eeeiixxx (NOT like 0,eeeiixxx) in A
GOSBVL =SPLITA A into (A,B)
GOSBVL =FRAC15 0,eeeiixxx in (A,B)
GOSBVL =uRESD1 into (C)
C=0 S +0,eeeiixxx (= ssss-ii,eeeiixxx) in (C)
R1=C +0,eeeiixxx (= ssss-ii,eeeiixxx) in (R1)
GOTO WEI
*
*
* BRANCH: (ssss-ii) and (ssss) are both NOT ZERO
*
WEIT A=R1 ssss,eeeiixxx into A
GOSBVL =SPLITA ssss,eeeiixxx into (A,B)
GOSBVL =FRAC15 0,eeeiixxx in (A,B)
GOSBVL =uRESD1 0,eeeiixxx into (C)
A=R2 ssss-ii,00 into (A)
C=A S
GOSBVL =AD2-12 value ssss-ii,eeeiixxx in (A,B)
GOSBVL =uRESD1 ssss-ii,eeeiixxx into C
R1=C ssss-ii,eeeiixxx in (R1)
*
* Upload the DSE action back into the variable
*
WEI A=R1
C=R0
CD0EX exchange C(A) with D0
DAT0=A W Store increased value ssss-ii,eeeiixxx back into variable
*
* Now upload the TRUE FALSE into the integer stack
* So far, R2 has ssss-ii,00
* So far, R1 has ssss-ii,eeeiixxx
*
* isolate eee
*
A=R1 ssss-ii,eeeiixxx in (A)
*
GOSBVL =IF12A
?P= 14 test if A like 0,eeeiixxx
GOYES SIZ ssss-ii is ZERO (tested)
*
* BRANCH (again) ssss-ii IS NOT ZERO
*
A=R1
GOSBVL =SPLITA A into (A,B)
GOSBVL =FRAC15 0,eeeiixxx into (A,B)
GOSBVL =uRESD1 0,eeeiixxx (A,B) into C
R1=C 0,eeeiixxx in R1
*
* BRANCH (again) ssss-ii IS ZERO
* 0,eeeiixxx
*
SIZ C=0 W
P= 14
C=C+1 P
P= 0
LCHEX 3 1000 in (C)
A=R1 0,eeeiixxx into A
SETDEC dont forget this before MP2-12
GOSBVL =MP2-12 eee,iixxx into (A,B)
GOSBVL =CLRFRC eee,00000 into (A,B)
GOSBVL =uRESD1 eee,00 into (C)
C=0 S +eee,00 in (C)
R1=C +eee,00 in (R1)
*
C=R2 ssss-ii,00 in C
A=R1 +eee,00 in A
P= 1
GOSBVL =uTEST
SETHEX
A=0 A
GONC TRO1
A=A-1 A
TRO1 GOSBVL =GETFP
DAT1=A A
RTNCC
*
****************************************************************
HP71B 4TH/ASM/Multimod, HP41CV/X/Y & Nov64d, PILBOX, HP-IL 821.62A & 64A & 66A, Deb11 64b-PC & PI2 3 4 w/ ILPER, VIDEO80, V41 & EMU71, DM41X
|