Fixed instructions operating on EX. Make assembler case insensitive and ignore comma in single operand opcodes.

This commit is contained in:
Maurizio Porrato 2021-02-13 10:03:46 +00:00
parent d7302226ea
commit 69966cdcda
2 changed files with 16 additions and 7 deletions

8
asm.py
View File

@ -2,6 +2,7 @@
from types import SimpleNamespace
from rply import ParserGenerator, LexerGenerator
import re
import struct
OPS = {
@ -153,7 +154,7 @@ tokens = [
]
for name, regex in tokens:
lg.add(name, regex)
lg.add(name, regex, re.IGNORECASE)
#lg.ignore(r'\s+')
lg.ignore(r'[ \t\v\f]+')
@ -212,8 +213,10 @@ def op_op2(p):
return ASM(label=None, op=p[0].getstr(), b=p[1], a=p[3])
@pg.production("op : OP1 arg_a")
# Some source code has a comma before the argument
@pg.production("op : OP1 COMMA arg_a")
def op_op1(p):
return ASM(label=None, op=p[0].getstr(), a=p[1], b=None)
return ASM(label=None, op=p[0].getstr(), a=p[-1], b=None)
@pg.production("op : DIRN exprlist")
def op_dirn(p):
@ -393,6 +396,7 @@ if __name__ == '__main__':
print(["%04x" % x for x in words])
for w in words:
binimage += struct.pack("<H", w)
#binimage += struct.pack(">H", w)
outfilename = filename[:filename.rfind('.')]+'.bin'
with open(outfilename, 'wb') as binfile:
binfile.write(binimage)

15
dsim.c
View File

@ -225,8 +225,8 @@ void oDIV(uint16_t *a, uint16_t *b)
if (*a) {
wb = *b;
wt = (wb<<16) / *a;
rex = wt&0xffff;
*b = wt>>16;
rex = wt&0xffff;
} else {
*b = rex = 0;
}
@ -234,9 +234,14 @@ void oDIV(uint16_t *a, uint16_t *b)
void oDVI(uint16_t *a, uint16_t *b)
{
int32_t wa, wb, wt;
if (*a) {
rex = ((int16_t)*b<<16) / (int16_t)*a;
*b = (int16_t)*b / (int16_t)*a;
wa = (*a << 16) >> 16;
wb = (*b << 16) >> 16;
wt = (wb<<16) / wa;
*b = wt>>16;
rex = wt&0xffff;
} else {
*b = rex = 0;
}
@ -298,8 +303,8 @@ void oSHL(uint16_t *a, uint16_t *b)
uint32_t t;
t = ((uint32_t)*b) << *a;
rex = t >> 16;
*b = t;
rex = t >> 16;
}
#define DOIF(c) if (!(c)) { skip_next = true; ticks++; }
@ -484,7 +489,7 @@ void next()
if ((!intq_en) && (intq_size > 0) && (!skip_next)) {
i = intq_pop();
if (ria != 0) {
printf("Firing interrupt with message 0x%04x\n", i);
//printf("Firing interrupt with message 0x%04x\n", i);
intq_en = true;
ram[--rsp] = rpc;
ram[--rsp] = ra;