Post Reply 
Assorted WP-34S beginner questions
05-31-2014, 01:20 AM
Post: #1
Assorted WP-34S beginner questions
Got a few questions I haven't been able to answer either via the manual or just plain old poking and prodding...

1. I've seen some programs that do STO I, STO K, etc. Those don't seem to correspond to stack registers. What are these alphabetic register names exactly?

2. Can I call LocR again from within the same program to dynamically increase/decrease the current number of locals?

3. What flags have special meanings, and what are they? As far as I can tell, the numbered flags are all for user-defined purposes, but there are alphabetic ones too.

4. Somehow I managed to crash program execution and when I hit P/R, I appeared to be browsing around the XROM code (the step number was reported as 'Error 037' or whatever the number happened to be). Is there a way to get in there deliberately (and safely) to examine routines?
Visit this user's website Find all posts by this user
Quote this message in a reply
05-31-2014, 01:48 AM
Post: #2
RE: Assorted WP-34S beginner questions
(05-31-2014 01:20 AM)Dave Britten Wrote:  1. I've seen some programs that do STO I, STO K, etc. Those don't seem to correspond to stack registers. What are these alphabetic register names exactly?

They are I, J and K. They are just a few extra registers, although they have special meanings some of the time. I is used to hold the complex component of LastX when doing complex operations, J & K are used for the statistical distributions. There are also registers A, B, C and D. These are the top four levels of the eight level stack. If you're using the four level stack, they are available as general purpose registers.


Quote:2. Can I call LocR again from within the same program to dynamically increase/decrease the current number of locals?

Yes. If you call it in a subroutine, new locals will be allocated however.


Quote:3. What flags have special meanings, and what are they? As far as I can tell, the numbered flags are all for user-defined purposes, but there are alphabetic ones too.

A turns on the equals annunicator. B is the integer mode overflow, C is integer mode carry. D enables some extra numeric features in real mode (NaN, negative zero, infinities). T sets the printer trace mode.


Quote:4. Somehow I managed to crash program execution and when I hit P/R, I appeared to be browsing around the XROM code (the step number was reported as 'Error 037' or whatever the number happened to be). Is there a way to get in there deliberately (and safely) to examine routines?

No, getting into this section of memory shouldn't be possible.

If you want to examine the code, look at the source code directly, it will make more sense. trunk/xrom/


- Pauli
Find all posts by this user
Quote this message in a reply
05-31-2014, 02:50 AM
Post: #3
RE: Assorted WP-34S beginner questions
Cool, thanks, that clears things up. I'll have to grab a copy of the source and look around.
Visit this user's website Find all posts by this user
Quote this message in a reply
05-31-2014, 07:35 AM
Post: #4
RE: Assorted WP-34S beginner questions
(05-31-2014 01:20 AM)Dave Britten Wrote:  Got a few questions I haven't been able to answer either via the manual or just plain old poking and prodding...

Your questions 1 and 3 should be answered by the very first page of "Addressing Objects" in the manual.

d:-)
Find all posts by this user
Quote this message in a reply
05-31-2014, 12:30 PM
Post: #5
RE: Assorted WP-34S beginner questions
(05-31-2014 07:35 AM)walter b Wrote:  
(05-31-2014 01:20 AM)Dave Britten Wrote:  Got a few questions I haven't been able to answer either via the manual or just plain old poking and prodding...

Your questions 1 and 3 should be answered by the very first page of "Addressing Objects" in the manual.

d:-)

Ah, perfect, hiding in plain sight. I wasn't expecting to find that level of technical detail on the section intro page.
Visit this user's website Find all posts by this user
Quote this message in a reply
06-01-2014, 03:00 AM
Post: #6
RE: Assorted WP-34S beginner questions
Follow-up question: What's the best way to handle generating/posting WP-34S program listings? They tend to use a lot of special characters, and the program I'm working on uses a boatload of them in alpha mode.
Visit this user's website Find all posts by this user
Quote this message in a reply
06-01-2014, 07:21 AM
Post: #7
RE: Assorted WP-34S beginner questions
(06-01-2014 03:00 AM)Dave Britten Wrote:  What's the best way to handle generating/posting WP-34S program listings?

For this article I used wp34s_asm.pl.

Assemble the source:
tools/wp34s_asm.pl cordic.wp34s -o cordic.dat

Disassemble the binary image file:
tools/wp34s_asm.pl -dis cordic.dat


HTH
Thomas
Find all posts by this user
Quote this message in a reply
06-01-2014, 07:45 AM
Post: #8
RE: Assorted WP-34S beginner questions
(06-01-2014 03:00 AM)Dave Britten Wrote:  What's the best way to handle generating/posting WP-34S program listings? They tend to use a lot of special characters, and the program I'm working on uses a boatload of them in alpha mode.

This forum can deal with 'special' characters since it understands Unicode.

d:-)
Find all posts by this user
Quote this message in a reply
06-01-2014, 08:45 AM
Post: #9
RE: Assorted WP-34S beginner questions
(06-01-2014 07:45 AM)walter b Wrote:  This forum can deal with 'special' characters since it understands Unicode.

This is nice for posting. For entering code into the assembler you can use alias names for most of the commands which are easier to type in. In the tools directory you can find the command-alias.csv file with the alias names. The CSV is automatically created during the build process. I've appended an Open Document Sheet and a PDF here which I've just created from the above mentioned file.


Attached File(s)
.zip  command-alias.ods.zip (Size: 93.33 KB / Downloads: 5)
.pdf  command-alias.pdf (Size: 148.22 KB / Downloads: 27)

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
06-01-2014, 08:50 AM
Post: #10
RE: Assorted WP-34S beginner questions
(06-01-2014 07:45 AM)walter b Wrote:  This forum can deal with 'special' characters since it understands Unicode.

It's UTF-8 to be precise:
Code:
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

Unicode is the character-set while UTF-8 is the encoding.
Find all posts by this user
Quote this message in a reply
06-01-2014, 11:17 AM
Post: #11
RE: Assorted WP-34S beginner questions
(06-01-2014 07:45 AM)walter b Wrote:  
(06-01-2014 03:00 AM)Dave Britten Wrote:  What's the best way to handle generating/posting WP-34S program listings? They tend to use a lot of special characters, and the program I'm working on uses a boatload of them in alpha mode.

This forum can deal with 'special' characters since it understands Unicode.

d:-)

That's good, but then there's still the matter of entering the characters. I'd probably be spending a lot of time with the unicode character map to get that done.

Does the Windows or iOS emulator allow keying in a program, then exporting the source as formatted unicode? I'd be fine with that approach for the occasional software library posting.
Visit this user's website Find all posts by this user
Quote this message in a reply
06-01-2014, 11:53 AM
Post: #12
RE: Assorted WP-34S beginner questions
(06-01-2014 11:17 AM)Dave Britten Wrote:  ... there's still the matter of entering the characters.

In such cases I usually open a dummy MS Word file and insert my special characters there. Then copy & paste them in the forum post.

d:-)
Find all posts by this user
Quote this message in a reply
06-02-2014, 04:58 PM (This post was last modified: 06-02-2014 05:15 PM by BarryMead.)
Post: #13
RE: Assorted WP-34S beginner questions
(06-01-2014 11:17 AM)Dave Britten Wrote:  That's good, but then there's still the matter of entering the characters. I'd probably be spending a lot of time with the unicode character map to get that done.

Does the Windows or iOS emulator allow keying in a program, then exporting the source as formatted unicode? I'd be fine with that approach for the occasional software library posting.
Using Windows 7, when you exit the Windows emulator, the program is saved in the file:

C:/Users/your_user_name/AppData/Roaming/WP-34s/wp34s.dat

Use the perl disassembler program mentioned above to EXTRACT your program from the "wp34s.dat" RAM image
created by the emulator.

Hope this helps, Barry
Find all posts by this user
Quote this message in a reply
06-02-2014, 06:49 PM
Post: #14
RE: Assorted WP-34S beginner questions
(06-02-2014 04:58 PM)BarryMead Wrote:  
(06-01-2014 11:17 AM)Dave Britten Wrote:  That's good, but then there's still the matter of entering the characters. I'd probably be spending a lot of time with the unicode character map to get that done.

Does the Windows or iOS emulator allow keying in a program, then exporting the source as formatted unicode? I'd be fine with that approach for the occasional software library posting.
Using Windows 7, when you exit the Windows emulator, the program is saved in the file:

C:/Users/your_user_name/AppData/Roaming/WP-34s/wp34s.dat

Use the perl disassembler program mentioned above to EXTRACT your program from the "wp34s.dat" RAM image
created by the emulator.

Hope this helps, Barry

Thanks Barry, I'll look into that.
Visit this user's website Find all posts by this user
Quote this message in a reply
06-02-2014, 07:00 PM (This post was last modified: 06-02-2014 07:03 PM by BarryMead.)
Post: #15
RE: Assorted WP-34S beginner questions
Another thing you can do is to copy the wp34s.dat file to something else like:
mymathfunction1.dat or myspcialprogram.dat

Then whenever you want to instantly reload that program just rename or copy it over the wp34s.dat
file and when you bring up the emulator you have that custom program loaded.

I find this method easier to handle than the assembly/disassembly method of managing a library of custom
user programs.

But if your goal is to share "source" with others then you will probably want to use the disassembler to extract and save your source.

Enjoy, Barry
Find all posts by this user
Quote this message in a reply
06-02-2014, 07:14 PM
Post: #16
RE: Assorted WP-34S beginner questions
(06-02-2014 06:49 PM)Dave Britten Wrote:  Thanks Barry, I'll look into that.

WP 34s Assembler Tool Suite User Guide
Find all posts by this user
Quote this message in a reply
06-02-2014, 08:17 PM (This post was last modified: 06-02-2014 08:22 PM by BarryMead.)
Post: #17
RE: Assorted WP-34S beginner questions
There are lots of command line options to memorize and get familiar with.
These are the ones that I find useful when disassembling my programs to source.

From the C:/Users/your_user_name/AppData/Roaming/WP-34s/ directory type:

wp34s_asm.exe -dis wp34s.dat -s 0 -ns -dis_alias -o myprogram.wp34s

These options:
1. Disassemble instead of assemble
2. Remove the stars from labels
3. Remove the line numbers from disassembled output
4. Convert alias names to more standard keystroke names
5. Select the output file as myprogram.wp34s

Sometimes an example is worth many readings of Assembler users manual.

Take Care, Barry
Find all posts by this user
Quote this message in a reply
06-03-2014, 12:26 PM
Post: #18
RE: Assorted WP-34S beginner questions
(06-02-2014 08:17 PM)BarryMead Wrote:  Sometimes an example is worth many readings of Assembler users manual.

Take Care, Barry

Sooooo tue. On second thought, it's not sometimes...
Thanks for a useful, real-world example

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
07-21-2014, 10:08 AM
Post: #19
Code Reading for Dummies
Inspired by some Uni homework on numerical methods (Newton, Householder, Halley, Taylor series etc.) I went looking for the 34S code for trig and square root functions. However...
With all the subdirectories and code - I got lost.

Is there a "Code for Dummies" for the 34S code?
That "Command Alias" PDF is nice, but: given an instruction, how do I find the source code for that instruction? I'm looking for the trig functions, but really there should be a lookup for every function.
A search of the trunk for "COS" shows it in commands.c xeq.h complex.c but I'm blessed if I can find where cosines are actually evaluated.
What am I missing?
Find all posts by this user
Quote this message in a reply
07-21-2014, 11:22 AM
Post: #20
RE: Assorted WP-34S beginner questions
There isn't an internal road map. I really should write one in due course. Others have figured out how to navigate the code base with some success, often the more complicated areas than the numeric code. Thus, there is hope of understanding Smile


Square root, log, exponential and the basic arithmetic are in trunk/decNumber/decNumber.c

Pretty much all the rest of the real functions are in trunk/decn.c This includes the trig and hyperbolic functions. Search for decNumberSin and follow the code from there.


The 34S uses a Taylor series (MacLaurin actually) expansion for the trig functions after a range reduction step. The range reduction is exact for degrees and gradians but not for radians (although it should still be correctly rounded to the internal precision).


The 31S trig code is the slightly more advanced of the two because the 31S has spare flash and the 34S doesn't. This code is in branches/wp31s/decn.c Here the range reduction is followed by an octant reduction which reduces the argument to a small value. This avoids a degenerate case for cosine and provides certainty for things like \(cos(\frac{\pi}{2} + x) = - cos(\frac{\pi}{2} - x)\).


- Pauli
Find all posts by this user
Quote this message in a reply
Post Reply 




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