Luc Pauwels

HP28S Processor Notes

Copyright (C) 1989
Alonzo Gariepy
Version 1

The next several postings contain my notes on the HP28's CPU. The information they hold should be sufficient for you to start machine language programming your calculator. I make no claims about their quality or fitness for any particular purpose. Please inform me of any errors. I'm on the net at <uunet!microsoft!alonzo>.

Copyright (C) 1989 Alonzo M. Gariepy.

These notes are divided into four sections:

Future notes may include: These notes may not be distributed for profit without the written consent of the author.
I have completely reorganized and renamed the instruction set for my own purposes. This may render these notes of no value to some people, for which I am sorry. The new oganization and names have the following properties:
  1. One syntax for all instructions: OPERATION.FIELD ARGS

    ARGS is zero or more register names and constants separated by commas. This syntax simplifies reading, writing, assembly, and disassembly.

  2. Translations emphasize orthogonality (what little there is).

    The hex translations of instructions are decomposed into tables according to the field and register(s) to be operated on. This has simplified the writing of a declaritive assembler/disassembler in Prolog. You can pick up the use of these tables very quickly.

  3. All instructions that do the same operation have the same name.

    For example, all instructions that move data into register C have the form: MOVE.f x,C

  4. The mnemonics are much more like those of other processors.

Sample Program

Here is a sample program called SCR. It scrolls the display memory.
    SCR:	  ; scroll the display one pixel upwards.

132	   swap.a    a,d0	 ; save D0
103	   move.w    a,r3	 ;  in A.

D2	   clr.a     c		 ; set address field of C to 0.
3122	   move.p2   #22,c	 ; each 1/2 of LCD is 34*2 columns (+1 on right)
27	   move.1    7,p	 ; point to nibble 7.
307	   move.p1   7,c	 ; nibble 7 gets 0111 bit mask.
10A	   move.w    c,r2	 ; we'll want to use these values twice.
A81	   clr.p     b		 ; B is a flag, when set it is also a bit mask.
1B048FF    move.5    #FF840,d0	 ; starting address of left columns of LCD.

    LOOP:	  ; a 34 cycle loop in a 2 cycle loop: 2 * 34 * 2 = 136 columns.

1527	   move.w    @d0,a	 ; read two columns (64 bits) into A.
81C	   srb.w     a		 ; shift them right (scroll up).
0E06	   and.p     c,a	 ; mask out bit shifted from first column.
1507	   move.w    a,@d0	 ; put back the scrolled columns.

16F	   add.a     16,d0	 ; next two columns (16 nibbles hence).
CE	   dec.a     c		 ; decrement and test the lower five nibbles of
8AE9E	   brnz.a    c,LOOP	 ;  C that we are using as a counter.

90D31	   brnz.p    b,FINISH	 ; B==1 means we have done both sides of LCD.
1B00CFF    move.5    #FFC00,d0	 ; starting address of right columns of LCD.

11A	   move.w    r2,c	 ; yet another set of 34 double columns to do.
A85	   move.p    c,b	 ; set the flag indicating last time through.
64DF	   jump      LOOP

    FINISH:	  ; do the remaining column and exit.

1561	   move.wp   @d0,c	 ; read 32 bits (reg A didn't work).
81E	   srb.w     c		 ; shift column right (scroll up).
0E05	   and.p     b,c	 ; mask out bit shifted from first column.
1541	   move.wp   c,@d0	 ; put back (or maybe reg A didn't work here).
20	   move.1    0,p	 ; you must always restore P to 0.
113	   move.w    r3,a	 ; time to restore D0.

132	   move.a    a,d0	 ; start dispatch.
142	   move.a    @d0,a	 ; where we go next.
164	   add.a     5,d0	 ; make D0 ready for the next guy to dispatch.
808C	   jump      @a 	 ; bye-bye...

The information in these notes comes from my own experiments, from public HP documents, and from some non-HP documents.

Foremost among the latter is the book, "Customize Your HP-28" by W.A.C. Mier-Jedrzejowicz. This book contains a great deal of valuable information about every aspect of the HP28. It is available from:

P.O. Box 1080
Berkeley, California
94701-1080, USA
Thanks to Dave Kaffine for explaining the new instructions.