VASM HP-41 question


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?


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.



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.



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;-)




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.



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 ***
* ***


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



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/
LD@PT- 1/
LD@PT- 2/
LD&PT- 5/
Or even .25/
LD@PT- 2/
LD&PT- 5/
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=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.


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
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
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
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
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 *
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.



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?


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.


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..


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP-41(CL): The easiest way to transfer FOCAL programs from a Linux PC to the HP-41 Geir Isene 13 3,874 12-05-2013, 02:40 AM
Last Post: Hans Brueggemann
  Non-Prime question alert: Hp-41 and synthetic instructions Marcel Samek 11 2,709 11-04-2013, 09:31 PM
Last Post: sjthomas
  hp 41 series wire-wrapped connector question. Matt Kernal 3 1,222 06-19-2012, 01:48 AM
Last Post: Luiz C. Vieira (Brazil)
  Re: HP-41 Navigation PAC question Timo 0 625 02-27-2012, 04:06 AM
Last Post: Timo
  HP-41 Navigation PAC question Diego Diaz 7 1,635 02-24-2012, 12:09 PM
Last Post: Dave Shaffer (Arizona)
  HP-41 NUT Assembler question MichaelG 6 1,320 02-14-2012, 03:35 AM
Last Post: MichaelG
  HP-41 printer interface question. (To the M-code gurus out there) Diego Diaz 2 1,029 01-29-2012, 12:18 PM
Last Post: Diego Diaz
  41-MCODE Question Ángel Martin 3 995 10-10-2011, 05:03 PM
Last Post: Eric Smith
  41 halfnut character question Eric Smith 5 1,397 08-23-2011, 02:09 PM
Last Post: Eric Smith
  41 MCODE Question - Page #4 Library Ángel Martin 5 1,300 07-30-2011, 11:16 PM
Last Post: Eric Smith

Forum Jump: