Post Reply 
Sharp PC-G850VS
04-12-2022, 02:07 AM
Post: #161
RE: Sharp PC-G850VS
(04-11-2022 08:32 PM)OS1 Wrote:  The other thing I can’t get working is the “void angle(void)” call. It just says Syntax Error. Does anyone know how to put a C program in to Radians when it runs?

The syntax is:
void angle (unsigned n);

Sets the mode for the trigonometric functions:
n = 0 : DEG
n = 1 : RAD
n = 2 : GRAD

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
04-12-2022, 07:34 PM
Post: #162
RE: Sharp PC-G850VS
(04-12-2022 02:07 AM)robve Wrote:  
(04-11-2022 08:32 PM)OS1 Wrote:  The other thing I can’t get working is the “void angle(void)” call. It just says Syntax Error. Does anyone know how to put a C program in to Radians when it runs?

The syntax is:
void angle (unsigned n);

Sets the mode for the trigonometric functions:
n = 0 : DEG
n = 1 : RAD
n = 2 : GRAD

- Rob

Thank you. One oddity, this seems to need to be the first instruction in the program. If you add it have way through the Rad appears in the display but the program ploughs on in degrees! Not a big deal, just an observation.
Find all posts by this user
Quote this message in a reply
04-12-2022, 08:09 PM
Post: #163
RE: Sharp PC-G850VS
(04-12-2022 07:34 PM)OS1 Wrote:  One oddity, this seems to need to be the first instruction in the program. If you add it have way through the Rad appears in the display but the program ploughs on in degrees! Not a big deal, just an observation.

Strange. That doesn't appear to happen on my G850VS:
10 int main() {
20   printf("Test\n");
30   angle(1);
40   printf("%.10g\n",sin(.1));
50   angle(0);
60   printf("%.10g\n",sin(.1));
70   angle(2);
80   printf("%.10g\n",sin(.1));
90 }


Test
0.09983341665
0.001745328366
0.001570795681

Perhaps a firmware bug in the G850V?

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
04-14-2022, 04:47 AM
Post: #164
RE: Sharp PC-G850VS
(04-12-2022 08:09 PM)robve Wrote:  
(04-12-2022 07:34 PM)OS1 Wrote:  One oddity, this seems to need to be the first instruction in the program. If you add it have way through the Rad appears in the display but the program ploughs on in degrees! Not a big deal, just an observation.

Strange. That doesn't appear to happen on my G850VS:

Perhaps a firmware bug in the G850V?

- Rob

The VS has EEPROM rather than the ROM of the straight V version. Casio undoubtedly made some fixes before shipping the newer VS.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
04-14-2022, 12:36 PM
Post: #165
RE: Sharp PC-G850VS
(04-14-2022 04:47 AM)toml_12953 Wrote:  The VS has EEPROM rather than the ROM of the straight V version. Casio undoubtedly made some fixes before shipping the newer VS.

Casio?? lol Smile

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
04-14-2022, 05:57 PM
Post: #166
RE: Sharp PC-G850VS
(04-14-2022 12:36 PM)rprosperi Wrote:  
(04-14-2022 04:47 AM)toml_12953 Wrote:  The VS has EEPROM rather than the ROM of the straight V version. Casio undoubtedly made some fixes before shipping the newer VS.

Casio?? lol Smile

Sure! Casio snuck in (to my thoughts, if not the Sharp factory) and made the change. Big Grin

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
06-29-2022, 08:30 AM
Post: #167
RE: Sharp PC-G850VS
(04-12-2022 08:09 PM)robve Wrote:  
(04-12-2022 07:34 PM)OS1 Wrote:  One oddity, this seems to need to be the first instruction in the program. If you add it have way through the Rad appears in the display but the program ploughs on in degrees! Not a big deal, just an observation.

Strange. That doesn't appear to happen on my G850VS:
10 int main() {
20   printf("Test¥n");
30   angle(1);
40   printf("%.10g¥n",sin(.1));
50   angle(0);
60   printf("%.10g¥n",sin(.1));
70   angle(2);
80   printf("%.10g¥n",sin(.1));
90 }


Test
0.09983341665
0.001745328366
0.001570795681

Perhaps a firmware bug in the G850V?

- Rob

I just tried this on my G850V (no S) model. It works fine. I also have the VS model and it works there, too.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
07-06-2022, 08:07 PM
Post: #168
RE: Sharp PC-G850VS
So for fun I've managed to write a Lisp interpreter in C for the Sharp PC-G850(V)(S).

[Image: lisp850.jpg]

The screen displays the "curry" function definition in Lisp, which applies one argument to a function to return a new function that takes the remaining arguments:

  > (define curry (lambda (f x) (lambda args (f x . args))))
  > ((curry + 1) 3)
  4


The interpreter compiles and runs on the PC-850(V)(S) itself, so the C source just needs to be copied to the machine via BLOAD then C(Text<-Basic) or via serial RS232.

The Lisp interpreter is only 87 lines long. An additional 44 lines of C implement 22 classic Lisp functions, specials and double precision arithmetic: eval, quote, cons, car, cdr, +, -, *, /, int, <, eq?, assoc, env, or, and, not, if, cond, let, lambda, define.

This Lisp interpreter supports lambda-closures with static scoping and global static scoping of defined functions to make recursion easy (like Scheme). This means that advanced Lisp examples work fine (perhaps with some tweaks). Like the Y combinator to apply anonymous recursive lambdas e.g. to compute factorial of 5 on the fly:

  > (define Y (lambda (f) (lambda args ((f (Y f)) . args))))
  > ((Y (lambda (f) (lambda (k) (if (< 0 k) (* k (f (- k 1))) 1)))) 5)
  120


The interpreter allocates 1024 cells of 8 bytes each to store pairs (cons), which is shared with a heap to store atom names. Cells are 8 bytes to store floating point values. This allocation should be big enough to run some practical Lisp code that does not need a lot of memory. Garbage collection is performed before the prompt returns to remove all temp lists of the last computation. The prompt shows the remaining number of free cells, e.g. 920 initially, since the 22 built-in functions take up some space.

I've done some hacking of the internals of floats to tag them as ATOM, PRIM, CONS, CLOS, and NIL so I can easily pass these Lisp expressions (as if they are floats) to the C functions of the interpreter for evaluation of atoms, primitives (such as lambda), lists and closures.

For one thing, it might prove that the PC-850(V)(S) C compiler is pretty capable. The C runtime is sufficiently robust, even when there is a lot of pointer stuff going on in the Lisp interpreter. And along the way I found some undocumented features in the C compiler/runtime of my PC-G850VS.

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
07-07-2022, 07:05 AM
Post: #169
RE: Sharp PC-G850VS
Wow - very impressive! Might you share your code?
Find all posts by this user
Quote this message in a reply
07-07-2022, 02:56 PM
Post: #170
RE: Sharp PC-G850VS
(07-07-2022 07:05 AM)EdS2 Wrote:  Wow - very impressive! Might you share your code?

Sure will be happy to. The plain code might not be as useful, so I will write something up to explain the internals.

I found some strange bug in my PC-G850VS C. The relational operators <, <=, >, >= don't work properly for some floating point values. Here is a simple test to check:

main() { printf("%d", 1e10 < 1e9); }

This should display 0 (false). But mine shows 1. It appears to happen only when comparing two floats with exponents Eab and Ec for digits a, b and c such that a<c. Also negative exponents E-ab and E-c have a similar problem (but off by one). The problem persists after resetting my G850VS.

A workaround for this issue is to avoid direct comparisons of floats like x<y and use x-y<0 instead to check the sign of the difference.

I don't know if this is a specific issue with my machine? Does anyone else see this?

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
07-07-2022, 05:12 PM
Post: #171
RE: Sharp PC-G850VS
(07-07-2022 02:56 PM)robve Wrote:  This should display 0 (false). But mine shows 1. It appears to happen only when comparing two floats with exponents Eab and Ec for digits a, b and c such that a<c. Also negative exponents E-ab and E-c have a similar problem (but off by one). The problem persists after resetting my G850VS.

A workaround for this issue is to avoid direct comparisons of floats like x<y and use x-y<0 instead to check the sign of the difference.

I don't know if this is a specific issue with my machine? Does anyone else see this?

- Rob

I do. I tried it on both a PS-850V and a PC-850VS and it prints 1 on both when using C. BASIC does handle it correctly.

Tom L
Cui bono?
Find all posts by this user
Quote this message in a reply
07-14-2022, 11:29 PM (This post was last modified: 07-15-2022 12:40 PM by robve.)
Post: #172
RE: Sharp PC-G850VS
(07-07-2022 07:05 AM)EdS2 Wrote:  Wow - very impressive! Might you share your code?

Thanks for your interest! Please see the new thread Lisp in 99 lines of C.

I found some undocumented features of the C compiler. These were probably omitted from the PC-G850(V)(S) manual by accident.

PC-G850(V)(S) manual omissions

P.78 section 8.6.3 does not mention the ternary ?: and comma , operators of C.
a ? b : c gives b if a is true otherwise gives c
a , b evaluates both a and b, but gives the value of b (*)
*) Do not call void-returning functions as operands of the comma operator, this will cause issues.

P.87 The C scanf(),fscanf(),sscanf() support %n conversion, which is not mentioned:
%n      Number of characters converted      (*)      int
For example, sscanf("123#", "%d%n", &n, &i) assigns 123 to n and 3 to i.
*) The %n conversion value is only set if the input could not be completely scanned: sscanf("123", "%d%n", &n &i) assigns 123 to %n but does not assign a value to i. Workaround: set i to strlen() before sscanf().

P.101 the beep() C function is missing in this section:
void beep (unsigned tone, unsigned duration, unsigned number)
Function: beep sound
Note the different parameter order compared to BEEP in Basic! See Basic BEEP for a description of the function.

P.101 the sizeof() function is missing in this section:
int sizeof(type)
int sizeof(expression)

Function: size of a type
Returns the size in bytes of the specified type or the size of the type of the specified expression. For example, sizeof(int) and sizeof(7) both return 2.

P.171 Basic function MDF is missing in this section:
MDF
MDF expression
See also: USING
Function: Modification function
Description: Returns the value of expression modified to the current USING format. See also Section 3.1.

The first one above is very important and useful. The second one is useful to replicate libc functions, such as strtol(), strtoul(), strtof(), strtod(), atol(), atoi() here listed in compact form to save space (please don't write C this way):

long strtol(const char*s,char**t,int b){long x;int n=strlen(s);sscanf(s,b==8?"%lo%n":b==16?"%lx%n":"%ld%n",&x,&n);if(t)*t=s+n;return x;}
unsigned long strtoul(const char*s,char**t,int b){unsigned long x;int n=strlen(s);sscanf(s,b==8?"%lo%n":b>10?"%lx%n":"%lu%n",&x,&n);if(t)*t=s+n;return x;}
float strtof(const char*s,char**t){float x;int n=strlen(s);sscanf(s,"%g%n",&x,&n);if(t)*t=s+n;return x;}
double strtod(const char*s,char**t){double x;int n=strlen(s);sscanf(s,"%lg%n",&x,&n);if(t)*t=s+n;return x;}
long atol(const char*s){return strtol(s,0,0);};
#define atoi atol


For example, strtol() supports decimal, octal and hex bases b and sets string pointer t to the point where conversion ended in the string s, if t!=NULL.

- Rob

Edit: fixed typo

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
08-05-2022, 08:41 PM
Post: #173
RE: Sharp PC-G850VS
(07-11-2018 11:01 PM)jwhsu Wrote:  I'm not sure if anyone is interested. I made an English translation of the PC-G850VS Users Guide based off the German translation using Google Translate. I also added some additional material from the PC-E500 manual and the 11-pin SIO interface PDF to help with examples and to make it more readable. Hopefully, the instructions on how to use CASL, Assembler, and C are accurate. I have tested some of the BASIC instructions, however, I am not familiar with C or assembly and haven't tested those functions. If anyone uses this and finds any errors, please let me know so I can make corrections. Thanks.

Sharp PC-850V(S) Users Guide
Thank you so much !
Is this translation "maintained"? i.e. thanks to it, I have unboxed again my G805VS and I have found a few issues in the manual. Should I report them here or is there another way ?
thanks again
-Alain
Find all posts by this user
Quote this message in a reply
11-11-2022, 01:18 AM
Post: #174
RE: Sharp PC-G850VS
Apologies for cross-posting this here. This announcement may otherwise get unnoticed by PC-G850 users. I usually think it's bad practice to do so on this Forum, but please let's be kind Smile

Forth850 for the PC-G850(V)(S) is now available

Forth850 has 294 words in an 8K executable. It's super fast by design and written from scratch in Z80 assembly (see the README in the repository for details). The nqueens benchmark runs in only 0.865 seconds. Compiling Forth source is speedy too without noticeable delays. I may add more features over time. Suggestions welcome!

Forth850 has a HP forum thread

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
01-25-2023, 03:18 PM
Post: #175
RE: Sharp PC-G850VS
Hey Everyone,

I noticed something peculiar on my 850, hope it is not of topic, has anyone tried to see the contents of the registers from Program Mode ("CALL &HBD03") and then check them again from the Machine Monitor("GBD03")? Well I tried and found out that the results are different and this baffles me to the point I think I have a bad unit. They should indicate the same register values shouldn't they?

Hope someone can help,
Tibi
Find all posts by this user
Quote this message in a reply
02-14-2023, 02:42 AM
Post: #176
RE: Sharp PC-G850VS
The PC-G850 user guide lists a number of ROM routines in Appendix J. But none of the serial routines work, or perhaps some require register parameters that aren't documented in the user guide.

When I searched for these ROM routines in the source code of PC-G850 utilities and games, such as MIDI850 and TerminalG850, I noticed that they all work at a lower level for SIO sending and receiving with Z80 IN and OUT opcodes in an interrupt routine. None use ROM routines.

I tried:

BCE2 Reads a byte from the serial interface to A (waits for the start bit indefinitely)
BCE8 Open (OPEN) the serial interface (11-pin)
BCEB Close (CLOSE) the serial interface (11-pin)

After BCE8 OPEN I tried BCE2 but that crashes the machine. Anyone has had any luck with the SIO ROM calls?

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
03-02-2023, 09:50 AM
Post: #177
RE: Sharp PC-G850VS
While looking at photos showing how easy it is to add a buzzer, I note two more pads for a backup battery. All 4 pads are dimensioned to mate with leaf connectors: they're not solder pads. So, is there another model in the series that has both a buzzer and a backup battery in the rear cover?
Find all posts by this user
Quote this message in a reply
05-03-2023, 04:19 PM
Post: #178
RE: Sharp PC-G850VS
Hi,

I have a G850VS on the way from Japan.

I read that I can use a FTDI serial to USB adapter board to connect the 850 to my PC for file transfer, I have such a board and suitable wires to connect. Also I believe I also need to make some configuration changes on the FTDI chip itself

Would someone be able to point to instructions as to how to set this up ?
Find all posts by this user
Quote this message in a reply
05-06-2023, 01:05 AM
Post: #179
RE: Sharp PC-G850VS
You should find all the info you need in the following thread, and in the attached PDF.
https://www.hpmuseum.org/forum/thread-19431.html
https://www.hpmuseum.org/forum/attachment.php?aid=9569

Jean-Charles
Find all posts by this user
Quote this message in a reply
05-08-2023, 01:05 PM
Post: #180
RE: Sharp PC-G850VS
(05-06-2023 01:05 AM)Helix Wrote:  You should find all the info you need in the following thread, and in the attached PDF.
https://www.hpmuseum.org/forum/thread-19431.html
https://www.hpmuseum.org/forum/attachment.php?aid=9569

It is unclear from that thread about what pins should connect where in terms of the connection from the FTDI adapter to the 850s 11 pin port. Also is the resistor really needed as I unable to soldier ?
Find all posts by this user
Quote this message in a reply
Post Reply 




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