▼
Posts: 39
Threads: 16
Joined: Jan 1970
Can someone explain the following from the beginning of the NUT Math ROM 1
Common Math Entries
If number is 210 or 110 or 213?
The register contains 14 nybbles. What do these 210,110 and 213 mean?
▼
Posts: 2,309
Threads: 116
Joined: Jun 2005
They are just program labels. ad210, ad110, and ad213 are three different entry points for the addition ruoutine.
It's all explained in the comments at the top of the file.
Internally, numbers are stored in memory in 10digit form. That's the count of the mantissa digits. There are also two digits of exponent, and one each of mantissa sign and exponent sign. There's also a 13digit form that is used only in the registers, for intermediate calculations. That's 13 digits of mantissa, with the sign and exponent in another register.
For the 210 entry points, both numbers are in the normal 10digit form. For 110, one is in ten digit and one is in 13digit form. For 213, both are in 13digit form.
For instance, the entry point ad210 is used to add two numbers both in tendigit form.
Eric
▼
Posts: 858
Threads: 80
Joined: Feb 2009
Hi Eric!
What you mean with "internally"? The useraccessible numbers are with a 10 digit mantissa. Durging calcualtions (internally) the HP41 may do something else (to achieve higher precission?) but converts the result before it pops up on the user surface.
BTW  in my copy of the VASM there are no comments in the math routines.
Ciao.....Mike
▼
Posts: 1,841
Threads: 54
Joined: Jul 2005
Hi Mike,
maybe you have an earlier copy, and the comments were made later?
Another halfOT question:
Do you have (or know someone who has) the VASM listings as plain text file(s),
not only as image/picture of the pages?
This would be very practical for searching through the ROM;)
Regards
Raymond
▼
Posts: 858
Threads: 80
Joined: Feb 2009
Hi Raymond! Seems Eric's append answers your question. Alas I do not have those text files and had no time yet to try OCR with my scanns.
Ciao.....Mike
Posts: 2,309
Threads: 116
Joined: Jun 2005
Quote:
BTW  in my copy of the VASM there are no comments in the math routines.
None at the very beginning of the file cn6b, right under where it says "Nut math ROM 1" and "starting address=@14000"?
Mine says:
file cn6b
*****************************************************
* Nut math ROM 1 *
* starting address=@14000 *
****************************************************
******************************************************
* common math entries ***
* if number is 210, ***
* then form is: ***
* A has 10 digit form ***
* C has 10 digit form ***
* if number is 110, ***
* then form is: ***
* A has sign and exp ***
* B has 13 digit mantissa ***
* C has 10 digit form ***
* if number is 213, ***
* then form is: ***
* A and B as in 110 ***
* M has sign and exp ***
* C has 13 digit mantissa ***
* ***
* on exit, C has 10 digit form ***
* A and B have 13 digit form ***
* ***
******************************************************
▼
Posts: 858
Threads: 80
Joined: Feb 2009
Yep, there is a comments "header", but no "inline" comments as in other parts.
Ciao.....Mike
Posts: 39
Threads: 16
Joined: Jan 1970
This is where I got the 13 digit form. I tried to SETDEC prior to the C=AC operation and still the result is not the correct answer. In fact it is way off. Is there some considerations to think about when entering constants lets say 1.25/
PT= 12/
C=0/
LD@PT 1/
LD@PT 2/
LD&PT 5/
Or even .25/
LD@PT 2/
LD&PT 5/
PT=2/
LD@PT 9/
LD@PT 9/
LD@PT 9/
I am assuming that exchanging the C register with A and N does not perform any ill effects on the number. After I have the two numbers, and I have verified that they are correct, in the A and the N registers. I perform the following:
A=C All/
C<>N ALL/
A<>C ALL/
C=AC All/
WRIT 3(x)/
Sorry for these very basic questions but I am very interested in MCODE and want to learn more.
Thanks to everyone who has responded.
Jeff
▼
Posts: 858
Threads: 80
Joined: Feb 2009
Pls do not apologize for beginners questions. But if you want to go deeper in this bussines get a copy of "MCode made easy" from ..  ah? who was it?  or something like that. It was long ago when I did such things and forgot too much, so I am almost a beginner too.
If it helps here a random number generator (CX only! as w/o seed it takes part of time as seed which is stored in a volatile buffer) of the type used in PPCROM: Rn+1 = FRAC(Rn * 9821 + ,211327). At the end you find the multiply and add step. Pls try this entry points, IIRC they are very close to those the HP41 goes when you hit "*" or "+".
B400 04E C=0 ALL
B401 35C PT= 12
B402 250 LC 9
B403 260 SETHEX
B404 3F0 PERSLCT
B405 130 LDI
B406 0C0 CON 192
B407 108 SF 8
B408 1AD *
B409 16A NCGO 5A6B
B40A 084 D
B40B 005 E
B40C 005 E
B40D 013 S
B40E 0F8 C=REG 3/X
B40F 361 *
B410 050 NCXQ 14D8
B411 158 M=C
B412 3E9 *
B413 08C NCXQ 23FA
B414 033 JNC +06 B41A
B415 038 RDATA
B416 000 NOP
B417 2EE ?C#0 ALL
B418 321 *
B419 0C3 CGO 30C8
B41A 2A0 SETDEC
B41B 198 C=M
B41C 106 A=C X
B41D 130 LDI
B41E 003 CON 03
B41F 146 A=A+C X
B420 03C RCR 3
B421 0A6 A<>C X
B422 35C PT= 12
B423 250 LC 9
B424 010 LC 0
B425 050 LC 1
B426 2F0 WDATA
B427 3E0 RTN
B428 08E N
B429 012 R
B42A 3E9 *
B42B 08C NCXQ 23FA
B42C 07B JNC +0F B43B
B42D 389 *
B42E 140 NCXQ 50E2
B42F 038 RDATA
B430 05A C=0 M
B431 07C RCR 4
B432 3F0 PERSLCT
B433 2A0 SETDEC
B434 266 C=C1 X
B435 158 M=C
B436 0A6 A<>C X
B437 270 RAMSLCT
B438 375 *
B439 03C NCXQ 0FDD
B43A 015 *
B43B 0FC NCXQ 3F05
B43C 046 C=0 X
B43D 07C RCR 4
B43E 2A0 SETDEC
B43F 10E A=C ALL
B440 04E C=0 ALL
B441 35C PT= 12
B442 250 LC 9
B443 210 LC 8
B444 090 LC 2
B445 050 LC 1
B446 130 LDI
B447 003 CON 03
B448 135 *
B449 060 NCXQ 184D
B44A 10E A=C ALL
B44B 04E C=0 ALL
B44C 19C PT= 11
B44D 090 LC 2
B44E 050 LC 1
B44F 050 LC 1
B450 0D0 LC 3
B451 090 LC 2
B452 1D0 LC 7
B453 01D *
B454 060 NCXQ 1807
B455 084 CF 5
B456 0ED *
B457 064 NCXQ 193B
B458 158 M=C
B459 0EE B<>C ALL
B45A 375 *
B45B 03C NCXQ 0FDD
B45C 01A A=0 M
B45D 0B9 *
B45E 04A NCGO 122E
BTW  this routine can only be shiftet to page boundaries (x000, x400, x800, and xC00). Use it first in an emulator and trace it to see what happens. Adjust the buffer number in case of conflicts with other buffers.
Ciao.....Mike
Posts: 39
Threads: 16
Joined: Jan 1970
Is there a way to verify whether or not I have one or both the numbers, that I am performing math on, in 10 or 13 digit form? I am trying to perform a C=AC and I know if I use WRIT 3(X) after each of the previous operations that I have the correct numbers placed into the A and C registers. Unfortunatly when I perform this C=AC operation I get something like 181.64 which is not the correct answer. Is there a way to change both the numbers to a known form prior to this operation? What am I missing?
Thanks,
Jeff
▼
Posts: 2,309
Threads: 116
Joined: Jun 2005
An number accessible to the user is ALWAYS stored in 10digit form.
13digit form is ONLY used for internal intermediate calculations. For instance, within the calculation of an exponential. The 13digit form is never the input or output of a user function, and is never in the stack.
In other words, anything you ever have in the stack or in a user register, including user intermediate results is always 10digit.
Posts: 1,253
Threads: 117
Joined: Nov 2005
Jeff, have you made sure you have the CPU in DECimal mode? The result will be bogus if you don´t have a SETDEC instruction somewhere in your code prior to the sustraction step..
Tried to use the OS routines? [Y_MINUS_X] (located at 1421H) and [AD2_10] (located at 1807H) come to mind.
I´m not sure I understand (nor agree) with the 13bit vs. 10bit discussion in this thread: to me, everything in the coconut CPU has a 10.digit precision, since the input and output both have precisely that. But again, there are many things in MCODE I don´t know..
Best,
ÁM
