You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the bug
8085 CPU comes with a few undocumented instructions that where found a few years after its introduction. You can find a full list of these unofficial opcodes e.g. in asXXXX assembler documentation.
One of the undocumented instructions that I encountered is ldsi. Ghidra decompiler does not know this instruction and stops binary -> assembly decompilation after encountering it. This is somehow annoying when you try to reverse engineer old code (think retro-computing).
To Reproduce
Try to decompile this file (Intel HEX format):
It was compiled from two assembly files (file responsible for starting C environment, stripped down to only necesary parts) in as8085 format:
; Run time start off for Small C.; cseg .module CSTART .area CSTART (REL,CON) ;program area CRTSO is RELOCATABLE .list (err, loc, bin, eqt, cyc, lin, src, lst, md) .nlist (pag) .globl cstartend .globl cceq, ccgchar, cccmp lxi h,#0x3ffe ; Initialize stack on even address. ; Stack grows downwards. sphlcall main ; call main programstop:hlt ; stop processorjmp stop; fetch char from (HL) and sign extend into HLccgchar: mov a,mccsxt: mov l,a rlcsbb amov h,aret; DE == HLcceq: call cccmp rz dcx hret; signed compare of DE and HL; carry is sign of difference [set => DE < HL]; zero is zero/non-zerocccmp: mov a,esub lmov e,amov a,dsbb h lxi h,1 ;preset true jm cccmp1 ora e ;resets carryretcccmp1: ora estcret;cstartend: .end
and the example main.asm:
; Small C 8080; Coder (2.4,84/11/27); Front End (2.7,84/11/28); Front End for ASXXXX (2.8,13/01/20) ;program area SMALLC_GENERATED is RELOCATABLE .module SMALLC_GENERATED .list (err, loc, bin, eqt, cyc, lin, src, lst, md) .nlist (pag) .area SMALLC_GENERATED (REL,CON,CSEG);#define TRUE (1);#define FALSE (0);main() {main:; char *outport1, *outport2, *inport;push bpush bpush b; char in; dcx sp; outport1 = 0x8000; ldsi #5push d lxi h,#32768pop d shlx; outport2 = 0xA000; ldsi #3push d lxi h,#40960pop d shlx; inport = 0xC000; ldsi #1push d lxi h,#49152pop d shlx; *outport1 = 0; ldsi #5 lhlxpush h lxi h,#0pop dmov a,l stax d; *outport2 = 0; ldsi #3 lhlxpush h lxi h,#0pop dmov a,l stax d; while (TRUE) {$2: lxi h,#1mov a,h ora ljz$3; *inport = 0xF; ldsi #1 lhlxpush h lxi h,#15pop dmov a,l stax d; *outport1 = 0xF; ldsi #5 lhlxpush h lxi h,#15pop dmov a,l stax d; *outport2 = 0xF; ldsi #3 lhlxpush h lxi h,#15pop dmov a,l stax d; }jmp$2$3:; return;jmp$1;}$1:xchg lxi h,#7 dad sp sphlxchgret .area SMALLC_GENERATED_DATA (REL,CON,DSEG) .globl main;0 error(s) in compilation; literal pool:0; global pool:1; Macro pool:70 ; .end
The second listing was generated from C using (not fully working right now) SmallC compiler:
#defineTRUE (1)
#defineFALSE (0)
main() {
char*outport1, *outport2, *inport;
charin;
outport1=0x8000;
outport2=0xA000;
inport=0xC000;
*outport1=0;
*outport2=0;
while (TRUE) {
*inport=0xF; // its like this for dbg purposes*outport1=0xF;
*outport2=0xF;
}
return;
}
Expected behavior
Unofficial 8085 opcodes should be decompiled. Possibly a new language flavour should be introduced like 8085+unofficial.
Environment (please complete the following information):
macOS 10.15.6
Java Version: 14.0.1
Ghidra Version: 9.1.2
The text was updated successfully, but these errors were encountered:
Describe the bug
8085 CPU comes with a few undocumented instructions that where found a few years after its introduction. You can find a full list of these unofficial opcodes e.g. in asXXXX assembler documentation.
One of the undocumented instructions that I encountered is
ldsi
. Ghidra decompiler does not know this instruction and stops binary -> assembly decompilation after encountering it. This is somehow annoying when you try to reverse engineer old code (think retro-computing).To Reproduce
Try to decompile this file (Intel HEX format):
It was compiled from two assembly files (file responsible for starting C environment, stripped down to only necesary parts) in as8085 format:
and the example
main.asm
:The second listing was generated from C using (not fully working right now) SmallC compiler:
Expected behavior
Unofficial 8085 opcodes should be decompiled. Possibly a new language flavour should be introduced like 8085+unofficial.
Environment (please complete the following information):
The text was updated successfully, but these errors were encountered: