Sharp PC-1500A Compiler
|
11-21-2024, 06:05 AM
Post: #1
|
|||
|
|||
Sharp PC-1500A Compiler
Has anyone tried this program? Unfortunately, it doesn't work for me, and after running RUN, some initialization takes place without error, but the program exits and DEF commands don't work.
http://www.pc1500.com/abc-compiler.html |
|||
11-21-2024, 03:34 PM
Post: #2
|
|||
|
|||
RE: Sharp PC-1500A Compiler
No, have not used that one. I use the TASM extension I wrote for VS Code:
https://github.com/Jeff-Birt/TASM_vsCode_Extension Also helpful is the PC-1500 library builder: https://github.com/Jeff-Birt/Sharp_PC-1500_Lib_Builder |
|||
11-22-2024, 05:49 AM
Post: #3
|
|||
|
|||
RE: Sharp PC-1500A Compiler
Thank you for the info. The program as such works, in fact all commands work, only the IF...GO command doesn't work, strange. But GO itself works.
|
|||
11-27-2024, 08:25 PM
Post: #4
|
|||
|
|||
RE: Sharp PC-1500A Compiler
Heureka, I figured it out!
In line 6510, it should not be &B5 but must be &BE (SJP i,j) instruction at address D0D2H, where two variables are compared. The program actually couldn't work for anyone all the time, there were two errors. 3500:POKE P,&B5,&79,&AE,&38,&D2,&B5,X,&AE,&38,&D3,&B5,&79,&AE,&38,&D0,&B5,Y 6510:POKE P+18,&BE,&3A,&C4,&B5,ZZ,&BE,&D0,&D2,&89,2,&8E,3,&BA,Y,Z I would stress to users that the _STOP function is absolutely necessary, otherwise the program will "wander" in RAM. I will improve the program with other functions like SIN, COS, TAN or LOG. |
|||
11-30-2024, 06:31 PM
(This post was last modified: 12-01-2024 12:57 PM by Josef.)
Post: #5
|
|||
|
|||
RE: Sharp PC-1500A Compiler
Version 1.4 is ready, SIN, COS, TAN, LOG and ABS functions are added. Instructions and program is attached. This is how the solution of the Kepler equation looks like. Assembler tends to be much faster, especially in common mathematical operations. A bin file is basically a text file that can be converted to WAV, for example, or uploaded using the CE-158 (X) interface from a computer using RS232. The program after translation by the compiler occupies 391 Bytes in RAM.
*L=(M+180*I/pi* SIN(E) - E)/(1-I*COS (E)) IF ABS(L) > 1E-3 THEN E = E + L: GOTO * 0 M=E 1*F=ESX 2 F=F*I 3 F=F*D 4 F=F-E 5 F=F+M 6 C=ECX 7 C=C*I 8 C=K-C 9 L=F/C 10 E=E+L 11 L=LAX 12 IFL>RGO* 13 PRE 14 WE 15 STOP 16 END M= Mean Anomaly, I= Eccentricity, D= 180/3.14, K=1, R=0.0001 |
|||
12-01-2024, 12:32 PM
Post: #6
|
|||
|
|||
RE: Sharp PC-1500A Compiler
The author of the program made another mistake, and the GO command did not work. I didn't think to check all the instructions. I am attaching the corrected version.
|
|||
12-02-2024, 08:41 PM
Post: #7
|
|||
|
|||
RE: Sharp PC-1500A Compiler
I must admit that I have absolutely no experience with this calculator, but it reminds me how we can use this Python to RPN - source code converter to translate a corresponding Python program:
Code: def kepler(M): The generated program for the HP-42S can be simplified a bit to: Code: 00 { 72-Byte Prgm } Example RAD 0.5 XEQ "kepler" 0.50813 RCL "E" RCL "I" RCL "E" SIN × - 0.50000 (11-30-2024 06:31 PM)Josef Wrote: 0 M=E I could be wrong, but shouldn't that rather be: Code: 0 E=M |
|||
12-02-2024, 10:35 PM
Post: #8
|
|||
|
|||
RE: Sharp PC-1500A Compiler
Nice.
Yes, in the description, I stated M= Mean Anomaly; it should have been E= Mean Anomaly. So if we add M, then 0 must be E=M. |
|||
12-02-2024, 11:49 PM
Post: #9
|
|||
|
|||
RE: Sharp PC-1500A Compiler
(12-02-2024 08:41 PM)Thomas Klemm Wrote: I must admit that I have absolutely no experience with this calculator, but it reminds me how we can use this Python to RPN - source code converter I just tried that converter. It chokes on the Python function sqrt! Calculators have a square root function, no? Tom L Cui bono? |
|||
12-03-2024, 03:09 AM
Post: #10
|
|||
|
|||
RE: Sharp PC-1500A Compiler
(12-02-2024 11:49 PM)toml_12953 Wrote: It chokes on the Python function sqrt! Calculators have a square root function, no? Python doesn't provide a sqrt function. It has to be imported from a library. From Help & User Guide: Quote:What is not supported From List of HP42S Commands Reference: \( \begin{array}{|c|c|} \hline \text{HP42S Command} & \text{Supported in Python to RPN} & \text{Comments Parameters} & \text{Description (original HP42S)} \\ \hline \text{SQRT} & \text{✓} & \text{(n)} & \text{Square root. Returns √x.} \\ \hline \end{array} \) The following Python program works: Code: def radius(x, y): The generated code for the HP-42S can be optimized to: Code: LBL "radius" You could also use the built-in function →POL instead: Code: r, phi = toPol(x, y) |
|||
12-03-2024, 03:41 AM
Post: #11
|
|||
|
|||
RE: Sharp PC-1500A Compiler
(12-03-2024 03:09 AM)Thomas Klemm Wrote:(12-02-2024 11:49 PM)toml_12953 Wrote: It chokes on the Python function sqrt! Calculators have a square root function, no? True but even if you import the math library, the converter should know that sqrt is the same as SQRT and tan is the same as TAN, etc. Tom L Cui bono? |
|||
12-03-2024, 04:55 AM
(This post was last modified: 12-03-2024 06:38 AM by Thomas Klemm.)
Post: #12
|
|||
|
|||
RE: Sharp PC-1500A Compiler
If you want to run the code in a Jupyter notebook or a Python REPL you can import the functions and alias them with their uppercase names:
Code: from math import sqrt as SQRT 5.0 (12-03-2024 03:41 AM)toml_12953 Wrote: (…) the converter should know that sqrt is the same as SQRT and tan is the same as TAN, etc. Andy Bulka provides this converter as a free service. He describes its use and limitations. If that's not what you want, you have a few options:
|
|||
12-03-2024, 07:45 PM
Post: #13
|
|||
|
|||
RE: Sharp PC-1500A Compiler | |||
12-03-2024, 08:00 PM
Post: #14
|
|||
|
|||
RE: Sharp PC-1500A Compiler
I wanted to try calculating prime numbers, but I missed the IF...GOSUB function. I added it to the compiler, and now it works as IF...GS. I tried the program in Basic and the ABC compiler. I set the search from 1 to 100. Basic took 94 seconds, and the compiler did it in 34 seconds.
10 INPUT "Enter lower limit: "; A 20 INPUT "Enter upper limit: "; B 30 PRINT "The prime numbers between "; A; " and "; B; " are:" 40 LET N = A 50 IF N > B THEN GOTO 120 60 LET F = 1 70 IF N < 2 THEN LET F = 0 80 LET D = 2 90 IF D > INT(SQR(N)) THEN GOTO 110 100 IF N / D = INT(N / D) THEN LET F = 0 105 LET D = D + 1 106 GOTO 90 110 IF F = 1 THEN PRINT N;" "; 115 LET N = N + 1 116 GOTO 50 120 END 0 N=A 1cIFN>BGO* 2 F=L 3 IFN<KGS+ 4 D=K 5aR=N?X 6 R=RIX 7 IFD>RGO- 8 S=N/D 9 O=SIX 10 IFS=OGS+ 11 D=D+L 12 GOa 13-IFF=LGSb 14 N=N+L 15 GOc 16+F=I 17 RET 18bPRN 19 WE 20 RET 21*STOP 22 END For the compiler, you must manually enter the constants: A=1, B=100, K=2, L=1, I=0 |
|||
Yesterday, 06:57 AM
Post: #15
|
|||
|
|||
RE: Sharp PC-1500A Compiler
Here is new version.
|
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)