diff --git a/x1/Makefile b/x1/Makefile index c51b080..95abf93 100644 --- a/x1/Makefile +++ b/x1/Makefile @@ -24,5 +24,7 @@ spray/main.bin: @./extract.py -p a.out spray/top.bin @$(AS) spray/bottom.S @./extract.py -p a.out spray/bottom.bin - @./append_nop.py 15728640 spray/top.bin spray/bottom.bin spray/main.bin + @$(AS) spray/bottom_reset.S + @./extract.py -p a.out spray/bottom_reset.bin + @./append_nop.py spray/top.bin spray/bottom.bin spray/bottom_reset.bin spray/main.bin 112 113 @rm -f a.out diff --git a/x1/append_nop.py b/x1/append_nop.py index bdfa73e..96a9acf 100755 --- a/x1/append_nop.py +++ b/x1/append_nop.py @@ -5,20 +5,31 @@ import sys def main(): if len(sys.argv) < 5: - print(f'Usage: {sys.argv[0]} N top.bin bottom.bin out.bin', file=sys.stderr) + print(f'Usage: {sys.argv[0]} top.bin bottom_loop.bin bottom_reset.bin out.bin reset_fill_from reset_fill_to', file=sys.stderr) sys.exit(1) - with open(sys.argv[2], 'rb') as topf, open(sys.argv[3], 'rb') as bottomf, open(sys.argv[4], 'wb') as out: - top, bottom = topf.read(), bottomf.read() + with open(sys.argv[1], 'rb') as tf, open(sys.argv[2], 'rb') as btmlf, open(sys.argv[3], 'rb') as btmrf, open(sys.argv[4], 'wb') as out: + top, btml, btmr = tf.read(), btmlf.read(), btmrf.read() + fill_from, fill_to = int(sys.argv[5]), int(sys.argv[6]) + out.write(top) - for i in range((1024 * 64 - len(top) - len(bottom)) // 4): + if fill_from == 0: + blen, b = len(btmr), btmr + else: + blen, b = len(btml), btml + for i in range((1024 * 64 - len(top) - blen) // 4): out.write(b'\x00\x00\xa0\xe1') - out.write(bottom) + out.write(b) for i in range(1024 * 1024 * 15 // (1024 * 64) - 1): - for i in range((1024 * 64 - len(bottom)) // 4): + if fill_from <= i+1 < fill_to: + blen, b = len(btmr), btmr + else: + blen, b = len(btml), btml + + for j in range((1024 * 64 - blen) // 4): out.write(b'\x00\x00\xa0\xe1') - out.write(bottom) + out.write(b) main() diff --git a/x1/spray/bottom.S b/x1/spray/bottom.S index ac76cb4..dca8308 100644 --- a/x1/spray/bottom.S +++ b/x1/spray/bottom.S @@ -4,6 +4,5 @@ _start: loop: + nop b loop - ldr r0, =0x00000000 - mov pc, r0 diff --git a/x1/spray/bottom_reset.S b/x1/spray/bottom_reset.S new file mode 100644 index 0000000..166962a --- /dev/null +++ b/x1/spray/bottom_reset.S @@ -0,0 +1,7 @@ +.text + .align 2 + .global _start + +_start: + ldr r0, =0x00000000 + mov pc, r0