test with default godbolt.org loop example, slightly modified
authorLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 21 May 2021 14:19:39 +0000 (15:19 +0100)
committerLuke Kenneth Casson Leighton <lkcl@lkcl.net>
Fri, 21 May 2021 14:19:39 +0000 (15:19 +0100)
to run attn in order to halt

src/openpower/decoder/isa/pypowersim.py
src/test/basic_pypowersim/Makefile
src/test/basic_pypowersim/square.s [new file with mode: 0644]

index 50d58c07dd8c268ce1905c7d31057d01b5aa6ecb..1c6316309c927975d599c4dec3643740d55a5c53 100644 (file)
@@ -93,7 +93,7 @@ def run_tst(args, generator, initial_regs,
         yield pdecode2.dec.bigendian.eq(0)  # little / big?
         pc = simulator.pc.CIA.value
         index = pc//4
-        while index < len(instructions):
+        while index < len(instructions) and not simulator.halted:
             print("instr pc", pc)
             try:
                 yield from simulator.setup_one()
index 80870f57cb19e36f0c7553171f2eb63d3b7098d2..afd15f33496e1ab54e60756c932736c73def9ae1 100644 (file)
@@ -11,7 +11,7 @@ sim: kernel.bin
 clean:
        rm *.o *.elf *.bin
 
-kernel.elf: testloop.o
+kernel.elf: square.o
        $(TOOLCHAIN)-ld $^ -EL -o $@ -T memmap
 
 kernel.bin: kernel.elf
diff --git a/src/test/basic_pypowersim/square.s b/src/test/basic_pypowersim/square.s
new file mode 100644 (file)
index 0000000..38ed5bc
--- /dev/null
@@ -0,0 +1,18 @@
+        std 31,-8(1)
+        stdu 1,-48(1)
+        mr 31,1
+        li 12,5
+.L3:
+        mr 9,12
+        addi 9,9,-1
+        mr 12,9
+        mr 9,12
+        cmpdi 7,9,0
+        beq 7,.L4
+        b .L3
+.L4:
+        addi 1,31,48
+        ld 31,-8(1)
+        attn
+        .long 0
+        .byte 0,9,0,0,128,1,0,1