Saturday, August 4, 2007

Undocumented 8085 Instructions

8085 undocumented instructions
These are the undocumented 8085 instructions, undocumented due to incompatibility with 8086, Use them at your discretion. (information here is not sure yet, still worth a post)

DSUB
Hex Code: 08H
Description: BC pair is subtracted from HL Pair affecting all flags.

JNK [16bit location] - Jump to Location if 'K' flag is reset
Hex code : DDH

JK [16bit location] - Jump to Location if 'K' flag is set
Hex Code: FDH

RRHL - Rotate Right HL Pair
Description: Rotates the HL pair 16 bit towards right.
Hex code : 10H
Operands : none
Flags unaffected


RLDE - Rotate Left DE Pair
Description: Rotates DE Pair to left.
Hex code: 18H
Operands : none
Carry affected : depends on Bit 15

ADI HL - Add Immidiate to HL pair
Description: Adds an 8 byte number to the HL pair.
Hex Code : 28H
Operands : 8 bit number
Flags: All affected

ADI SP - Add Immidiate to Stack Pointer
Description: Adds an 8 byte number to the SP
Hex Code : 38H
Operands : 8 bit number
Flags: All affected

RSTV
Description: Does a RST 8 instruction when the 'V' (must be overflow)flag is SET.
Hex Code: CBH

LHLX
Description: Loads HL Pair with the contents of address stored in the DE pair
Hex Code: EDH

SHLX
Description: Stores the HL Pair contents to the address specified in the DE pair.
Hex Code: D9H


Help me!
Whats this K flag ? Any Intel engineers out there ?

5 comments:

Anonymous said...

Thank you for posting these undocumented 8085 instructions. Your doc is the clearest I've found so far. I have a customer who wants these implemented in our assembler.

Dave Bardon, Avocet Systems, Rockland, Maine

Anonymous said...

This is what I found about undocumented bits in the F flag register:
bits: S Z X5 AC 0 P B CY
undocumented ones:
X5: X5=S1*S2+S1*R+S2*R
where S1 is sign of first operand,
S2 is sign of second operand and
R is sign of result.
V: complement two overflow

sorry,nothing about K flag

Anonymous said...

Hello,
as far as I can remember, the K bit wasn't mentioned back in 1982, but there was the bit X5 which was set when instructions dcx RegPair (e.g. inx h) or inx RegPair caused the value change from 0000H -> FFFFH and vice versa.
Usage:
lxi b,383 ; setup 384 iterations
loop:
blah blah
dcx b
jnx5 loop

Roland Mayer

Anonymous said...

Hello,

after reading the description more carefully I believe I found some errors in it. Unfortunately it's just from my memory, and I used the 8085 in the eighties of the last century.

JNK and JK had the names JNX5 and JX5
RRHL was ARHL and meant Arithmetic Right shift of HL
RLDE was RDEL (Rotate DE Left), description is OK
ADI HL was LDHI (Load De from Hl + Immediate) and performed HL + signed-8-bit-value -> DE
ADI SP was LDSI (Load De from Sp + Immediate) and performed SP + signed-8-bit-value -> DE
These two instructions work neatly with LHLX/SHLX pair when using local stack variables:

Example for increment of an 16 bit counter located on stack
ldsi -5 ; DE contains address SP - 5
lhlx ; load value from address SP - 5, SP - 4 into HL
inx h
shlx ; store incremented 16-bit value on stack

Example of accessing a byte through pointer on stack
ldsi -8 ; load address of on stack into DE
lhlx ; load pointer (through DE)
ldhi 5 ; address of HL + 5 in DE
ldax d ; fetch value at [HL + 5]
inc a
stax d ; store incremented value

I believe most instructions need 10 clocks (DSUB, RDEL and ARHL 6 clocks)

Hope could help you, enjoy these small instruction jewels.

Regards
Roland

Arun Prabhakar said...

Thanks a lot Roland :)