root@kunivv1.sci.kun.nl (Privileged Account) (01/10/90)
This is a patch for the Z80/Z280 disassembler package. The package was originally posted as > Newsgroups: comp.os.cpm > Subject: Z80/Z280 disassembler in C > Summary: Here it is > Keywords: Z80 Z280 disassembler C > Message-ID: <598@kunivv1.sci.kun.nl> > Date: 27 Dec 89 12:36:54 GMT This patch corrects the following: * It fixes a portability bug (NULL was mistakenly used as 0) * It corrects a Z280 disassembler bug ([DD|FD] ED 06/16/26/36 was interchanged with [DD|FD] ED 0E/1E/2E/3E) * It changes outhex.c to always output leading zero's on byte and word values that sometimes need it. This takes care of annoying things like LD HL,(9F00H) LD DE,(0A001H) * It includes some cosmetic changes that caused problems with ancient compilers that accept the =op form (it was already marked obsolete by K&R 1. sigh). Thanks to Dru Nelson <dnelson@mthvax.cs.miami.edu> for pointing this out to me. -- Luc Rooijakkers Internet: lwj@cs.kun.nl Faculty of Mathematics and Computer Science UUCP: uunet!cs.kun.nl!lwj University of Nijmegen, the Netherlands tel. +3180612271 *** old/Makefile Wed Jan 10 12:27:19 1990 --- Makefile Wed Jan 10 13:18:52 1990 *************** *** 15,16 **** --- 15,21 ---- + # Change this if your compiler doesn't have void + + VOID= + #VOID=-Dvoid=int + # You might change this if you have gcc *** old/README Wed Jan 10 12:27:20 1990 --- README Wed Jan 10 13:17:44 1990 *************** *** 40,41 **** --- 40,48 ---- + - In disas.c, the file to be disassembled is opened with mode "rb", + meaning binary mode. On some systems, this may be different from the + default text mode. + + - If you don't have a compiler that accepts void, enable the VOID macro + in the Makefile. + Byte order is not (should not) be a problem, since I've tried to insure *** old/dis.c Wed Jan 10 12:27:24 1990 --- dis.c Wed Jan 10 13:11:31 1990 *************** *** 29,39 **** * ! * ../../88 Created as symbolic Z280 disassembler ! * ../../88 Extended to non-symbolic Z280 disassembler ! * ../../88 Added #if's for Z80 disassembler ! * 07/07/88 First final version ! * 12/08/89 Split off output routines ! * 01/10/89 Split OUT_IO into OUT_INP,OUT_OUTP ! * 23/12/89 Split off more output routines ! * 24/12/89 Cleaned up for public release ! * 27/12/89 Use strchr() instead of strstr() * --- 29,42 ---- * ! * ../../88 Created as symbolic Z280 disassembler. lwj ! * ../../88 Extended to non-symbolic Z280 disassembler. lwj ! * ../../88 Added #if's for Z80 disassembler. lwj ! * 07/07/88 First final version. lwj ! * 12/08/89 Split off output routines. lwj ! * 01/10/89 Split OUT_IO into OUT_INP,OUT_OUTP. lwj ! * 23/12/89 Split off more output routines. lwj ! * 24/12/89 Cleaned up for public release. lwj ! * 27/12/89 Use strchr() instead of strstr(). lwj ! * 02/01/90 Replaced several NULL's by AM_NULL's. lwj ! * 08/01/90 Fixed LDW (HL),rp / LWD rp,(HL) swapped bug. lwj ! * 10/01/90 Portability mods. lwj * *************** *** 42,46 **** #ifdef Z280 ! char DisId[] = "@(#) DIS (Z280) 27/12/89"; #else ! char DisId[] = "@(#) DIS (Z80) 27/12/89"; #endif --- 45,49 ---- #ifdef Z280 ! char DisId[] = "@(#) DIS (Z280) 10/01/90"; #else ! char DisId[] = "@(#) DIS (Z80) 10/01/90"; #endif *************** *** 110,112 **** for(bp=buf;s<sp;) ! *bp++=*s++; --- 113,115 ---- for(bp=buf;s<sp;) ! *bp++ = *s++; *************** *** 245,247 **** if(disp>=0x80) ! disp+=-0x100; /* cryptic but portable */ --- 248,250 ---- if(disp>=0x80) ! disp += -0x100; /* cryptic but portable */ *************** *** 578,580 **** #else ! if(am_code==NULL) { #endif --- 581,583 ---- #else ! if(am_code==AM_NULL) { #endif *************** *** 654,656 **** #ifdef Z80 ! if(am_code==NULL) { #endif --- 657,659 ---- #ifdef Z80 ! if(am_code==AM_NULL) { #endif *************** *** 816,820 **** outop("LD"W); - outrp((op>>4)&0x03); - outs(","); outim(); } else { --- 819,823 ---- outop("LD"W); outim(); + outs(","); + outrp((op>>4)&0x03); } else { *************** *** 821,825 **** outop("LD"W); - outim(); - outs(","); outrp((op>>4)&0x03); } --- 824,828 ---- outop("LD"W); outrp((op>>4)&0x03); + outs(","); + outim(); } *************** *** 1119,1121 **** case 0x9F: ! if (am_code==NULL) { outop( (op==0x97) ? "EPUF" : "EPUI" ); --- 1122,1124 ---- case 0x9F: ! if (am_code==AM_NULL) { outop( (op==0x97) ? "EPUF" : "EPUI" ); *************** *** 1128,1130 **** case 0xAF: ! if (am_code==NULL) { outop( (op==0xA7) ? "EPUM" : "MEPU" ); --- 1131,1133 ---- case 0xAF: ! if (am_code==AM_NULL) { outop( (op==0xA7) ? "EPUM" : "MEPU" ); *************** *** 1139,1141 **** case 0xB7: ! if (am_code==NULL) { outop("INW"); --- 1142,1144 ---- case 0xB7: ! if (am_code==AM_NULL) { outop("INW"); *************** *** 1147,1149 **** case 0xBF: ! if (am_code==NULL) { outop("OUTW"); --- 1150,1152 ---- case 0xBF: ! if (am_code==AM_NULL) { outop("OUTW"); *** old/disas.c Wed Jan 10 12:27:26 1990 --- disas.c Wed Jan 10 13:15:49 1990 *************** *** 21,25 **** * ! * ../../88 Created ! * 16/12/89 Fixed JR/JP address bug ! * 26/12/89 Cut down for public release * --- 21,26 ---- * ! * ../../88 Created. lwj ! * 16/12/89 Fixed JR/JP address bug. lwj ! * 26/12/89 Cut down for public release. lwj ! * 10/01/90 Portability mods. lwj * *************** *** 27,29 **** ! char DisasId[] = "@(#) DISAS 26/12/89"; --- 28,30 ---- ! char DisasId[] = "@(#) DISAS 10/01/90"; *************** *** 108,109 **** --- 109,112 ---- + /* open file in binary mode ("rb") */ + if((file=fopen(name,"rb"))==NULL) { *************** *** 237,239 **** col++; ! *linep++=*s++; } --- 240,242 ---- col++; ! *linep++ = *s++; } *************** *** 252,254 **** while(((col+8)&~7)<=pos) { ! *linep++='\t'; col=(col+8)&~7; --- 255,257 ---- while(((col+8)&~7)<=pos) { ! *linep++ = '\t'; col=(col+8)&~7; *************** *** 257,259 **** while(col<pos) { ! *linep++=' '; col++; --- 260,262 ---- while(col<pos) { ! *linep++ = ' '; col++; *** old/oplist.c Wed Jan 10 12:27:27 1990 --- oplist.c Wed Jan 10 13:11:53 1990 *************** *** 20,23 **** * ! * 23/12/89 Split off from dis.c ! * 26/12/89 Added debugging option * --- 20,24 ---- * ! * 23/12/89 Split off from dis.c. lwj ! * 26/12/89 Added debugging option. lwj ! * 10/01/90 Portability mods. lwj * *************** *** 25,27 **** ! char OpListId[] = "@(#) OPLIST 26/12/89"; --- 26,28 ---- ! char OpListId[] = "@(#) OPLIST 10/01/90"; *************** *** 163,165 **** while(*s) ! *outbufp++=*s++; } --- 164,166 ---- while(*s) ! *outbufp++ = *s++; } *** old/optab.c Wed Jan 10 12:27:28 1990 --- optab.c Wed Jan 10 13:12:04 1990 *************** *** 20,23 **** * ! * 23/12/89 Split off from dis.c ! * 26/12/89 Added debugging option * --- 20,24 ---- * ! * 23/12/89 Split off from dis.c. lwj ! * 26/12/89 Added debugging option. lwj ! * 10/01/90 Portability mods. lwj * *************** *** 25,27 **** ! char OpTabId[] = "@(#) OPTAB 26/12/89"; --- 26,28 ---- ! char OpTabId[] = "@(#) OPTAB 10/01/90"; *************** *** 223,225 **** for(;*s!='\0';s++) ! *outbufp++= (*s=='\t') ? ' ' : *s; } --- 224,226 ---- for(;*s!='\0';s++) ! *outbufp++ = (*s=='\t') ? ' ' : *s; } *** old/outdebug.c Wed Jan 10 12:27:29 1990 --- outdebug.c Wed Jan 10 13:11:05 1990 *************** *** 16,18 **** * ! * 23/12/89 Split off from dis.c * --- 16,18 ---- * ! * 23/12/89 Split off from dis.c. lwj * *** old/outhex.c Wed Jan 10 12:27:30 1990 --- outhex.c Wed Jan 10 13:10:26 1990 *************** *** 10,12 **** #include <stdio.h> - #include <ctype.h> --- 10,11 ---- *************** *** 17,21 **** * ! * 12/08/89 Split off from dis.c ! * 01/10/89 Split OUT_IO into OUT_INP, OUT_OUTP ! * 23/12/89 Cleaned up for public release * --- 16,22 ---- * ! * 12/08/89 Split off from dis.c. lwj ! * 01/10/89 Split OUT_IO into OUT_INP, OUT_OUTP. lwj ! * 23/12/89 Cleaned up for public release. lwj ! * 08/01/90 Always include leading zero when possibly needed. lwj ! * 10/01/90 Portability mods. lwj * *************** *** 23,25 **** ! char OutHexId[] = "@(#) OUTHEX 23/12/89"; --- 24,26 ---- ! char OutHexId[] = "@(#) OUTHEX 10/01/90"; *************** *** 43,45 **** case OUT_EPU: ! sprintf(buf,"%02XH",value); break; --- 44,46 ---- case OUT_EPU: ! sprintf(buf,"%03XH",value); break; *************** *** 49,51 **** case OUT_CALL: ! sprintf(buf,"%04XH",value); break; --- 50,52 ---- case OUT_CALL: ! sprintf(buf,"%05XH",value); break; *************** *** 74,76 **** case OUT_JR: ! sprintf(buf,"%04XH",addr+value); break; --- 75,77 ---- case OUT_JR: ! sprintf(buf,"%05XH",addr+value); break; *************** *** 88,92 **** } - - if(isalpha(buf[0])) - outs("0"); --- 89,90 ---- *** old/outsym.c Wed Jan 10 12:27:31 1990 --- outsym.c Wed Jan 10 13:10:45 1990 *************** *** 16,18 **** * ! * 23/12/89 Split off from dis.c * --- 16,18 ---- * ! * 23/12/89 Split off from dis.c. lwj * -- Luc Rooijakkers Internet: lwj@cs.kun.nl Faculty of Mathematics and Computer Science UUCP: uunet!cs.kun.nl!lwj University of Nijmegen, the Netherlands tel. +3180612271