H P - 2 8 C N O T E 1 Subject: A collection of notes about the HP-28C Author : Wlodek Mier-Jedrzejowicz Brian, the following is an edited version of an article I wrote for DATAFILE, the journal of HPCC, which is the British club for owners of HP handhelds. I hope you will find a good home for it on the pages of HP Exchange. Good luck! So far I know of six HP-28Cs owned by members of the British club. At this stage I think a collection of short notes on the 28C would serve the club better than a long article, so here are some such notes. Three of the 28s were bought in England, the others by mail order from EduCALC in California for $189.90 plus $20 air post and insurance. The normal UK shop price including VAT (Value Added Tax) is »245. The lowest discount price to us in the UK is »194. Assuming you are charged the correct taxes, you will pay about »177, saving »17 at the expense of waiting 3 weeks. HP see the 18C and 28C as extended series 10 calculators and something of an experiment - if they sell well then HP will consider a similar HP-41 successor. In the meantime there is clearly room for one more extended model of the HP-41. HP appear to be happy to spread rumours about such a calculator. While making a phone call AND using my HP-28C I dropped it onto a hard floor. This proved two things to me: 1. The 28 is far less easy to operate with one hand than earlier HP calculators. 2. The 28 can survive a 3 foot drop onto a marble floor without any damage. If your HP-28C does break down or get broken and you return it to HP then, we are told, it will be thrown away and replaced by a new one. One member who did return his 28 got a new one - which HP referred to as a "service unit". In other words the 18C and 28C are not designed to be opened and repaired. Thus if we want to know what a 28 looks like inside then we shall have to buy one and break it open. To this end I have started an R & D fund to buy a 28 for "Research and Development". Our Treasurer is currently holding this which he calls the "Riot and Destruction" fund. Further contributions will be gratefully received. The results of the "Research and Destruction" will be communicated to all contributors, and should be printed in DATAFILE later. As described in my previous article (DATAFILE V6N1p13), the HP-28C uses 20-bit addresses. A 20-bit address takes up 2ø bytes, or 5 nybbles. If you use MEM as I described you will find that program instructions are 5 nybbles long each - in other words each instruction in a program is stored as the address of the machine code which will execute (and display) that instruction. This is different from previous calculators which stored each program instruction as a one-byte-long "token". When the program was executed, each token was translated into the address of that instruction, and then the instruction was executed. The 28C saves time by avoiding the need for this translation, but it takes 2ø times as much space. With a completely clear memory the 28C provides you with 1687 bytes; room for about 650 program steps, assuming you leave at least some space for the stack, UNDO, and the extra instructions at the beginning and end of the program. This is not really much better than the HP-15C which allows a maximum of 448 steps. By comparison, the 41CV uses some multi-byte steps, averaging at about 1ø bytes per step, and has a main memory of 2,237 bytes, allowing about 1,400 steps. HP-28C "objects" consist of a 5 nybble address, followed if necessary by more addresses and/or some data. For example each of the integer numbers from -9 to +9 is stored as the 5 nybble address of a routine which displays that integer and provides its value in calculations. (The address of the integer 5, for instance, is hexadecimal 1E353.) Symbolic constants such as "pi" are stored in a program in the same way, but normal real numbers are stored as 32 nybbles - the last 16 nybbles contain a sign, a 12-digit mantissa and a three-digit exponent, just as on the HP-71B. The preceding 16 nybbles provide room for three addresses and for one more data nybble, though I have not yet worked out how these are used. (Maybe some of them are used in displaying the number?) It is clear however that the two steps 5, INV only take up 5 bytes whereas the equivalent constant 0.2 takes up 16 bytes. Obviously it is worth using single- digit integers where possible in programs. The memory of an empty 28C can hold 103 real numbers, compared with 67 in a 15C (plus 5 in the stack) and 319 in the 41CV (plus at least 9 more in the stack and synthetically accessible registers). Thus the 28C is closer to the 15C than the 41CV - at least in terms of data and program storage. It IS better than the HP-41C, but as it is 7ø years newer so it should be. Anyway, data and program storage are not the only criteria to be used - for symbolic algebra the 28C wins hands down, but if you want to use devices which store programs or large amounts of data then you need an HP-41. Other objects which only use 5 nybbles (in the stack) are upper-case single- character names, and an empty text string. Other names use an overhead of at least 10 extra bytes, so it is a good idea to use names consisting of a single upper-case character wherever possible. One more object which takes only 5 nybbles is a duplicate entry in the stack. If you make a second copy of an item on the stack by pressing ENTER or using DUP, OVER or PICK then the 28C does not create another copy - instead it apparently stores the address of a routine which displays a duplicate of the original, and uses it in evaluations. Clearly this can be used to save a lot of memory if you know about it; making a second copy by recalling an object from storage a second time, or entering it from the keyboard takes more space. It now becomes clearer what a "System Object" is. Any address can be put on the stack; however if it is not the address of a routine which displays a specific type of object, then the HP-28C displays "System Object" instead. Similarly if it cannot provide a type then the TYPE function gives the message "Bad Argument Type". As there is no easy way of putting an arbitrary address on the stack to execute the code at that address, the 28C provides SYSEVAL which converts a binary number into an address and then executes the code at that address. This does not explain WHY HP provided the SYSEVAL function, but it is very useful. In my previous article (and in the HP-28C Special Issue of DATAFILE) I wrote that a second copy is made of a program when it is running. This appears not to be the case, since MEM gives the same result when executed from the keyboard or from a running program. Still, programs which PURGE themselves do carry on running; the name is immediately removed from the USER menu, but its area is not immediately cleared, so the program carries on running. Some users have remarked that PURGE seems to have a bug because it does not give an error message when you try to PURGE a nonexistent named object. In fact this seems to have been a conscious design decision, not a bug, since it would be difficult for PURGE to make a full check if it is not to delete objects immediately. After considerable effort by myself and Ian Maw we have developed a method of translating an object on the stack into a string of bytes. Thus we can study data objects, or find the ROM address of an instruction. These notes include some results of this work, I plan to describe the method in a separate article. Using this method, I have made a list of the address of every operation in the HP-28C catalog. Since this is supposed to be a collection of short notes, I shall not include the list here, but if we don't get a full operating system listing from HP then I shall plan to publish the list. After entering an object into the command line remember you must press ENTER twice to put two copies in the 28C stack. Colin Crowther points out that on previous HP calculators the number was entered directly into the X register; you only needed to press ENTER once to make a second copy, so be careful when you use ENTER. One stack operation I find very useful is SWAP, DROP - this removes the second object on the stack - useful if you are trying to save space, particularly if you are doing a calculation that produces two numbers of which you only need one. Finally, here is an interesting snippet passed on to me by Jeremy Smith. The hexadecimal number #123E is the address of the routine which reads the system clock. (Such a routine is needed since the clock is used, for example, as a seed for the random number generator.) Thus << #123E SYSEVAL >> returns the clock reading. You can use this to time your calculations, or even to use the HP-28C as a watch. The system clock is updated 8,192 (decimal) times a second, it is initialised when you first put a set of batteries in the 28C, and it is not cleared by a MEMORY LOST nor if you remove the batteries for a short time. I have heard one report of an HP-28C whose timing suddenly went wrong. Is this a bug? It could be similar to the HP-71B time bug, some other software bug, a hardware problem, or it could have been a once only problem, for example due to static. The HP-28C appears to suffer less from static than the HP-41, but some reports suggest it is not completely immune.