Compiling asmx
Moderator: BigEvilCorporation
Compiling asmx
hello again
I'm trying to recompile asmx on windows (so i can modify it). I downloaded mingw.
So everytime i compile using mingw32-gcc *.c -o asmx
i got
asmguts.h:275: error: storage size of `opcdTab2' isn't known
asmz80.c:60: error: storage size of `opcdTab' isn't known
anyone got idea how to get rid of those error, knowing i can not define the size (dynamic) as the tabs are define like this:
struct OpcdRec opcdTab[] =
{
...
thanks in advance
pascal
I'm trying to recompile asmx on windows (so i can modify it). I downloaded mingw.
So everytime i compile using mingw32-gcc *.c -o asmx
i got
asmguts.h:275: error: storage size of `opcdTab2' isn't known
asmz80.c:60: error: storage size of `opcdTab' isn't known
anyone got idea how to get rid of those error, knowing i can not define the size (dynamic) as the tabs are define like this:
struct OpcdRec opcdTab[] =
{
...
thanks in advance
pascal
Re: Compiling asmx
Good 2 see someone else with asmx problems (even if the thread is almost 8 years old )
When it comes to compilation, i don't have any troubles - not even warnings.
The problem is "incbin".
When I'm including binary, asmx cuts it at first seen "1A" byte there... That happens only on windows, when i compile asmx with mingw.
Another question is - there is a sonic hack, named "wtf lame" - its source consist asmx.exe which includes binaries without any problems and its size is pretty small... How did they do it!?
When it comes to compilation, i don't have any troubles - not even warnings.
The problem is "incbin".
When I'm including binary, asmx cuts it at first seen "1A" byte there... That happens only on windows, when i compile asmx with mingw.
Another question is - there is a sonic hack, named "wtf lame" - its source consist asmx.exe which includes binaries without any problems and its size is pretty small... How did they do it!?
Re: Compiling asmx
I'm guessing the file is opened in text mode ("r") instead of binary mode ("rb"). On *nix they're identical, but Windows converts between CRLF and LF. It'll also stop whenever it sees DOS EOF (which happens to be 0x1A).
You'll have to hunt down that fopen and replace the "r" with "rb".
You'll have to hunt down that fopen and replace the "r" with "rb".
Sik is pronounced as "seek", not as "sick".
Re: Compiling asmx
Thank you so much for solving my problem! I finally got rid of this annoying bug.
found it at asmx.c, line 4695
upd.
There also was a bug, adding 0D before 0A, replacing 0Fs with 00 and it probably did something else. I fixed it the same way:
Code: Select all
replaced
object = fopen(cl_ObjName, "w");
with
object = fopen(cl_ObjName, "wb");
Re: Compiling asmx
Yeah, literally the same issue (conversion of control codes). Didn't think 0x0F would be affected too though.
I'd have suggested to just go change all calls to fopen, but I imagine that you're probably using CRLF newlines in your source code and the assembler expecting LF and hence you need to keep the fopen to the source files as just "r" (so the conversion happens), so blindly changing everything would be a bad idea. For anything binary though it absolutely should be "rb"/"wb".
I'd have suggested to just go change all calls to fopen, but I imagine that you're probably using CRLF newlines in your source code and the assembler expecting LF and hence you need to keep the fopen to the source files as just "r" (so the conversion happens), so blindly changing everything would be a bad idea. For anything binary though it absolutely should be "rb"/"wb".
Sik is pronounced as "seek", not as "sick".
Re: Compiling asmx
I'm so glad that I can use properly working native win-asmx, without Cygwin environment now! Thank you!
Asmx itself works just everywhere (even on my android, where I've built it with c4droid and even assembled a hack with it ).
Asmx itself works just everywhere (even on my android, where I've built it with c4droid and even assembled a hack with it ).
Re: Compiling asmx
Ok, i found another bug (i think its also asmx source question).
asmx sees too big difference between "move.w 0(a1),d1" and "move.w 1(a1),d1".
When it's 1 or more, it gives correct code - 32 29 00 01, but when it's 0, it just gives 32 11 instead of 32 29 00 00.
How comes?
I'm trying to assemble original ROM from sources, so I found out there is a difference.
Asmx has interesting comments at 657 line - // 0(PC,Xn) 0(An,Xn) and // FIXME: reg1 can't be PC here?...
asmx sees too big difference between "move.w 0(a1),d1" and "move.w 1(a1),d1".
When it's 1 or more, it gives correct code - 32 29 00 01, but when it's 0, it just gives 32 11 instead of 32 29 00 00.
How comes?
I'm trying to assemble original ROM from sources, so I found out there is a difference.
Asmx has interesting comments at 657 line - // 0(PC,Xn) 0(An,Xn) and // FIXME: reg1 can't be PC here?...
Code: Select all
else if (token == ',')
{ // 0(PC,Xn) 0(An,Xn)
// FIXME: reg1 can't be PC here?
val = 0;
reg2 = GetReg(DA_regs);
if (reg2 == 16) reg2 = 15; // SP -> A7
if (reg2 >= 0)
{
// get Xn forced size if any
width = WID_W;
if (linePtr[0] == '.' && toupper(linePtr[1]) == 'L')
{
linePtr = linePtr + 2;
width = WID_L;
}
else if (linePtr[0] == '.' && toupper(linePtr[1]) == 'W')
linePtr = linePtr + 2;
//CheckByte(val); // zero IS a byte
if (RParen()) return FALSE;
if (reg1 == 9)
{
// (PC,Xn)
if (!store)
{
// val = val - locPtr - 2; // don't offset from PC
ea -> mode = 0x3B;
ea -> len = 1;
ea -> extra[0] = (reg2 << 12) + (val & 0xFF);
if (width == WID_L)
ea -> extra[0] |= 0x0800;
return TRUE;
}
}
else
{
// (An,Xn)
ea -> mode = 0x30 + reg1;
ea -> len = 1;
ea -> extra[0] = (reg2 << 12) + (val & 0xFF);
if (width == WID_L)
ea -> extra[0] |= 0x0800;
return TRUE;
}
}
}
Re: Compiling asmx
Yeaaaaaah whenever it sees 0(An) it always optimizes it into (An) regardless of settings. Ran into it the hard way because it effectively makes MOVEP unusable with an offset of 0 >_> (MOVEP only supports nn(An) and not (An), so 0(An) becoming (An) literally made it not build). I had to fix it in my own copy.
I have a modified asmx to make it closer to asm68k syntax but the author never used a proper license and I lost contact with him so looks like I'm unable to release it legally for now.
EDIT: since we're talking about asmx bugs, another bug I had to fix is that it misassembles CMP An, An into CMP (An)+, (An)+. Was wondering why the code didn't work (expecting some dumb mistake) until I got so fed up I decided to look into the disassembler in Regen and noticed something was off there.
I have a modified asmx to make it closer to asm68k syntax but the author never used a proper license and I lost contact with him so looks like I'm unable to release it legally for now.
EDIT: since we're talking about asmx bugs, another bug I had to fix is that it misassembles CMP An, An into CMP (An)+, (An)+. Was wondering why the code didn't work (expecting some dumb mistake) until I got so fed up I decided to look into the disassembler in Regen and noticed something was off there.
Sik is pronounced as "seek", not as "sick".
Re: Compiling asmx
Have you uploaded the fixed asmx to github? I'd like to have it too, with your permission.
Re: Compiling asmx
That's the part I can't do because asmx doesn't have any proper license =/
Sik is pronounced as "seek", not as "sick".
Re: Compiling asmx
Oh... Well then, can u guide me how to solve 0(an) / cmp(an)+ bugs? (if u don't mind ofc)
-
- Very interested
- Posts: 2984
- Joined: Fri Aug 17, 2007 9:33 pm
Re: Compiling asmx
Post a diff file, then. That should be fine regardless of the license (or lack thereof).
Re: Compiling asmx
Good call... especially because I forgot what change I had made was the one that fixed the CMP issue =/
asm68k.c:
asm68k.c:
Code: Select all
--- asm68k-asmx.c 2016-07-12 22:05:50.444463000 -0300
+++ asm68k-sikasm.c 2016-07-28 05:19:36.954015000 -0300
@@ -892,12 +892,14 @@
}
else
{
+ /*
if (evalKnown && val == 0)
{
// 010 (An)
ea -> mode = 0x10 + reg1;
return TRUE;
}
+ */
// d16(An)
CheckWord(val);
@@ -1159,7 +1161,8 @@
val = EvalBranch(2);
if (val == 0)
{
- Warning("Short branch can not have zero offset!");
+ //Warning("Short branch can not have zero offset!");
+ Error("Short branch can not have zero offset!");
InstrW(0x4E71); // assemble a NOP instead of a zero branch
}
else InstrW((parm & 0xFF00) + (val & 0x00FF));
@@ -1182,8 +1185,8 @@
InstrW((parm & 0xFF00) + (val & 0x00FF));
else
{
- if (val != 0 && -128 <= val && val <= 129) // max is +129 because short branch saves 2 bytes
- Warning("Short branch could be used here");
+ //if (val != 0 && -128 <= val && val <= 129) // max is +129 because short branch saves 2 bytes
+ // Warning("Short branch could be used here");
InstrWW(parm & 0xFF00,val);
}
#endif
@@ -1191,8 +1194,8 @@
#endif
case WID_W:
val = EvalWBranch(2);
- if (val != 0 && -128 <= val && val <= 129) // max is +129 because short branch saves 2 bytes
- Warning("Short branch could be used here");
+ //if (val != 0 && -128 <= val && val <= 129) // max is +129 because short branch saves 2 bytes
+ // Warning("Short branch could be used here");
InstrWW(parm & 0xFF00,val);
break;
@@ -1510,8 +1513,8 @@
case 0xB000: // CMP/EOR
if (reg2 & 0x8000) // disallow EOR
{
- InstrWE((parm & 0xF000) + (reg1 << 9) + (size << 7) + 0x40, &ea1);
- // IllegalOperand();
+ //InstrWE((parm & 0xF000) + (reg1 << 9) + (size << 7) + 0x40, &ea1);
+ InstrWE((parm & 0xF000) + (reg1 << 9) + (size << 7) + 0xC0, &ea1);
break;
}
default:
@@ -1771,6 +1774,18 @@
{
reg1 = ea1.mode & 7;
reg2 = ea2.mode & 7;
+
+ if ((ea1.mode & 0x38) == 0x10) {
+ ea1.mode &= ~0x38;
+ ea1.mode |= 0x28;
+ ea1.extra[0] = 0;
+ }
+ if ((ea2.mode & 0x38) == 0x10) {
+ ea2.mode &= ~0x38;
+ ea2.mode |= 0x28;
+ ea2.extra[0] = 0;
+ }
+
if ((ea1.mode & 0x38) == 0x00 && (ea2.mode & 0x38) == 0x28)
InstrWW(parm + (reg1 << 9) + reg2 + 0x0080, ea2.extra[0]); // Dx,(d16,Ay)
else if ((ea1.mode & 0x38) == 0x28 && (ea2.mode & 0x38) == 0x00)
Sik is pronounced as "seek", not as "sick".
Re: Compiling asmx
thanks, guys
-
- Very interested
- Posts: 159
- Joined: Sat Feb 24, 2007 11:35 pm
- Location: San Antonio, TX
Re: Compiling asmx
Finally getting real life under control to where I can work on this stuff again. For now, it's in http://svn.xi6.com/svn/asmx/ with the "current" 2.x version being in:
http://svn.xi6.com/svn/asmx/branches/2.x/
If the current 2.x branch works well enough, I'm going to make it an official 2.0 version.
Right now "trunk" is my attempt at using C++, but there were some people who were building this on really old computers that didn't have C++ (to work with architectures other than 68k), so that's set aside for now. It may become a 3.0 version.
http://svn.xi6.com/svn/asmx/branches/2.x/
If the current 2.x branch works well enough, I'm going to make it an official 2.0 version.
Right now "trunk" is my attempt at using C++, but there were some people who were building this on really old computers that didn't have C++ (to work with architectures other than 68k), so that's set aside for now. It may become a 3.0 version.