Assorted WP-34S beginner questions - Printable Version +- HP Forums (https://www.hpmuseum.org/forum) +-- Forum: Not HP Calculators (/forum-7.html) +--- Forum: Not quite HP Calculators - but related (/forum-8.html) +--- Thread: Assorted WP-34S beginner questions (/thread-1482.html) Pages: 1 2 Assorted WP-34S beginner questions - Dave Britten - 05-31-2014 01:20 AM 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? RE: Assorted WP-34S beginner questions - Paul Dale - 05-31-2014 01:48 AM (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 RE: Assorted WP-34S beginner questions - Dave Britten - 05-31-2014 02:50 AM Cool, thanks, that clears things up. I'll have to grab a copy of the source and look around. RE: Assorted WP-34S beginner questions - walter b - 05-31-2014 07:35 AM (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:-) RE: Assorted WP-34S beginner questions - Dave Britten - 05-31-2014 12:30 PM (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. RE: Assorted WP-34S beginner questions - Dave Britten - 06-01-2014 03:00 AM 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. RE: Assorted WP-34S beginner questions - Thomas Klemm - 06-01-2014 07:21 AM (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 RE: Assorted WP-34S beginner questions - walter b - 06-01-2014 07:45 AM (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:-) RE: Assorted WP-34S beginner questions - Marcus von Cube - 06-01-2014 08:45 AM (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. RE: Assorted WP-34S beginner questions - Thomas Klemm - 06-01-2014 08:50 AM (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:  Unicode is the character-set while UTF-8 is the encoding. RE: Assorted WP-34S beginner questions - Dave Britten - 06-01-2014 11:17 AM (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. RE: Assorted WP-34S beginner questions - walter b - 06-01-2014 11:53 AM (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:-) RE: Assorted WP-34S beginner questions - BarryMead - 06-02-2014 04:58 PM (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 RE: Assorted WP-34S beginner questions - Dave Britten - 06-02-2014 06:49 PM (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. RE: Assorted WP-34S beginner questions - BarryMead - 06-02-2014 07:00 PM 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 RE: Assorted WP-34S beginner questions - Thomas Klemm - 06-02-2014 07:14 PM (06-02-2014 06:49 PM)Dave Britten Wrote:  Thanks Barry, I'll look into that. WP 34s Assembler Tool Suite User Guide RE: Assorted WP-34S beginner questions - BarryMead - 06-02-2014 08:17 PM 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 RE: Assorted WP-34S beginner questions - rprosperi - 06-03-2014 12:26 PM (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 Code Reading for Dummies - sa-penguin - 07-21-2014 10:08 AM 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? RE: Assorted WP-34S beginner questions - Paul Dale - 07-21-2014 11:22 AM 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 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