The Museum of HP Calculators

HP Forum Archive 15

[ Return to Index | Top of Index ]

VASM HP-41 question
Message #1 Posted by Jeff D on 21 Apr 2005, 7:43 p.m.

Can someone explain the following from the beginning of the NUT Math ROM 1 Common Math Entries If number is 2-10 or 1-10 or 2-13? The register contains 14 nybbles. What do these 2-10,1-10 and 2-13 mean?

      
Re: VASM HP-41 question
Message #2 Posted by Eric Smith on 22 Apr 2005, 2:45 a.m.,
in response to message #1 by Jeff D

They are just program labels. ad2-10, ad1-10, and ad2-13 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 10-digit 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 13-digit 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 2-10 entry points, both numbers are in the normal 10-digit form. For 1-10, one is in ten digit and one is in 13-digit form. For 2-13, both are in 13-digit form.

For instance, the entry point ad2-10 is used to add two numbers both in ten-digit form.

Eric

            
Re: VASM HP-41 question
Message #3 Posted by Mike (Stgt) on 22 Apr 2005, 3:13 a.m.,
in response to message #2 by Eric Smith

Hi Eric!

What you mean with "internally"? The user-accessible numbers are with a 10 digit mantissa. Durging calcualtions (internally) the HP-41 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

                  
Re: VASM HP-41 question
Message #4 Posted by Raymond Del Tondo on 22 Apr 2005, 3:47 a.m.,
in response to message #3 by Mike (Stgt)

Hi Mike,

maybe you have an earlier copy, and the comments were made later?

Another half-OT 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

                        
Re: VASM HP-41 question
Message #5 Posted by Mike (Stgt) on 26 Apr 2005, 3:51 a.m.,
in response to message #4 by Raymond Del Tondo

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

                  
Re: VASM HP-41 question
Message #6 Posted by Eric Smith on 22 Apr 2005, 6:10 p.m.,
in response to message #3 by Mike (Stgt)

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 2-10, *** * then form is: *** * A has 10 digit form *** * C has 10 digit form *** * if number is 1-10, *** * then form is: *** * A has sign and exp *** * B has 13 digit mantissa *** * C has 10 digit form *** * if number is 2-13, *** * then form is: *** * A and B as in 1-10 *** * M has sign and exp *** * C has 13 digit mantissa *** * *** * on exit, C has 10 digit form *** * A and B have 13 digit form *** * *** ******************************************************

                        
Re: VASM HP-41 question
Message #7 Posted by Mike (Stgt) on 26 Apr 2005, 3:39 a.m.,
in response to message #6 by Eric Smith

Yep, there is a comments "header", but no "inline" comments as in other parts.

Ciao.....Mike

                        
Re: VASM HP-41 question
Message #8 Posted by Jeff D on 26 Apr 2005, 8:18 p.m.,
in response to message #6 by Eric Smith

This is where I got the 13 digit form. I tried to SETDEC prior to the C=A-C 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=A-C 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

                              
MCode question
Message #9 Posted by Mike (Stgt) on 27 Apr 2005, 4:52 a.m.,
in response to message #8 by Jeff D

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 PPC-ROM: 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 HP-41 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=C-1  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

            
Re: VASM HP-41 question
Message #10 Posted by Jeff D on 22 Apr 2005, 1:21 p.m.,
in response to message #2 by Eric Smith

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=A-C 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=A-C 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

                  
Re: VASM HP-41 question
Message #11 Posted by Eric Smith on 22 Apr 2005, 6:07 p.m.,
in response to message #10 by Jeff D

An number accessible to the user is ALWAYS stored in 10-digit form.

13-digit form is ONLY used for internal intermediate calculations. For instance, within the calculation of an exponential. The 13-digit 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 10-digit.

                  
Re: VASM HP-41 question
Message #12 Posted by Ángel Martin on 24 Apr 2005, 1:23 a.m.,
in response to message #10 by Jeff D

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 13-bit vs. 10-bit 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


[ Return to Index | Top of Index ]

Go back to the main exhibit hall