Now at version 1.11.9.
SYM * bf0esym; // External symbol involved in expr
// Function prototypes
-int check030bf(void);
+int Check030Bitfield(void);
//
// it's a bitfield instruction--check the parameters inside the {} block
// for validity
if (*tok == '{')
- if (check030bf() == ERROR)
+ if (Check030Bitfield() == ERROR)
return ERROR;
if ((acount == 0) || (*tok != ','))
// It's a bitfield instruction--check the parameters inside the {} block
// for validity
if (*tok == '{')
- if (check030bf() == ERROR)
+ if (Check030Bitfield() == ERROR)
return ERROR;
// At this point, it is legal for 020+ to have a ':'. For example divu.l
tok++; //eat the colon
if ((*tok >= KW_D0) && (*tok <= KW_D7))
- {
a2reg = (*tok++) & 7;
- }
else if ((*tok >= KW_FP0) && (*tok <= KW_FP7))
- {
a2reg = (*tok++) & 7;
- }
else
return error("a data or FPU register must follow a :");
}
// Error messages:
badmode:
return error("addressing mode syntax");
-
- //unmode:
- //return error("unimplemented addressing mode");
}
// bfxxx <ea>{param1,param2}
// param1/2 are either data registers or immediate values
//
-int check030bf(void)
+int Check030Bitfield(void)
{
PTR tp;
CHECK00;
//D_word((inst | am0 | a0reg | am1 | a1reg));
if (inst == B16(11101111, 11000000))
+ {
// bfins special case
D_word((inst | am1 | a1reg));
+ }
else
+ {
D_word((inst | am0 | a0reg));
+ }
ea0gen(siz); // Generate EA
if (flg & 16)
{
- // OR-in register number
+ // OR-in register number
if (flg & 8)
inst |= reg_9[a1reg]; // ea1reg in bits 9..11
else
D_word(inst);
- // Generate ea0 if requested
+ // Generate ea0 if requested
if (flg & 2)
ea0gen(siz);
if (activefpu == FPU_68040)
warn("Instruction is emulated in 68040");
-
+
return gen_fpu(inst, siz, B8(00000011), FPU_NOWARN);
}
{
if (activefpu & (FPU_68040 | FPU_68060))
return gen_fpu(inst, siz, B8(01100011), FPU_NOWARN);
-
+
return error("Unsupported in current FPU");
}
a1reg = a0reg;
return gen_fpu(inst, siz, B8(00011010), FPU_NOWARN);
}
-
+
return gen_fpu(inst, siz, B8(00011010), FPU_NOWARN);
}
a1reg = a0reg;
return gen_fpu(inst, siz, B8(01011010), FPU_NOWARN);
}
-
+
return gen_fpu(inst, siz, B8(01011010), FPU_NOWARN);
}
{
if (activefpu & (FPU_68040 | FPU_68060))
return gen_fpu(inst, siz, B8(01000001), FPU_NOWARN);
-
+
return error("Unsupported in current FPU");
}
CHECKNO60;
D_word(B16(00000001, 11000000));
- if (a0exattr&DEFINED)
+ if (a0exattr & DEFINED)
+ {
D_word(a0exval);
+ }
else
{
AddFixup(FU_WORD, sloc, a0expr);
}
}
-
//
// Construct and deposit flag word
//
}
else if (obj_format == ALCYON)
{
- uint32_t symbolmaxsize = 0;
-
if (verb_flag)
{
if (prg_flag)
- {
printf("TOS header : 28 bytes\n");
- printf("Total : %d bytes\n", 28 + sect[TEXT].sloc + sect[DATA].sloc + sect[BSS].sloc);
- }
- else
- {
- printf("Total : %d bytes\n", sect[TEXT].sloc + sect[DATA].sloc + sect[BSS].sloc);
- }
+
+ printf("Total : %d bytes\n", sect[TEXT].sloc + sect[DATA].sloc + sect[BSS].sloc + (prg_flag ? 28 : 0));
}
- if (prg_flag != 1)
- symbolmaxsize = sy_assign(NULL, NULL) * 28; // Assign index numbers to the symbols
+ // Assign index numbers to the symbols, get # of symbols (we assume
+ // that all symbols can potentially be extended, hence the x28)
+ uint32_t symbolMaxSize = sy_assign(NULL, NULL) * 28;
// Alloc memory for header + text + data, symbol and relocation
// information construction.
- t = tds = sect[TEXT].sloc + sect[DATA].sloc;
-
- if (t < symbolmaxsize)
- t = symbolmaxsize;
-
- // Is there any reason to do this this way???
- buf = malloc(t + HDRSIZE);
- buf += HDRSIZE;
+ tds = sect[TEXT].sloc + sect[DATA].sloc;
+ buf = malloc(HDRSIZE + tds + symbolMaxSize);
// Build object file header just before the text+data image
- chptr = buf - HDRSIZE; // -> base of header
+ chptr = buf; // -> base of header
D_word(0x601A); // 00 - magic number
D_long(sect[TEXT].sloc); // 02 - TEXT size
D_long(sect[DATA].sloc); // 06 - DATA size
D_long(sect[BSS].sloc); // 0A - BSS size
- D_long(0); // 0E - symbol table size (will be filled later if non zero)
+ D_long(0); // 0E - symbol table size (filled later)
D_long(0); // 12 - stack size (unused)
D_long(PRGFLAGS); // 16 - PRGFLAGS
D_word(0); // 1A - relocation information exists
// Construct text and data segments; fixup relocatable longs in .PRG
// mode; finally write the header + text + data
- p = buf;
+ p = buf + HDRSIZE;
for(i=TEXT; i<=DATA; i++)
{
// Do a first pass on the Alcyon image, if in PRG mode
if (prg_flag)
- MarkImage(buf, tds, sect[TEXT].sloc, 0);
-
- unused = write(fd, buf - HDRSIZE, tds + HDRSIZE);
+ MarkImage(buf + HDRSIZE, tds, sect[TEXT].sloc, 0);
- // Construct and write symbol table
- if (prg_flag != 1)
+ // Construct symbol table and update the header entry, if necessary
+ if (prg_flag > 1)
{
- sy_assign(buf, AddSymEntry);
- unused = write(fd, buf, symsize);
+ // sy_assign with AddSymEntry updates symsize (stays 0 otherwise)
+ sy_assign(buf + HDRSIZE + tds, AddSymEntry);
+ chptr = buf + 0x0E; // Point to symbol table size entry
+ D_long(symsize);
}
+ // Write out the header + text & data + symbol table (if any)
+ unused = write(fd, buf, HDRSIZE + tds + symsize);
+
// Construct and write relocation information; the size of it changes if
- // we're writing a RELMODed executable.
+ // we're writing a RELMODed executable. N.B.: Destroys buffer!
tds = MarkImage(buf, tds, sect[TEXT].sloc, 1);
unused = write(fd, buf, tds);
-
- // If we generated a symbol table we need to update the placeholder value
- // we wrote above in the header
- lseek(fd, 0xE, 0);
- symsize = BYTESWAP32(symsize);
- unused = write(fd, &symsize, 4);
-
}
else if (obj_format == ELF)
{
// Common index handler; enter here with 'tok' pointing at the
// comma.
- AMn_IX0: // Handle indexed with missing expr
+AMn_IX0: // Handle indexed with missing expr
AnEXVAL = 0;
AnEXATTR = ABS | DEFINED;
- AMn_IXN: // Handle any indexed (tok -> a comma)
+AMn_IXN: // Handle any indexed (tok -> a comma)
if (*tok++ != ',')
goto badmode;
{
if (expr(scaleexpr, &scaleval, &scaleattr, &scaleesym) != OK)
return error("scale factor expression must evaluate");
+
switch (scaleval)
{
case 1:
else
{
expr(AnBEXPR, &AnBEXVAL, &AnBEXATTR, &AnESYM);
+
if (CHECK_OPTS(OPT_BASE_DISP) && AnBEXVAL == 0 && AnEXATTR != 0)
{
// bd=0 so let's optimise it out
AnEXTEN|=EXT_BDSIZE0;
}
else if (*tok == DOTL)
- { // ([bd.l,...
- AnEXTEN |= EXT_BDSIZEL;
- tok++;
+ {
+ // ([bd.l,...
+ AnEXTEN |= EXT_BDSIZEL;
+ tok++;
}
else
- { // ([bd[.w],... or ([bd,...
+ {
+ // ([bd[.w],... or ([bd,...
// Is .W forced here?
if (*tok == DOTW)
{
}
else
{
- // Defined, absolute values from $FFFF8000..$00007FFF get optimized
- // to absolute short
+ // Defined, absolute values from $FFFF8000..$00007FFF
+ // get optimized to absolute short
if (CHECK_OPTS(OPT_ABS_SHORT)
&& ((AnBEXATTR & (TDB | DEFINED)) == DEFINED)
&& (((uint32_t)AnBEXVAL + 0x8000) < 0x10000))
tok++;
// Check for size
+ // ([bd,An/PC],Xn.W/L...)
+ switch ((int)*tok)
{
- // ([bd,An/PC],Xn.W/L...)
- switch ((int)*tok)
- {
- // Index reg size: <empty> | .W | .L
- case DOTW:
- tok++;
- break;
- default:
- break;
- case DOTL:
- AnEXTEN |= EXT_L;
- tok++;
- break;
- case DOTB:
- // .B not allowed here...
- goto badmode;
- }
+ // Index reg size: <empty> | .W | .L
+ case DOTW:
+ tok++;
+ break;
+ default:
+ break;
+ case DOTL:
+ AnEXTEN |= EXT_L;
+ tok++;
+ break;
+ case DOTB:
+ // .B not allowed here...
+ goto badmode;
}
// Check for scale
}
// Check for size
+ // ([bd,An/PC],Xn.W/L...)
+ switch ((int)*tok)
{
- // ([bd,An/PC],Xn.W/L...)
- switch ((int)*tok)
- {
- // Index reg size: <empty> | .W | .L
- case DOTW:
- tok++;
- break;
- default:
- break;
- case DOTL:
- AnEXTEN |= EXT_L;
- tok++;
- break;
- case DOTB:
- // .B not allowed here...
- goto badmode;
- }
+ // Index reg size: <empty> | .W | .L
+ case DOTW:
+ tok++;
+ break;
+ default:
+ break;
+ case DOTL:
+ AnEXTEN |= EXT_L;
+ tok++;
+ break;
+ case DOTB:
+ // .B not allowed here...
+ goto badmode;
}
// Check for scale
else
tok++; // eat the comma
- CHECKODn:
+CHECKODn:
if (expr(AnEXPR, &AnEXVAL, &AnEXATTR, &AnESYM) != OK)
goto badmode;
// Is .W forced here?
if (*tok == DOTW)
- {
tok++;
- }
}
// Check for final closing parenthesis
}
// Check for size
+ // ([bd,An/PC],Xn.W/L...)
+ switch ((int)*tok)
{
- // ([bd,An/PC],Xn.W/L...)
- switch ((int)*tok)
- {
- // Index reg size: <empty> | .W | .L
- case DOTW:
- tok++;
- break;
- default:
- break;
- case DOTL:
- tok++;
- AnEXTEN |= EXT_L;
- break;
- case DOTB:
- // .B not allowed here...
- goto badmode;
- }
+ // Index reg size: <empty> | .W | .L
+ case DOTW:
+ tok++;
+ break;
+ default:
+ break;
+ case DOTL:
+ tok++;
+ AnEXTEN |= EXT_L;
+ break;
+ case DOTB:
+ // .B not allowed here...
+ goto badmode;
}
// Check for scale
if (*tok == '*') // ([bd,An/PC],Xn*...)
- { // scale: *1, *2, *4, *8
+ { // scale: *1, *2, *4, *8
tok++;
if (*tok == SYMBOL)
{
if (expr(scaleexpr, &scaleval, &scaleattr, &scaleesym) != OK)
return error("scale factor expression must evaluate");
+
switch (scaleval)
{
case 1:
if (*tok == ',')
{
- // Check if we're actually doing d8(An,Dn) or (d16,An,Dn[.size][*scale])
- // TODO: not a very clear cut case from what I can think. The only way
- // to distinguish between the two is to check AnEXVAL and see if it's
- // >127 or <-128. But this doesn't work if AnEXVAL isn't defined yet.
- // For now we fall through to d8(An,Dn) but this might bite us in the
- // arse during fixups...
+ // Check if we're actually doing d8(An,Dn) or
+ // (d16,An,Dn[.size][*scale])
+ // TODO: not a very clear cut case from what I can think.
+ // The only way to distinguish between the two is to check
+ // AnEXVAL and see if it's >127 or <-128. But this doesn't
+ // work if AnEXVAL isn't defined yet. For now we fall
+ // through to d8(An,Dn) but this might bite us in the arse
+ // during fixups...
if ((AnEXATTR & DEFINED) && (AnEXVAL + 0x80 > 0x100))
{
- // We're going to treat it as a full extension format with no
- // indirect access and no base displacement/index register suppression
+ // We're going to treat it as a full extension format
+ // with no indirect access and no base displacement/
+ // index register suppression
AnEXTEN |= EXT_FULLWORD; // Definitely using full extension format, so set bit 8
AnEXTEN |= EXT_IISPRE0; // No Memory Indirect Action
AnEXTEN |= EXT_BDSIZEL; // Base Displacement Size Long
tok++; // Get past the comma
- // Our expression is techically a base displacement
+ // Our expression is techically a base displacement,
// so let's copy it to the relevant variables so
// eagen0.c can pick it up properly
//AnBEXPR = AnEXPR;
}
// Check for scale
if (*tok == '*') // ([bd,An/PC],Xn*...)
- { // scale: *1, *2, *4, *8
+ { // scale: *1, *2, *4, *8
tok++;
if (*tok == SYMBOL)
{
if (expr(scaleexpr, &scaleval, &scaleattr, &scaleesym) != OK)
return error("scale factor expression must evaluate");
+
switch (scaleval)
{
case 1:
else
goto badmode;
}
-
+
AMn = AINDEXED;
goto AMn_IXN;
}
#define MAJOR 1 // Major version number
#define MINOR 11 // Minor version number
-#define PATCH 0 // Patch release number
+#define PATCH 9 // Patch release number
#endif // __VERSION_H__