# HG changeset patch # User james # Date 1391101795 0 # Node ID 9bbdf7258cd80df74874b7561ffde60f6433f14a # Parent 50dd22c1ccba4a20ab6bd75eaa891217da0f7517 Second pass now properly pads addresses diff -r 50dd22c1ccba -r 9bbdf7258cd8 assembler/assembler.py --- 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 diff -r 50dd22c1ccba -r 9bbdf7258cd8 tests/ljmp.asm --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tests/ljmp.asm Thu Jan 30 17:09:55 2014 +0000 @@ -0,0 +1,7 @@ +LJMP label +CLR C +label: +SET C +label2: +SJMP label2 + diff -r 50dd22c1ccba -r 9bbdf7258cd8 tests/test.bin Binary file tests/test.bin has changed