Friday, 14 October 2011

Undocumented 8085 Flags and Instructions

FLAG REGISTER of 8085

Bit undocumented 8085 Remark
7 (MSB) S Mark flag,sign flag
6 Z Zero flag
5 X5,k Originally unused, concerning X5 or k it mentions later
4 AC Auxiliary(Assistant) carry or half carry and for BCD operation revision
3 0 Unused
2 P Parity flag, as for just Z80 CPU overflow flag combined use
1 V Overflow flag or subtraction flag
0 (LSB) C Carry
X5 - In case of the usual 8 bit addition and subtraction where S1 is the sign of 1st operand, S2 is the sign of 2nd operand and R is the sign of the operational result, then the change of X5 can be written with the formula,
  X5 = S1 & S2 | S1 & R | S2 & R.

Undocumented 8085 Instructions

These are the undocumented 8085 instructions, undocumented due to incompatibility with 8086.

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

JNK [16bit location]
Hex code : DDH
Description: - Jump to Location if ‘K’ flag or ‘X5’ flag is reset.
Clock: 7/10

JK [16bit location]
Hex Code: FDH
Description: - Jump to Location if ‘K’ flag or ‘X5’ flag is set.
Clock: 7/10



RRHL, ARHL
Description: Rotates the HL pair 16 bit towards right.  Flags remains unchanged. ARHL order is arithmetic right shift of HL register pair. MSB of the H register which means the mark does not change. The least significant bit of L register enters into the CY flag. Just the CY flag changes.
Hex code : 10H
Clock: 7



RLDE
Description: Rotates DE Pair to left. Bit 15 is transferred to carry. No other flags is affected.
Hex code: 18H
Clock: 10


ADI HL
Description:Adds an Immediate 8 byte number to the HL pair and load the result into DE pair.
Hex Code :28H
Operands : 8 bit number
Flags: All affected
Clock: 10

ADI SP

Description: Adds an 8 byte number to the SP and load the result into DE pair.
Hex Code : 38H
Operands : 8 bit number
Flags: All affected

Clock: 10

RSTV

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


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

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

N.B. - Although some of these opcode are very useful (such as a 16 bit subtract), It was warned by Intel tech support to not use them because their operation, and in fact their very presence in any particular chip, cannot be guaranteed. So, if you are a home hobbyist who wants to use undocumented opcodes to your advantage, that's perfectly fine and dandy, but if you are a professional programmer who's software is used in manufactured products, then you definitely should not use undocumented opcodes, no matter how useful or convenient they may be!

4 comments:

  1. Actually, all of these instructions were 100% tested when they were manufactured at Intel. The test program used to test these devices contained all of these instructions and was written to do an extensive test on ALL instructions in many combinations and order. So, unless the 8085 broke after it was shipped, these instructions were tested and were working.
    I know this because I was the Test Engineer at Intel that developed the 8085 Production Test Program. I wrote all the code for this test and it ran on a Megatest @8000 test system.

    Cort Allen

    ReplyDelete
    Replies
    1. I still have the original documentation for these commands given to me from Engineering. If there is any interest in these you can reach me at:

      manofquest@aol.com

      Cort Allen

      Delete
  2. Thanks and that i have a neat offer: How Much Home Renovation Cost house renovation business

    ReplyDelete