kkx ADD.f s,d kk | f x | s d -------- --------- A0 | P 0 | B A A1 | WP 1 | C B A2 | XS 2 | A C A3 | X 3 | C D A4 | S 4 | A A A5 | M 5 | B B A6 | B 6 | C C A7 | W 7 | D D C | A 8 | A B 9 | B C A | C A B | D C Examples: C8 ADD.A A,B ; B = B + A (20 bits) A70 ADD.W B,A ; A = A + B (64 bits) A36 ADD.X C,C ; C = C + C (12 bits)
"The 818... opcodes don't always work as advertised. To be specific, when the field of such an instruction is XS, S, P, or WP, and a carry (or borrow) is generated out of the most significant nibble, it wraps around and affects the least significant nibble." -- D.K.
818twi ADD.f i+1,d t | f x | d ------- ------- 0 | P 0 | A 1 | WP 1 | B 2 | XS 2 | C 3 | X 3 | D 4 | S 5 | M 6 | B 7 | W F | A Examples: 818718 ADD.W 9,B ; B = B + 9 (64 bits) 81860F ADD.B 16,A ; A = A + 16 (8 bits)
These instructions let you add a constant from 1 to 16 to the contents of registers D0 or D1.
16x ADD.A x+1,D0 *** 17x ADD.A x+1,D1 *** Examples: 164 ADD 5,D0 ; D0 = D0 + 5 (20 bits) 17E ADD 15,D1 ; D1 = D1 + 15 (20 bits)
809 ADD.A P+1,C Examples: 809 ADD.A P+1,C ; C = C + P + 1 (20 bits)
0Exy AND.f s,d x | f y | s d ------- --------- 0 | P 0 | B A 1 | WP 1 | C B 2 | XS 2 | A C 3 | X 3 | C D 4 | S 4 | A B 5 | M 5 | B C 6 | B 6 | C A 7 | W 7 | D C F | A Examples: 0E63 AND.B C,D ; D = D & C (8 bits) 0EF5 AND.A B,C ; C = C & B (20 bits)
These instructions branch or return when an associated test evaluates true. The destination of the branch is the sum of an 8 bit sign extended 2's complement offset and the address of that offset. When the offset is 00, the destination is reached by popping an address off the return stack.
In the following, the destination argument is expressed relative to the address of the instruction (designated PC). In the case of a return, this argument can be omitted and the BR in the mnemonic substituted with RET.
These instructions branch/return depending on whether the specified bit in a register is 0 or 1.
8086xyy BRBC x,A,PC+5+yy 808Axyy BRBC x,C,PC+5+yy 83zyy BRBC hf,PC+3+yy 86xyy BRBC x,ST,PC+3+yy 8087xyy BRBS x,A,PC+5+yy 808Bxyy BRBS x,C,PC+5+yy 87xyy BRBS x,ST,PC+3+yy z | hf -------- 1 | XM 2 | SB 4 | SR 8 | MP Examples: 808B900 RETBS 9,C ; return if bit 9 of C is set 8765F BRBS 6,ST,PC-8 ; jump 8 nibbles before instruction ; if bit 6 of ST is set 8086E02 BRBC 14,A,PC+37 ; jump 37 nibbles from instruction ; if bit 14 of A is clear 83400 RETC SR ; return if Service Request clear 8380F BRBC MP,PC-13 ; jump -13 if Module Pulled clear
These instructions branch/return depending on whether the carry flag is clear or set.
5xx BRCC PC+1+xx 4xx BRCS PC+1+xx Examples: 500 RETCC ; return if carry clear 45F BRCS PC-10 ; branch -10 nibbles if carry set 550 BRCC PC+6 ; branch +6 nibbles if carry clear
These instructions branch/return depending on whether the 4 bit register P is equal/not equal to a 4 bit constant.
89xyy BREQ.1 P,x,PC+3+yy *** 88xyy BRNE.1 P,x,PC+3+yy *** Examples: 89C31 BREQ P,12,PC+22 ; branch +22 if P equals 12 88500 RETNE P,5 ; return if P not equal to 5
These instructions branch/return depending on the result of an inequality between the fields of two registers.
ttuyy BREQ.f s,d,PC+3+yy ttvyy BRNE.f s,d,PC+3+yy ttwyy BRZ.f s,PC+3+yy ttxyy BRNZ.f s,PC+3+yy zzuyy BRGT.f s,d,PC+3+yy zzvyy BRLT.f s,d,PC+3+yy zzwyy BRGE.f s,d,PC+3+yy zzxyy BRLE.f s,d,PC+3+yy tt zz | f u v w x | s d ----------- --------------- 8A 8B | A 0 4 8 C | A B 90 98 | P 1 5 9 D | B C 91 99 | WP 2 6 A E | C A 92 9A | XS 3 7 B F | D C 93 9B | X 94 9C | S 95 9D | M 96 9E | B 97 9F | W Examples: 8B500 RETLT.A B,C ; return if B < C (20 bits) 93BD0 BRZ.X D,PC+16 ; branch +16 if D is zero (12 bits) 9FA00 RETGE.W C,A ; return if C >= A (64 bits)
8083 BUSCB 80B BUSCC 808D BUSCD 804 UNCNFG ; unconfig all chips 805 CONFIG ; config next chip 806 MOVE.A ID,C ; get ID of current chip 807 SHUTDN ; shutdown bus, stop cpu 80A RESET ; bus reset, resets chips 80E SREQ ; check for service request
Unlike the BR and relative JUMP commands, relative CALLs contain an offset from the next instruction. In the following these are expressed relative to the address of the CALL instruction itself (PC). Offsets are in stored in 2's complement form.
7xxx CALL.3 PC+4+xxx *** 8Exxxx CALL.4 PC+6+xxxx Examples: 7040 CALL PC+68 ; call 68 nibbles from this instruction 8E020E CALL.4 PC-8154 ; call 8154 nibbles back from insruction
8Fxxxxx CALL.A xxxxx Examples: 8F0200C CALL.A #C0020 ; call to absolute address #C0020h
ppt CLR.f d pp | f t| d -------- ------ A8 | P 0| A A9 | WP 1| B AA | XS 2| C AB | X 3| D AC | S AD | M AE | B AF | W D | A Examples: D2 CLR.A C ; clear address field of C (20 bits) A83 CLR.P D ; clear nibble of D pointed to by P AF0 CLR.W A ; clear all of A (64 bits)
8084x CLRB x,A 8088x CLRB x,C 84x CLRB x,ST Examples: 8084D CLRB 13,A ; clear bit 13 of register A 80880 CLRB 0,C ; clear bit 0 of register C 847 CLRB 7,ST ; clear bit 7 of ST
The bits 1,2,4, and 8 can be ORed together to clear more than one hardware status flag at a time.
82x CLRB d* x | d -------- 1 | XM 2 | SB 4 | SR 8 | MP Examples: 825 CLR XM,SR 822 CLR SB
08 CLR.X ST ***
0D DEC.1 P *** kkw DEC.f d kk | f w | d -------- ------- A0 | P C | A A1 | WP D | B A2 | XS E | C A3 | X F | D A4 | S A5 | M A6 | B A7 | W C | A Examples: 0D DEC P ; P = P - 1 (4 bits) A3D DEC.X B ; B = B - 1 (12 bits)
802 IN.4 A *** 803 IN.4 C ***
0C INC.1 P *** qqu INC.f d qq | f u | d -------- ------- B0 | P 4 | A B1 | WP 5 | B B2 | XS 6 | C B3 | X 7 | D B4 | S B5 | M B6 | B B7 | W E | A Examples: 0C INC P ; P = P - 1 (4 bits) B77 INC.W D ; D = D - 1 (64 bits)
808F INTOFF 8080 INTON 80810 RSI
The JUMP command takes a 2's complement offset relative to the address of the offset, stored with the least signficant bit first. In the following, the destination is expressed relative to the address of the JUMP instruction.
6xxx JUMP.3 PC+1+xxx *** 8Cxxxx JUMP.4 PC+2+xxxx Examples: 6C10 JUMP PC+29 6C1F JUMP PC-227 8C1001 JUMP.4 PC+4099
8Dxxxxx JUMP.A xxxxx
These opcodes are useful for implementing the threaded RPL interpreter of the HP28S. They can be expressed either as MOVE or JUMP instructions. The effect is to set the PC to the address pointed at by the address pointed at by the register.
808C JUMP.A @A *** 808C MOVE.A @A,PC *** 808E JUMP.A @C *** 808E MOVE.A @C,PC ***
Opcodes 81B2 and 81B3 can be expressed either as MOVE or JUMP instructions. The SWAP instructions might be useful for implementing coroutines.
81B2 JUMP.A A *** 81B2 MOVE.A A,PC *** 81B3 JUMP.A C *** 81B3 MOVE.A C,PC *** 81B6 SWAP.A A,PC *** 81B7 SWAP.A C,PC ***
There are so many MOVE instructions that it might make sense to distinguish them with their own names, but there is also virtue in limiting the number of mnemonics one must remember.
ppz MOVE.f s,d pp | f z | s d -------- --------- A8 | P 4 | B A A9 | WP 5 | C B AA | XS 6 | A C AB | X 7 | C D AC | S 8 | A B AD | M 9 | B C AE | B A | C A AF | W B | D C D | A Examples: D9 MOVE.A B,C ; C gets B (20 bits) AE4 MOVE.B B,A ; A gets B (8 bits) AFB MOVE.W D,C ; C gets D (64 bits)
These instructions move between memory and registers A or C by indirecting through address registers D0 or D1.
14x MOVE.A s,d 14y MOVE.B s,d 15xt MOVE.f s,d 15yi MOVE.n s,d ; n = i + 1 x y | s d t | f -------------- ------- 0 8 | A @D0 0 | P 1 9 | A @D1 1 | WP 2 A | @D0 A 2 | XS 3 B | @D1 A 3 | X 4 C | C @D0 4 | S 5 D | C @D1 5 | M 6 E | @D0 C 6 | B 7 F | @D1 C 7 | W Examples: 142 MOVE.A @D0,A ; A gets 20 bits stored at D0 15D6 MOVE.7 C,@D1 ; Store 28 bits of C at D1 1577 MOVE.W @D1,C ; C gets 64 bits stored at D1 149 MOVE.B A,@D1 ; Store one byte of A at D1 1516 MOVE.B A,@D1 ; Store one byte of A at D1 1591 MOVE.2 A,@D1 ; Store one byte of A at D1
13w MOVE.A s,Da *** 13y MOVE.4 s,Da w y | s Da ----------- 0 8 | A D0 1 9 | A D1 4 C | C D0 5 D | C D1 Examples: 131 MOVE A,D1 ; D1 gets A (20 bits) 13C MOVE.4 C,D0 ; D0 gets C (16 bits)
10j MOVE.W A,Rn *** 10k MOVE.W C,Rn *** 11j MOVE.W Rn,A *** 11k MOVE.W Rn,C *** 81At0j MOVE.f A,Rn 81At0k MOVE.f C,Rn 81At1j MOVE.f Rn,A 81At1k MOVE.f Rn,C 81At2j SWAP.f A,Rn 81At2k SWAP.f C,Rn t | f j k | Rn ------- ---------- 0 | P 0 8 | R0 1 | WP 1 9 | R1 2 | XS 2 A | R2 3 | X 3 B | R3 4 | S 4 C | R4 5 | M 6 | B 7 | W F | A Examples: 100 MOVE A,R0 ; R0 gets A (64 bits) 11C MOVE R4,C ; C gets R4 (64 bits) 81A71C MOVE.W R4,C ; C gets R4 (64 bits) 81A309 MOVE.X C,R1 ; R1 gets C (12 bits)
Opcodes 81B2 and 81B3 can be expressed either as MOVE or JUMP instructions.
81B2 MOVE.A A,PC *** 81B3 MOVE.A C,PC *** 81B4 MOVE.A PC,A *** 81B5 MOVE.A PC,C ***
These opcodes are useful for implementing the threaded RPL interpreter of the HP28S. They can be expressed either as MOVE or JUMP instructions. The effect is to set the PC to the address pointed at by the address pointed at by the register.
808C MOVE.A @A,PC *** 808E MOVE.A @C,PC ***
These instructions move a variable length constant from the instruction stream into registers A or C beginning with the nibble pointed to by register P. This results in a unique field type, Pn, where P designates the position where the constant will be moved and n the size of the constant in nibbles.
3ix...x MOVE.Pn x...x,C ; n = i + 1 8082ix...x MOVE.Pn x...x,A ; n = i + 1 Examples: 34910C0 MOVE.P5 #C019,C 32310 MOVE.P3 19,C 808234000 MOVE.P4 4,A
19xx MOVE.2 xx,D0 1Axxxx MOVE.4 xxxx,D0 1Bxxxxx MOVE.5 xxxxx,D0 1Dxx MOVE.2 xx,D1 1Exxxx MOVE.4 xxxx,D1 1Fxxxxx MOVE.5 xxxxx,D1 Examples: 1940 MOVE.2 4,D0 ; D0 gets 4 (8 bits) 1E1234 MOVE.4 #4321,D1 ; D1 get #4321h (16 bits) 1B12340 MOVE.5 #4321,D0 ; D0 gets #04321h (20 bits)
2x MOVE.1 x,P *** Examples: 27 MOVE 7,P ; P points to nibble 7 2C MOVE 12,P ; P points to nibble 12
Move 4 bit P register value to or from the specified nibble (x) of regiester C.
80Cx MOVE.1 P,C,x *** 80Dx MOVE.1 C,x,P *** Examples: 80C0 MOVE P,C,0 ; nibble 0 of C gets P (4 bits) 80D7 MOVE C,7,P ; P gets nibble 7 of C (4 bits)
09 MOVE.X ST,C *** 0A MOVE.X C,ST ***
rrv NEG.f d rr | f v | d -------- ------- B8 | P 8 | A B9 | WP 9 | B BA | XS A | C BB | X B | D BC | S BD | M BE | B BF | W F | A Examples: FA NEG.A C ; C = -C (20 bits) BEB NEG.B D ; D = -D (8 bits)
These instructions do nothing.
420 NOP3 6300 NOP4 64000 NOP5
rrw NOT.f d rr | f w | d -------- ------- B8 | P C | A B9 | WP D | B BA | XS E | C BB | X F | D BC | S BD | M BE | B BF | W F | A Examples: BCE NOT.S C ; invert nibble 15 of C (4 bits) FF NOT.A D ; invert D (20 bits)
0Exz OR.f s,d x | f z | s d ------- --------- 0 | P 8 | B A 1 | WP 9 | C B 2 | XS A | A C 3 | X B | C D 4 | S C | A B 5 | M D | B C 6 | B E | C A 7 | W F | D C F | A Examples: 0E6C OR.B A,B ; B = B & A (8 bits) 0EFF OR.A D,C ; C = C & D (20 bits)
800 OUT.S C 801 OUT.X C
07 POP.A C ***
06 PUSH.A C ***
01 RET ; return 02 RETSETC ; set carry and return 03 RETCLRC ; clear carry and return 0F RETI ; enable int and return 00 RETSETXM ; set XM flag and return
See BRANCH. Branch instructions function as conditional returns when their destination offset is zero.
The SB flag is set when a non-zero nibble is shifted from postion 0 to 15 (RRN only).
81w RLN.W d 81x RRN.W d w x | d --------- 0 4 | A 1 5 | B 2 6 | C 3 7 | D Examples: 810 RLN.W A ; rotate A one nibble left 816 RRN.W C ; rotate C one nibble right
8085x SETB x,A 8089x SETB x,C 85x SETB x,ST Examples: 8085D SETB 13,A ; clear bit 13 of register A 80890 SETB 0,C ; clear bit 0 of register C 857 SETB 7,ST ; clear bit 7 of ST
Sets the CPU to do register arithmetic in HEX (binary) or DEC (binary coded decimal) mode.
05 SETDEC 04 SETHEX
Shift Left Bit is done with add.f reg,reg (add the reg to itself). The SB flag is set when a non-zero nibble/bit is shifted out of position 0 (SRN/SRB only). Zeros shifted in.
rrw SLN.f d rrx SRN.f d 819tw SRB.f d 81z SRB.W d rr t | f w x z | d ----------- ----------- B8 0 | P 0 4 C | A B9 1 | WP 1 5 D | B BA 2 | XS 2 6 E | C BB 3 | X 3 7 F | D BC 4 | S BD 5 | M BE 6 | B BF 7 | W F F | A Examples: F3 SLN.A D ; shift D left one nibble (20 bits) BE6 SRN.B C ; shift C right one nibble (8 bits) 81931 SRB.X B ; shift B right one bit (12 bits)
The SUBN instruction stores the negative of the subtraction in the destination.
qqy SUB.f s,d qqw SUBN.f s,d qq | f y w | s d -------- ----------- B0 | P 0 C | B A B1 | WP 1 D | C B B2 | XS 2 E | A C B3 | X 3 F | C D B4 | S 8 | A B B5 | M 9 | B C B6 | B A | C A B7 | W B | D C E | A Examples: E2 SUB.A A,C ; C = C - A (20 bits) EE SUBN.A A,C ; C = - (C - A) = A - C (20 bits) B70 SUB.W B,A ; A = A - B (64 bits)
"The 818... opcodes don't always work as advertised. To be specific, when the field of such an instruction is XS, S, P, or WP, and a carry (or borrow) is generated out of the most significant nibble, it wraps around and affects the least significant nibble." -- D.K.
818tyi SUB.f i+1,d t | f y | d ------- ------- 0 | P 8 | A 1 | WP 9 | B 2 | XS A | C 3 | X B | D 4 | S 5 | M 6 | B 7 | W F | A Examples: 818594 SUB.M 5,B ; B = B - 5 (48 bits) 8186BD SUB.B 14,D ; D = D - 14 (8 bits)
18x SUB.A x+1,D0 *** 1Cx SUB.A x+1,D1 *** Examples: 184 SUB 5,D0 ; D0 = D0 - 5 (20 bits) 1C9 SUB 10,D1 ; D1 = D1 - 10 (20 bits)
ppw SWAP.f s,d pp | f w | s d -------- --------- A8 | P C | B A A9 | WP D | C B AA | XS E | A C AB | X F | C D AC | S AD | M AE | B AF | W D | A Examples: DF SWAP.A C,D ; interchange values of C and D ABC SWAP.X A,B ; interchange low 3 nibbles of A and B
13x SWAP.A s,Da *** 13z SWAP.4 s,Da x z | s Da ------------ 2 A | A D0 3 B | A D1 6 E | C D0 7 F | C D1 Examples: 137 SWAP C,D1 ; interchange low 20 bits of C and D1 13A SWAP.4 A,D0 ; interchange low 16 bits of A and D0
12j SWAP.W A,Rn *** 12k SWAP.W C,Rn *** 81At2j SWAP.f A,Rn 81At2k SWAP.f C,Rn t | f j k | Rn ------- ---------- 0 | P 0 8 | R0 1 | WP 1 9 | R1 2 | XS 2 A | R2 3 | X 3 B | R3 4 | S 4 C | R4 5 | M 6 | B 7 | W F | A Examples: 121 SWAP A,R1 ; interchange A with R1 (64 bits) 12B SWAP C,R3 ; interchange C with R3 (64 bits) 81AF24 SWAP.A A,R4 ; interchange A with R4 (20 bits)
These operations have the effect of saving the PC of the next instruction and transferring control to the address contained in the register. This can be useful for implementing coroutines.
81B6 SWAP.A A,PC *** 81B7 SWAP.A C,PC ***
Swap 4 bit P register value with the high order nibble of the specified field of register C.
80Fx SWAP.1 P,C,x *** Examples: 80F0 SWAP P,C,0 ; interchange P with low nibble of C 80FF SWAP P,C,15 ; interchange P with high nibble of C
0B SWAP.X C,ST ***
Dataregisters: A B D C (64 bit) B points to the top of the oject heap D holds the size of the free area between the stack and the heap Addressregisters: D0 D1 (20 bit) D0 is the RPL instruction pointer D1 points to the top of the stack Pointer register 1st: P (4 bit) P is assumed always to be zero Temporary register 5st: R0 R1 R2 R3 R4 (64 bit) If you change any of these registers (B, D1, D, P, D0) in your machine code programs, restore their previous values before exiting.
+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | 15| 14| 13| 12| 11| 10| 9 | 8 | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+In the following diagrams, each nibble within a field is marked with its position, while those outside are blank. The vertical bar has been removed from between the nibbles of a field.
Field: .A Name: Address Field Start: nibble 0 Size: 5 nibbles Example: ADD.A 5,D1 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | | 4 3 2 1 0 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ Field: .B Name: Byte Field Start: nibble 0 Size: 2 nibbles Example: INC.B C +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | | | | | 1 0 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ Field: .M Name: Mantissa Field Start: nibble 3 Size: 12 nibbles Example: MOVE.M B,C +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | | 14 13 12 11 10 9 8 7 6 5 4 3 | | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ Field: .n Name: n Nibble Field Start: nibble 0 Size: n nibbles Example: MOVE.8 @D0,A +---+- - - -+---+---+---+- - - -+---+---+ | | | |n-1 n-2 1 0 | +---+- - - -+---+---+---+- - - -+---+---+ Field: .P Name: Pointer Field Start: nibble P Size: 1 nibble Example: RETZ.P B +---+- - - -+---+---+---+- - - -+---+---+ | | | | P | | | | | +---+- - - -+---+---+---+- - - -+---+---+ Field. .Pn Name: n from Pointer Field Start: nibble P Size: n nibbles Example: MOVE.P3 6,C +---+- - - -+---+---+- - - -+---+---+---+- - - -+---+ | | | |P+n-1 P+1 P | | | | +---+- - - -+---+---+- - - -+---+---+---+- - - -+---+ Field: .S Name: Sign Field Start: nibble 15 Size: 1 nibble Example: CLR.S B +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | 15| | | | | | | | | | | | | | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ Field: .W Name: Word Field Start: nibble 0 Size: 16 nibbles Example: SWAP.W A,R2 +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ Field: .WP Name: Word to Pointer Field Start: nibble 0 Size: P+1 nibbles Example: OR.WP C,D +---+- - - -+---+---+---+- - - -+---+---+ | | | | P P-1 1 0 | +---+- - - -+---+---+---+- - - -+---+---+ Field: .XS Name: Exponent Sign Field Start: nibble 2 Size: 1 nibble Example: NOT.XS C +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | | | | 2 | | | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ Field: .X Name: Exponent Field Start: nibble 0 Size: 3 nibbles Example: SUB.X A,C +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+ | | | | | | | | | | | | | | 2 1 0 | +---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+---+