Question about programming the HP-71B - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: Question about programming the HP-71B (/thread-175183.html) Question about programming the HP-71B - Namir - 11-26-2010 Hi All, I am using an HP-71B with a MATH Pac module. This module supports the COMPLEX type. How can I declare a SUB subroutine to have a parameter with the COMPLEX type? Thanks! Namir Re: Question about programming the HP-71B - Jerry Raia - 11-26-2010 Here is one way: Main Program ```10 COMPLEX A ! declare type 20 A=-5 30 CALL TESTSUB(A) ! call and pass the variable ``` Sub Program ```10 SUB TESTSUB(A) ! sub program with variable passed 20 DISP SQRT(A) ! take the sqrt of the negative number ``` you should get (0,2.2360679775) Edited: 26 Nov 2010, 9:29 p.m. Re: Question about programming the HP-71B - Namir - 11-27-2010 Hi! I am using the EMU71 (since I am away from home) and get the following value! (0,5) Matlab gives me your answer of 0 + 2.2361i. Any explanation why I am getting (0,5) with EMU71? Namir Edited: 27 Nov 2010, 6:11 a.m. Re: Question about programming the HP-71B - Jerry Raia - 11-27-2010 That's odd, I just tried it on EMU71 and got the correct result. Re: Question about programming the HP-71B - Egan Ford - 11-27-2010 Me too. Re: Question about programming the HP-71B - Namir - 11-27-2010 When I type VER\$ on my EMU71 I get: HP71:2CDCC MATH:1A JPC:Ex HPIL:1B HELP:C FACTR:A STRU:A RCPY:E The EMU71.INI file is: ```; emu71.ini Emu71 initialisation file ; [MODULES] ; 10 softwired modules max., plus 1 hardwired module ; main RAM in port 0 only ; port(1-5) type(ROM,RAM,HRD) size(Ko) file 0 RAM 32 ram00.bin 1 ROM 16 hpilrom.bin 2 ROM 16 mathrom.bin 3 ROM 32 jpcromx.bin 5 RAM 32 iram50.bin ; [DEVICES] DISPLAY HDRIVE1 HDRIVE2 DOSLINK LPRTER1 ``` Maybe the above info helps? Re: Question about programming the HP-71B - Katie Wasserman - 11-27-2010 On a real 71b with Math ROM I can confirm that the answer is (0,2.236...). Re: Question about programming the HP-71B - Namir - 11-27-2010 My main goal was to write SUB routines that have parameters that are complex arrays and variables. The good news is that the approach you suggest WORKS!! It seems that with the MATH module, the HP-71B does not require a special syntax for COMPLEX parameters. When the arguments passed to the SUB routines are complex, the routine treats them as COMPLEX within its scope. I was trying to implement the Aberthâ€“Ehrlich method that simultaneously solves for all the roots (real and complex) of polynomials. The good news is that the implementation works! Namir Edited: 27 Nov 2010, 6:05 p.m. Re: Question about programming the HP-71B - Namir - 11-27-2010 Sounds like an emulator bug, given the INI configuration I am using. The good news is that the polynomial-root program I wrote (which heavily uses complex math and complex variables and arrays) works just fine!! Edited: 27 Nov 2010, 4:24 p.m. Re: Question about programming the HP-71B - Karl Schneider - 11-27-2010 Quote: On a real 71b with Math ROM I can confirm that the answer is (0,2.236...). I'll second Katie. I got the answer (0,2.2360679775) by modifying Jerry's program as follows and hitting "RUN" to execute: ```10 COMPLEX A 20 A=(-5,0) 30 CALL TESTSUB(A) 40 SUB TESTSUB(A) 50 DISP SQRT(A) ``` ADDENDUM: The following program also works. It proves passage of the complex-valued variable, undeclared in the subroutine. ```10 COMPLEX A 20 A=(-5,0) 30 CALL TESTSUB(A) 35 END 40 SUB TESTSUB(B) 50 DISP SQRT(B) ``` -- KS Edited: 28 Nov 2010, 3:38 p.m. after one or more responses were posted Re: Question about programming the HP-71B - Namir - 11-27-2010 I typed you code, line for line, and got (0,5). Re: Question about programming the HP-71B - Jerry Raia - 11-27-2010 I'm glad it works! Still it's odd I can't seem to duplicate your result of (0,5) on either of my computers with EMU71. Re: Question about programming the HP-71B - Namir - 11-27-2010 I am equally baffled about the result. The program I wrote does not use the SQRT, so I guess I am fine. (deleted post) - deleted - 11-27-2010 This Message was deleted. This empty message preserves the threading when a post with followup(s) is deleted. If all followups have been removed, the original poster may delete this post again to make this placeholder disappear. Re: Question about programming the HP-71B - Namir - 11-27-2010 i will certainly test the program with a real HP-71B and Math rom by the end of the week, when i am back home. Re: Question about programming the HP-71B - Namir - 11-27-2010 I downloaded the latest version of EMU71 and ran the code. Same result. Also when I type SQR((-144,0)) I get (0,144). Also when I execute SQR((144,0)) I get (144,0). Moreover, when I execute SQR((144,144) I get (20808,3,46020761246E-3). The correct answeris 13.1842 + 5.4611i. Seems like a bug to me????? Namir Edited: 27 Nov 2010, 7:44 p.m. Re: Question about programming the HP-71B - Jerry Raia - 11-27-2010 Yes something is wrong. When I execute the examples you just tried on EMU71, I get the correct results. Not the results you are getting. Re: Question about programming the HP-71B - J-F Garnier - 11-28-2010 Hi Namir, Are you running Emu71 on a native Windows computer, or in a Windows (or DOS) emulation? J-F Re: Question about programming the HP-71B - Namir - 11-28-2010 Hi! I usually launch a DOS box in Windows 7 and then run your emulator. I tried running the emulator directly and I get the same error. I am running a 32-bit Windows 7 on my (traveling) laptop. I also noticed that raising complex number to integer power does not work! Thank you for responding to my query! Namir Edited: 28 Nov 2010, 6:29 a.m. Re: Question about programming the HP-71B - Raymond Del Tondo - 11-28-2010 Have you tried without the JPC, just to be sure ?IIRC the JPC listens to some interrupts, so maybe it's a matter of a Mode setting? HTH Ray Re: Question about programming the HP-71B - J-F Garnier - 11-28-2010 Namir, Very strange. I doubt this is a problem from Emu71 but can you send me your complete Emu71 folder with all your files so I can check ? jeffcalc (at] wanadoo fr thanks. J-F Re: Question about programming the HP-71B - Egan Ford - 11-28-2010 Quote: (or DOS) emulation? I tested with DOS emulation without issue. I tested the latest EMU71 with DOSBox on OS/X and on my iPad. ```10 COMPLEX A 20 A=-5 30 CALL TESTSUB(A) 40 END 100 SUB TESTSUB(A) 110 DISP SQRT(A) 120 END SUB ``` Results: ```(0,2.2360679775) ``` VER\$: ```HP71:2CDCC RPN:C FACTR:A MATH:1A JPC:Ex HPIL:1B HELP:C FACTR:A STRU:A RCPY:E FTH41:1A EDT:A ``` Edited: 28 Nov 2010, 1:54 p.m. Re: Question about programming the HP-71B - Namir - 11-28-2010 You have email! Namir Re: Question about programming the HP-71B - J-F Garnier - 11-28-2010 Found it :-)) In emu71.in, replace "2 ROM 16 mathrom.bin" by "2 ROM 32 mathrom.bin". Math module is a 32bB ROM. What is strange is that Emu71 didn't crash with just half of the ROM loaded... J-F Re: Question about programming the HP-71B - Geoff Quickfall - 11-28-2010 Both real versions of my HP71B with math roms give the correct answer:(0,2.236...) Haven't tried the emulator yet. Cheers, HP71:2cdcc clk:ms hpil:1b math:1a HP71:1bbbb clk:a hpil:1b math:1a Edited: 28 Nov 2010, 5:31 p.m. Re: Question about programming the HP-71B - Namir - 11-28-2010 Jean-Francois, It worked!!! thank you!! Now I get the correct results with EMU71. The power operator for complex numbers also works properly. I guess it was part of the ROM that was not loaded. Many thanks for taking the time to look into it. Namir Edited: 28 Nov 2010, 6:27 p.m. Re: Question about programming the HP-71B - Jerry Raia - 11-28-2010 Perhaps no calls were made within the ROM half that was missing. Although I wonder why the SQRT result Namir originally got didn't cause a crash. It is interesting. Re: Question about programming the HP-71B - Namir - 11-29-2010 The ^ operator also did not work! I had to recode the program and apply work-arounds. When I used the SQRT with complex values I got (wrong) answers. The emulator never crashed. namir Edited: 29 Nov 2010, 4:54 a.m.