mirror of
https://github.com/rzzzwilson/pymlac.git
synced 2025-06-10 09:32:41 +00:00
Fixed iasm bug stopping CPU tests
This commit is contained in:
@@ -375,7 +375,7 @@ Description : Delimit label, opcode and address fields of assembler line.
|
||||
: field - address of address field pointer (returned)
|
||||
: comment - address of comment string (returned)
|
||||
Returns :
|
||||
Comments : The buffer is broken into shorter strings (destroyed).
|
||||
Comments : 'buffer' is destroyed (broken into shorter strings.
|
||||
******************************************************************************/
|
||||
static void
|
||||
delimfields(char *buffer,
|
||||
@@ -401,19 +401,25 @@ delimfields(char *buffer,
|
||||
if (*chptr != ';' && *chptr != '\n')
|
||||
{
|
||||
*opcode = chptr;
|
||||
while (!isspace(*chptr))
|
||||
while (!isspace(*chptr) && *chptr != ';' && *chptr != '\n')
|
||||
++chptr;
|
||||
*chptr = '\0';
|
||||
++chptr;
|
||||
// at end of opcode
|
||||
if (isspace(*chptr) || *chptr == ';' || *chptr == '\n')
|
||||
{
|
||||
*chptr = '\0';
|
||||
++chptr;
|
||||
}
|
||||
|
||||
while (isspace(*chptr) && *chptr != ';' && *chptr != '\n')
|
||||
while (*chptr != '\0' && isspace(*chptr) && *chptr != ';' && *chptr != '\n')
|
||||
++chptr;
|
||||
if (*chptr != ';' && *chptr != '\n')
|
||||
|
||||
if (*chptr && *chptr != ';' && *chptr != '\n')
|
||||
{
|
||||
*field = chptr;
|
||||
while (!isspace(*chptr) && *chptr != ';' && *chptr != '\n')
|
||||
++chptr;
|
||||
*chptr = '\0';
|
||||
++chptr;
|
||||
if (strlen(*field) == 0)
|
||||
*field = NULL;
|
||||
}
|
||||
|
||||
@@ -93,6 +93,7 @@ Debug(char *fmt, ...)
|
||||
vsprintf(buff, fmt, ap);
|
||||
fprintf(stdout, "%s\n", buff);
|
||||
va_end(ap);
|
||||
fflush(stdout);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -18,4 +18,4 @@ lst: $(TESTS)
|
||||
../iasm/iasm -l $*.lst $<
|
||||
|
||||
clean:
|
||||
rm -Rf *.pyc *~ *.out test_*.ptp *.lst test_*.trace _#*#_.ptp
|
||||
rm -Rf *.pyc *~ *.out test_*.ptp *.lst test_*.trace _#ASM#_.*
|
||||
|
||||
@@ -11,6 +11,8 @@ where <filename> is a file of test instructions and
|
||||
-h prints this help and stops
|
||||
"""
|
||||
|
||||
import time
|
||||
|
||||
# We implement a small interpreter to test the CPU. The test code is read in
|
||||
# from a file:
|
||||
#
|
||||
@@ -93,7 +95,9 @@ class TestCPU(object):
|
||||
fd.write('\tend\n')
|
||||
|
||||
# now assemble file
|
||||
os.system('../iasm/iasm -l %s.lst %s.asm' % (self.AsmFilename, self.AsmFilename))
|
||||
#cmd = '../iasm/iasm -l %s.lst %s.asm >xyzzy 2>&1' % (self.AsmFilename, self.AsmFilename)
|
||||
cmd = '../iasm/iasm -l %s.lst %s.asm' % (self.AsmFilename, self.AsmFilename)
|
||||
res = os.system(cmd)
|
||||
|
||||
# read the listing file to get assembled opcode (second line)
|
||||
with open(self.AsmFilename+'.lst', 'rb') as fd:
|
||||
|
||||
Reference in New Issue
Block a user