MCODE programming: help needed with asmnut 0.40.1
01-26-2021, 12:13 PM (This post was last modified: 01-26-2021 12:41 PM by hmilz.)
Post: #1
 hmilz Junior Member Posts: 10 Joined: Jan 2021
MCODE programming: help needed with asmnut 0.40.1
Hi all,

I'm trying to get my head around building some new functions and began playing with asmnut. I have a question concerning the PROMPT feature that asmnut nicely supports.

Sadly, the way PROMPT works (and doesn't work) is not as documented in DOCUMENTATION, and it is contradictory in prompt.c.

DOCUMENTATION says,

Code:
                          1 := 1 Digit                          2 := 2 Digits                          F := 2 Digits < 56                          3 := 3 Digits                          S := ST                          I := IND                          Y := IND ST                          + := + - * /                          . := . ..                          a := Alpha or empty                          A := non-empty Alpha

and the code in prompt.c looks like this

Code:
 s_prompt_map prompt_map[ 16 ] = {   { 0x00, 0x0000, '1', "1 Digit",          }, //None   { 0x01, 0x2000, '2', "2 Digits",         }, //Alpha (null input valid)   { 0x02, 0x02E2, 'F', "2 Digits < 56",    }, //2 Digits, ST, IND, IND ST, +, -, * or /   { 0x03, 0x4002, '3', "3 Digits",         }, //2 Digits or non-null Alpha   {   -1, 0x0000, '?', "<invalid 0x10>",   }, //Invalid prompt 0x10   { 0x11, 0x0008, 'S', "ST",               }, //3 Digits   { 0x12, 0x00E2, 'I', "IND",              }, //2 Digits, ST, IND or IND ST   { 0x13, 0x40C2, 'Y', "IND ST",           }, //2 Digits, IND, IND ST or non-null Alpha   {   -1, 0x0000, '?', "<invalid 0x100>",  }, //Invalid prompt 0x20   { 0x21, 0x4000, '+', "+ - * /",          }, //non-null Alpha   { 0x22, 0x00C2, '.', ". ..",             }, //2 Digits, IND or IND ST   { 0x23, 0x4002, '?', "<invalid 0x800>",  }, //2 digits or non-null Alpha   {   -1, 0x0000, '?', "<invalid 0x1000>", }, //Invalid prompt 0x30   { 0x31, 0x00C1, 'a', "Alpha or empty",   }, //1 Digit, IND or IND ST   { 0x32, 0x00C2, 'A', "non-empty Alpha",  }, //2 Digits, IND or IND ST   { 0x33, 0x44C2, '?', "<invalid 0x8000>", }, //2 Digits, IND, IND ST, non-null Alpha . or .. };

where the left part coincides with the documentation above, and the right hand part (after //) coincides with what Meindert Kuipers wrote here.

Anyway. The flags A, a, or 2SIY appear to work and do what they are supposed to, but all others I've tried throw an assembler error, e.g. PROMPT 2 gives:

Code:
 8028/0|    >>> .NAME "ML" PROMPT 2 <<<  HMROM.SRC line #46: ==ERROR== Invalid prompt 2

Also, the bits actually created by the assembler do coincide with Meindert's part but not with what the flags are supposed to do according to DOCUMENTATION.

I am confused.

Is there a newer, bugfixed version of asmnut anywhere? It looks as if asmnut was hosted in git at an earlier point in time but I could not find anything anywhere.

PS Is Christophe still around?

Thank you!

Regards,
Harald
01-26-2021, 03:55 PM
Post: #2
 hmilz Junior Member Posts: 10 Joined: Jan 2021
RE: MCODE programming: help needed with asmnut 0.40.1
OK, I think I sort of fixed the PROMPT function, by simply mapping all the mainframe supported prompt variants. In prompt.c, I set:

Code:
 s_prompt_map prompt_map[ 16 ] = {   { 0x00, 0x0001, '0', "None",                                           },   { 0x01, 0x0002, '1', "Alpha (null input valid)",                       },   { 0x02, 0x0004, '2', "2 Digits, ST, IND, IND ST, +, -, * or /",        },   { 0x03, 0x0008, '3', "2 Digits or non-null Alpha",                     },   { 0x11, 0x0010, '4', "3 Digits",                                       },   { 0x12, 0x0020, '5', "2 Digits, ST, IND or IND ST",                    },   { 0x13, 0x0040, '6', "2 Digits, IND, IND ST or non-null Alpha",        },   { 0x21, 0x0080, '7', "non-null Alpha",                                 },   { 0x22, 0x0100, '8', "2 Digits, IND or IND ST",                        },   { 0x23, 0x0200, '9', "2 digits or non-null Alpha",                     },   { 0x31, 0x0400, 'A', "1 Digit, IND or IND ST",                         },   { 0x32, 0x0800, 'B', "2 Digits, IND or IND ST",                        },   { 0x33, 0x1000, 'C', "2 Digits, IND, IND ST, non-null Alpha . or ..",  }, };

and in the for loops in make_prompt(), I limited i to 13 for the 13 entries. The mask is now no longer needed so one might to throw this out too.

@Christophe, you will probably have had something in mind with the way you set this up but it did not work for me, and I could not understand what you were trying to achieve. At the end of the day, as I understand the mainframe function, it supports only the 12 combinations pointed to by the bits in the left column.

Now if there is a git repo somewhere ...
01-26-2021, 07:53 PM
Post: #3
 cgh Junior Member Posts: 25 Joined: Jun 2014
RE: MCODE programming: help needed with asmnut 0.40.1
Hello Harald,

Yes It seems that comments are not aligned with the code. Sorry.

Could you please share the PROMPT you want to set in function header. I am not sure I have tested all solutions.

I did no change in the new version, so perhaps I never discovered this issue.

Thanks for reporting it.

Regards,

Christophe
01-27-2021, 11:58 AM
Post: #4
 hmilz Junior Member Posts: 10 Joined: Jan 2021
RE: MCODE programming: help needed with asmnut 0.40.1
Hi Christophe,

(01-26-2021 07:53 PM)cgh Wrote:  Could you please share the PROMPT you want to set in function header. I am not sure I have tested all solutions.

As outlined in the code snippet above, when I now write

Code:
 .NAME   "ML" PROMPT C

what I get is bits set to 0x33, i.e. "2 Digits, IND, IND ST, non-null Alpha . or ..". This is a 1:1 mapping from Meindert's list mentioned in an earlier post in this thread. A combination of Flags seems not possible because the 2x 2 extra bits is all the mainframe can work with as far as I understand.
01-27-2021, 03:07 PM
Post: #5
 MeindertKuipers Member Posts: 169 Joined: Dec 2013
RE: MCODE programming: help needed with asmnut 0.40.1
I think it is important to let us know what you are trying to achieve. I also read that the assembled code has the bits correct, how did you confirm that?
If the bits are assembled correctly (verify with the hex editor on your HP41) then make certain that the function is non-programable (NOP after the function name). These prompting functions can be very tricky.

Regards, Meindert
01-27-2021, 04:19 PM
Post: #6
 hmilz Junior Member Posts: 10 Joined: Jan 2021
RE: MCODE programming: help needed with asmnut 0.40.1
Hi Meindert,

(01-27-2021 03:07 PM)MeindertKuipers Wrote:  I think it is important to let us know what you are trying to achieve. I also read that the assembled code has the bits correct, how did you confirm that?

With the code in place I showed above, the bits that are set are exactly as listed by you in this post. Verified by the assembler listing produced by asmnut, and I tested all functions within Nonpareil. (I have no physical HP-41 right now but NP uses the original HP-41 ROMs anyway.)

(01-27-2021 03:07 PM)MeindertKuipers Wrote:  If the bits are assembled correctly (verify with the hex editor on your HP41) then make certain that the function is non-programable (NOP after the function name). These prompting functions can be very tricky.

"PROMPT C" was just an example.

I any case I don't want to break anything. I started by using the original asmnut code and found that only very few prompts worked as documented, which points either to an error in the code or the documentation.

I still don't understand what the original code tried to achieve by accumulating bits in the mask. Isn't it true that the mainframe only interprets these 12 variants? Methinks that my suggested code is far simpler and straightforward. But I'm all open to an explanation.
01-27-2021, 08:59 PM (This post was last modified: 01-27-2021 09:09 PM by cgh.)
Post: #7
 cgh Junior Member Posts: 25 Joined: Jun 2014
RE: MCODE programming: help needed with asmnut 0.40.1
(01-27-2021 11:58 AM)hmilz Wrote:
Code:
 .NAME   "ML" PROMPT C

what I get is bits set to 0x33, i.e. "2 Digits, IND, IND ST, non-null Alpha . or ..". This is a 1:1 mapping from Meindert's list mentioned in an earlier post in this thread. A combination of Flags seems not possible because the 2x 2 extra bits is all the mainframe can work with as far as I understand.
Hi,

Sorry but I dont't understand. What is the PROMPT do you expect to create ? How many digits ? ALPHA ? IND ? ...
By the way, PROMPT C is not possible in asmnut. You must set a combination of 1 2 F 3 S I Y +. a and/or A,
For example, if you want a PROMPT of 3 digits, use
Code:
.NAME "3DIG" PROMPT 3

I you want a prompt of 2 digits limited to 0-55 and enable the IND, use:
Code:
.NAME "55IND" PROMPT FI

and so on...
What PROMPT do you want to set ?

The documentation is right. Don't look to the code, the comments may be outdated. This is the PROMPT I have in some functions:
Code:
                .NAME    "LA"    PROMPT    3                 .NAME    "LX"    PROMPT    3                 .NAME    "LB"    PROMPT    3                 .NAME    "LA"    PROMPT    3                 .NAME    "LX"    PROMPT    3                 .NAME    "XCF"    PROMPT 2IY                 .NAME    "XSF"    PROMPT 2IY

Regards,

Christophe
01-29-2021, 08:44 AM
Post: #8
 hmilz Junior Member Posts: 10 Joined: Jan 2021
RE: MCODE programming: help needed with asmnut 0.40.1
Hi Christophe, thanks for jumping in. Let me try to explain where the confusion comes from. First of all, I don't need any help or support with prompting per se. I just wanted to understand how asmnut supports the 12 HP supported available prompts because I failed to understand the combination of DOCUMENTATION and the code in prompt.c. When analyzing your code, I found that I might as well support the 12 available prompts in a straightforward manner, and applied my local changes as shown in #2 above.

Nevermind.
 « Next Oldest | Next Newest »

User(s) browsing this thread: 1 Guest(s)