Mercurial > hg > ede
changeset 17:9bbdf7258cd8
Second pass now properly pads addresses
author | james <jb302@eecs.qmul.ac.uk> |
---|---|
date | Thu, 30 Jan 2014 17:09:55 +0000 |
parents | 50dd22c1ccba |
children | 256d24488e3f |
files | assembler/assembler.py tests/ljmp.asm tests/test.bin |
diffstat | 3 files changed, 13 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/assembler/assembler.py Thu Jan 30 15:27:02 2014 +0000 +++ b/assembler/assembler.py Thu Jan 30 17:09:55 2014 +0000 @@ -91,15 +91,19 @@ # assemble to file # need to make sure 16 bit arguments are padded f.seek(pc) + op, width = iset[mne][sym] try: - f.write(struct.pack('>B', iset[mne][sym][0])) + f.write(struct.pack('>B', op)) + # pad if needed + for i in range(width - len(const) - 1): + f.write(struct.pack('>B', 0)) f.write(const) except: # will raise a symbol error when any unrecognised # mnemonic or argument format is found print 'syntax error: %s %s' % (mne, sym) return 'symbol_error' - pc = pc + len(const) + 1 + pc = pc + width f.seek(0) return f