I have written the following sequece in MCode
1A0 A=B=C=0
355 ?NC XQ
050 ->14D5
0B8 READ 2(Y)
0AE A<>C ALL
0F8 READ 3(X)
30E ?A<C ALL
017 JC B09A +02
0AE A<>C ALL
070 N=C ALL
10E A=C ALL
135 ?NC XQ
060 ->184D
0E8 WRIT 3(X)
My intention is to find the largest value between the A and C registers and square the value then write it back to the user X register. Unfortunately, when I use a fractional number with no integer value, the program does not produce the correct value.
Any thoughts would be appreciated.
Thanks,
Jeff
HP-41 MCode question
|
|
« Next Oldest | Next Newest »
|
▼
11-02-2005, 01:17 PM
▼
11-02-2005, 04:20 PM
(Well, it's been about half a billion seconds since I did any 41 machine code programming, but I think I see the problem...)
You need to perform a floating-point comparison between the two values; the ?A<C ALL is doing a 56-bit binary comparison between the normalized forms of the X and Y register values that you pulled into A and C, which won't work for the vast majority of possible values. (Remember, the X and Y registers can also contain alpha values, and could even include non-normalized values.) The Nut CPU basically hasn't a clue about floating-point operations -- the OS does all that. Hope that helps. ▼
11-04-2005, 10:44 PM
Frank, So about 15 years?
:) ▼
11-07-2005, 07:00 PM
Yeah, about that -- I think I last wrote 41 machine code around about 1989 (and probably machine code of any kind around 1994). I just haven't had a reason to get that close to a machine since (and these days, the platforms I'm programming for are things like browsers, VMs and databases, where the 'machine' is abstracted away from the metal).
11-09-2005, 07:15 PM
Thanks for the suggestions. I have tried to use the X<Y? with a X<>Y afterwords. This only yields "NO" whether the larger number is in the X or the Y registers. I understand that when executing these mcode routines from the keyboard will cause only "YES" or "NO" to be displayed, so I ran the routing from a user code program. This eliminated the "YES" or "NO" and left the numbers but still did not execute the X<>Y. I also tried the XX<Y? and still get similar results. My goal is to sort the higher number to a known register. The numbers will be integers with fractional portions.
11-03-2005, 12:05 AM
The way the mainframe tackles comparison is to subtract the two FPN's and then test the sign nibble. 1421 does an N=A-N with result also in C. 14D8: check C for Alpha Data Error. 14D5: check both A and C, ends with arguments reversed. Best Regards
11-05-2005, 04:24 AM
Can someone please tell me of any references that provide guidance and instruction on this topic? I've begun trying to learn the techniques of synthetic programming, but the references seem to be scattered, unfortunately. I have Jarett, and Wickes, and the PPC Journal on CD already. Are there any other major (or minor) references I should hunt for?
Thanks a lot, ▼
11-08-2005, 06:15 AM
Definitely get a copy of Ken Emery's "HP-41 MCODE for Beginners". Not sure if it's available on any CD-ROM or DVD set though!
Best, ▼
11-08-2005, 07:11 AM
Other musts for MCODE programmers: These are all on the DVD of TOS Meindert ▼
11-10-2005, 02:24 AM
Meindert, I don't understand the reference to the DVD by "TOS." Could you please tell me who "TOS" is?
Thanks, ▼
11-10-2005, 08:12 AM
Once and for all (and without breaking any rules... I hope): Google this and click the obvious.
Greetings, ▼
11-10-2005, 08:36 AM
Thanks Jeff, but I already know it very well. After all Warren's site is still alive and kickin' and easily found by search engines - if you know what to look for.
Greetings, |