Mail Archives: djgpp-workers/2009/11/11/17:02:17
Hey guys, is this a better place to discuss this (DJASM hacks/
improvements)?
---------- Forwarded message ----------
From: Martin Str|mberg <a DOT DOT DOT AT sister DOT ludd DOT ltu DOT se>
Date: Nov 11, 2:42=A0am
Subject: GAS ".code16" and DJASM quirks ...
To: comp.os.msdos.djgpp
Rugxulo <rugx DOT DOT DOT AT gmail DOT com> wrote:
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
> *** tony_y.bk1 =A0 =A0 Tue Nov 10 17:37:22 2009
> --- tony.y Tue Nov 10 21:26:58 2009
> ***************
> *** 2335,2340 ****
> --- 2335,2341 ----
> =A0 {
> =A0 =A0 int c, c2, i, oldc;
> =A0 =A0 struct opcode *opp, op;
> + =A0 char str[33], str2[33];
No.
#define MAX 32
#define CHARS "0-9a-fA-FhHxX"
char str[MAX+1+1], ... /* One for nul and one for "h"->"0x"
transformation. */
char format[1+ sizeof("2147483647") /* INT_MAX */ +1+ sizeof(CHARS)
+1+1];
sprintf(format "%%%d[%s]", MAX, CHARS); /* Possibly error handling
here too. */
> ! =A0 =A0 =A0 fscanf(infile, "%[0-9a-fA-FhHxX]",str);
fscanf(infile, format, str);
> !
> ! =A0 =A0 =A0 if (str[strlen(str)-1] =3D=3D 'h' || str[strlen(str)-1] =3D=
=3D 'H')
> ! =A0 =A0 =A0 {
> ! =A0 =A0 =A0 =A0 str[strlen(str)-1]=3D'\0';
> ! =A0 =A0 =A0 =A0 strcpy(str2,"0x");
> ! =A0 =A0 =A0 =A0 strcat(str2,str);
Why not sprintf(str2, "0x%s", str)? /* Again some proper size! */
> ! =A0 =A0 =A0 =A0 strcpy(str,str2);
> ! =A0 =A0 =A0 }
> ! =A0 =A0 =A0 sscanf(str, "%i", &(yylval.i));
> !
> !
> =A0 =A0 =A0 #endif
> =A0 =A0 =A0 =A0 sprintf(last_token, "%d", yylval.i);
> =A0 =A0 =A0 =A0 return NUMBER;
> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
Thanks!
MartinS
- Raw text -