Hacker News new | past | comments | ask | show | jobs | submit login
Silicon reverse engineering: The 8085's undocumented flags (2013) (righto.com)
24 points by hggh 14 days ago | hide | past | favorite | 9 comments



I'm not sure why this old post showed up, but I'm here for your 8085 questions :-)


Ken, A possible typo in the first paragraph:

> question of why there were not documented

Possibly: s/there/these/ or s/there/they/ ?


Thanks! I've fixed the typo.


I think it's quite interesting how some of the undocumented instructions on the 8085 make DE more useful than HL for some types of pointer accesses in a way that kind of mirrors the way IX/IY was intended to be used on Z80.

The LDSI n [DE=SP+n] and LHLX [HL=(DE+1),(DE)] combination would be perfect for fetching HL from a parameter saved on the stack for instance. And using LDHI:LHLX would be perfect for doing similar for traversing pointers in data structures.

The fact they weren't documented really does look like Intel trying to sabotage the 8085 for the benefit of the 8086.


All we know is that supposedly, Intel didn't document these instructions because it would have made translation to 8086 code more difficult.

I don't entirely buy this explanation though. The overflow flag could have easily used the same bit on both, and the X5 flag behaviour could at least have been documented for INC/DEC, were it clearly "makes sense" from a high-level viewpoint, and would have been no trouble to implement the same way on the 8086.

And if 8080 compatibility was such an important goal, then why design the memory addressing on the 8086 so that it's impossible to translate LDAX/STAX and XTHL into single instructions?

If the 8086 ModR/M worked similar to how it did later in 32-bit mode (only without SIB), all of these 8080 and 8085 instructions would have had an equivalent:

    LDAX -> MOV AL,[CX] (etc.)
    XTHL -> XCHG BX,[SP]
    LDSI -> LEA DX,[SP+n]
    LHLX -> MOV BX,[DX]
Dropping conditional call/return was probably the right decision (even though they could be very useful on occasion!), but the absence of conditional jumps with full 16-bit offset was IMO a mistake. If you don't believe that, maybe try writing a compiler (generating 8086 machine code directly) that doesn't emit the most stupid 5 byte code for every forward jump. It's possible of course, but not easy. Opcodes 60h-6fh were right there!


According to a comment on the article the lack of support for these registers meant the 8085 did not have a "jump if greater than" opcode. That seems like something of an inconvenience for a chip that a lot of people are going to be writing assembler on.


Comparisons between unsigned bytes can be done natively with JC, JNC and JZ, JNZ instructions. Things are more complicated with signed comparisons as there is no overflow flag. It is possible but requires more instructions.


Interestingly, while the 8086 and '186 had all the different jump instructions for signed and unsigned comparison, its microcode was limited to an 8080-like set of carry/zero flag tests. This made the BOUND instruction quite complicated and inefficient.


Ahh, nostalgia! The very first microcomputer I designed and built used the 8085A. I spent a lot of fun times exploring it for undocumented instructions.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: