From 5802220fc55fbaf66d29b5b606020d160c354685 Mon Sep 17 00:00:00 2001 From: BigEd Date: Mon, 22 Aug 2011 11:02:04 +0100 Subject: [PATCH] monitor: swap byte order for load and save (affects 16-byte binaries) --- src/py65/monitor.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/py65/monitor.py b/src/py65/monitor.py index fab99e7..c1a821e 100644 --- a/src/py65/monitor.py +++ b/src/py65/monitor.py @@ -439,7 +439,7 @@ class Monitor(cmd.Cmd): if self.byteWidth==8: bytes=map(ord, bytes) elif self.byteWidth==16: - bytes=map(lambda msb,lsb: (ord(msb)<<8)+ord(lsb),bytes[1::2],bytes[0::2]) + bytes=map(lambda msb,lsb: (ord(msb)<<8)+ord(lsb),bytes[0::2],bytes[1::2]) self._fill(start, start, bytes) @@ -457,9 +457,9 @@ class Monitor(cmd.Cmd): try: f = open(filename, 'wb') for byte in bytes: - for char in range (0,self.byteWidth,8): - f.write(chr(byte & 0xff)) - byte = byte >> 8 + # output each octect from msb first + for shift in range (self.byteWidth-8,-1,-8): + f.write(chr((byte>>shift) & 0xff)) f.close() except (OSError, IOError), why: msg = "Cannot save file: [%d] %s" % (why[0], why[1])