019
07.07.2007, 20:47 Uhr
timetube
|
Zitat: | proof80 postete Hallo Rolf,
Wie sieht HD64180-Code aus im Unterschied zu Z80 bzw. 8080? An welchen Dialekt ist das angelehnt? Hat's da LD rr,rr oder so'n MVI-Zeug?
Gruß, Wolfram |
8080 to Z80 ist recht einfach zu machen. Guggste http://www.nadhh.hanse.de/tmp/Z80Translater.zip ein kleines lex-script das es schon ganz gut kann und das schon im letztem Jahrtausend
tt.
%{ /************************************************************ 8080 to Z80 Mnemonic Converter (c) 89 by J.Sivers cplhh.Hanse.de (c) 07 by J.Sievers nadhh.Hanse.de Use: Z80Translater 8080InputFile > Z80 Output File
Finally, main is defined in the programs section since the one in the library calls yyparse instead. ************************************************************/ #include <errno.h> #include <string.h> int wc = 0; /* word count */ %}
%start WORD // the word start state
%%
// Scip comment ;[^\n]*\n { printf("%s",yytext); } \.[A-Za-z][^ \t]+ { printf("%s",yytext);} DW|DB|DS| EQU|ORG { printf(".%s",yytext);} // Put a dot in front of these statemends. ,M { printf(",(HL)");} M, { printf("(HL),");} [ \t]+M[ \t]+ { printf(" A,(HL) ");} LDAX[ \t]+[BD] { printf("LD A,(%c%c)",yytext[yyleng-1], *(char*)(strchr("BCDE",yytext[yyleng-1])+1));} STAX[ \t]+[BD] { printf("LD (%c%c),A",yytext[yyleng-1], *(char*)(strchr("BCDE",yytext[yyleng-1])+1));} LDA[ \t]+[^ \t]+ { printf("LD A,(%s)",yytext+4);} STA[ \t]+[^ \t]+ { printf("LD (%s),A",yytext+4);}
INX[ \t]+[BDHS]P? { if(yytext[yyleng-1]=='P') yyleng--; printf("INC %c%c",yytext[yyleng-1], *(char*)(strchr("BCDEHLSP",yytext[yyleng-1])+1));} DCX[ \t]+[BDHS]P? { if(yytext[yyleng-1]=='P') yyleng--; printf("DEC %c%c",yytext[yyleng-1], *(char*)(strchr("BCDEHLSP",yytext[yyleng-1])+1));}
DAD[ \t]+[BDH] { printf("ADD HL,%c%c",yytext[yyleng-1], *(char*)(strchr("BCDEHL",yytext[yyleng-1])+1));} DAD { printf("LD HL,");} LXI[ \t]+[BDH] { printf("LD %c%c",yytext[yyleng-1], *(char*)(strchr("BCDEHL",yytext[yyleng-1])+1));} LXI { printf("LD");} LHLD[ \t]+[^ \t]+ { printf("LD HL,(%s)",yytext+5);} SHLD[ \t]+[^ \t]+ { printf("LD (%s),HL",yytext+5);} IN[ \t]+[^ \t]+ { printf("IN A,(%s)",yytext+3);} OUT[ \t]+[^ \t]+ { printf("OUT (%s),A",yytext+4);} MOV { printf("LD");} MVI { printf("LD");} JMP { printf("JP");} XCHG { printf("EX DE,HL");} XTHL { printf("EX (SP),HL");} SPHL { printf("LD SP,HL");} SUI { printf("SUB A,");} SBB { printf("SBC");} SBI { printf("SBC A,");} ACI { printf("ADC A,");} INR { printf("INC");} DCR { printf("DEC");} CMA { printf("CPL");} STC { printf("SCF");} CMC { printf("CCF");} RLC { printf("RLCA");} RRC { printf("RRCA");} RAL { printf("RLA");} RAR { printf("RRA");} ANA { printf("AND");} ANI { printf("AND");} XRA { printf("XOR");} XRI { printf("XOR");} ORA { printf("OR");} ORI { printf("OR");} CMP { printf("CP");} CMI { printf("CP");} JNZ { printf("JP nz,");} JZ { printf("JP z,");} JNC { printf("JP nc,");} JC { printf("JP c,");} JPO { printf("JP po,");} JPE { printf("JP pe,");} JP { printf("JP p,");} JM { printf("JP m,");} PCHL { printf("JP (HL)");} CNZ { printf("CALL nz,");} CZ { printf("CALL z,");} CNC { printf("CALL nc,");} CC { printf("CALL c,");} CPO { printf("CALL po,");} CPE { printf("CALL pe,");} CP { printf("CALL p,");} CM { printf("CALL m,");} RNZ { printf("RET nz,");} RZ { printf("RET z,");} RNC { printf("RET nc,");} RC { printf("RET c,");} RPO { printf("RET po,");} RPE { printf("RET pe,");} RP { printf("RET p,");} RM { printf("RET m,");} ADD { printf("ADD A,");} ADC { printf("ADC A,");} PSW { printf("AF");}
[ \t]+M[ \t]+ { printf(" (HL) ");} ^[A-Za-z][^ \t]+ { printf("%s",yytext);} .|\n { putchar(*yytext); }
%% int main(int argc, char** argv) { int res; yyin = fopen(argv[1], "r"); if (yyin != NULL) res= yylex(); else { res = errno; perror("Input"); } // getchar(); return res; }
int yywrap(void) { printf("word count: %d\n", wc); return 1; } -- "Phantasie ist wichtiger als Wissen, denn Wissen ist begrenzt." Ein Stein. |