Mail Archives: djgpp-workers/2009/11/11/19:23:33
Hi again,
On Wed, Nov 11, 2009 at 5:59 PM, Rugxulo <rugxulo AT gmail DOT com> wrote:
>
> Okay, here's a small context diff against DJASM with Martin's
> suggestions (and it works, too):
Hmmm, maybe I should've diff'd against the latest DJASM.Y from CVS
instead. Hope this isn't too annoying. :-/
*** djasm.y Fri Aug 29 08:33:00 2008
--- martin.y Wed Nov 11 17:51:16 2009
***************
*** 15,25 ****
#include <time.h>
#include <ctype.h>
#include <unistd.h>
#ifndef O_BINARY
#define O_BINARY 0
#endif
#undef _POSIX_SOURCE
! #include "../../include/coff.h"
#define SMALL_EXE_HEADER 0
#if SMALL_EXE_HEADER
--- 15,26 ----
#include <time.h>
#include <ctype.h>
#include <unistd.h>
+ #include <limits.h> /* INT_MAX */
#ifndef O_BINARY
#define O_BINARY 0
#endif
#undef _POSIX_SOURCE
! #include <coff.h>
#define SMALL_EXE_HEADER 0
#if SMALL_EXE_HEADER
***************
*** 285,290 ****
--- 286,292 ----
{"insb", ONEBYTE, 0x6c},
{"insw", ONEBYTE, 0x6d},
{"insd", TWOBYTE, 0x666d},
+ {"int3", ONEBYTE, 0xcc},
{"into", ONEBYTE, 0xce},
{"iret", ONEBYTE, 0xcf},
{"iretd", TWOBYTE, 0x66cf},
***************
*** 315,320 ****
--- 317,323 ----
{"repne", ONEBYTE, 0xf2},
{"repnz", ONEBYTE, 0xf2},
{"sahf", ONEBYTE, 0x9e},
+ {"salc", ONEBYTE, 0xd6},
{"scasb", ONEBYTE, 0xae},
{"scasw", ONEBYTE, 0xaf},
{"scasd", TWOBYTE, 0x66af},
***************
*** 2334,2339 ****
--- 2337,2350 ----
int c, c2, i, oldc;
struct opcode *opp, op;
+
+ #define STRMAX 32
+ #define CHARS "0-9a-fA-FhHxX"
+ char str [STRMAX+1+1], /* 1 for NUL, 1 for 'h' -> "0x" transformation */
+ str2[STRMAX+1+1];
+ char format[1 + sizeof(INT_MAX) + 1 + sizeof(CHARS) + 1 + 1];
+
+
do {
c = fgetc(infile);
} while (c == ' ' || c == '\t');
***************
*** 2451,2458 ****
}
}
#else
ungetc(c, infile);
! fscanf(infile, "%i", &(yylval.i));
#endif
sprintf(last_token, "%d", yylval.i);
return NUMBER;
--- 2462,2485 ----
}
}
#else
+
ungetc(c, infile);
! /* fscanf(infile, "%i", &(yylval.i)); */
!
!
! sprintf(format, "%%%d[%s]", STRMAX, CHARS);
! fscanf(infile, format, str);
! strcpy(str2,str);
!
! if (str[strlen(str)-1] == 'h' || str[strlen(str)-1] == 'H')
! {
! sprintf(str2, "0x%s", str);
! str2[strlen(str2)-1]='\0';
! }
!
! sscanf(str2, "%i", &(yylval.i));
!
!
#endif
sprintf(last_token, "%d", yylval.i);
return NUMBER;
- Raw text -