402 lines
5.7 KiB
ArmAsm
402 lines
5.7 KiB
ArmAsm
|
.file "gameoflife-oscillator.sy"
|
||
|
.option pic
|
||
|
.attribute arch, "rv64i2p1_m2p0_a2p1_f2p2_d2p2_c2p0_zicsr2p0_zifencei2p0"
|
||
|
.attribute unaligned_access, 0
|
||
|
.attribute stack_align, 16
|
||
|
.text
|
||
|
.align 1
|
||
|
.globl read_map
|
||
|
.type read_map, @function
|
||
|
read_map:
|
||
|
addi sp,sp,-48
|
||
|
sd ra,40(sp)
|
||
|
sd s2,16(sp)
|
||
|
sd s0,32(sp)
|
||
|
lla s2,.LANCHOR0
|
||
|
sd s1,24(sp)
|
||
|
sd s3,8(sp)
|
||
|
sd s4,0(sp)
|
||
|
call getint@plt
|
||
|
sw a0,0(s2)
|
||
|
call getint@plt
|
||
|
sw a0,4(s2)
|
||
|
call getint@plt
|
||
|
sw a0,8(s2)
|
||
|
call getch@plt
|
||
|
lw a5,4(s2)
|
||
|
ble a5,zero,.L1
|
||
|
lla s4,sheet1+2004
|
||
|
li s3,1
|
||
|
.L3:
|
||
|
lw a5,0(s2)
|
||
|
mv s1,s4
|
||
|
li s0,1
|
||
|
ble a5,zero,.L5
|
||
|
.L4:
|
||
|
call getch@plt
|
||
|
addi a0,a0,-35
|
||
|
lw a5,0(s2)
|
||
|
seqz a0,a0
|
||
|
sw a0,0(s1)
|
||
|
addiw s0,s0,1
|
||
|
addi s1,s1,4
|
||
|
bge a5,s0,.L4
|
||
|
.L5:
|
||
|
call getch@plt
|
||
|
lw a5,4(s2)
|
||
|
addiw s3,s3,1
|
||
|
addi s4,s4,2000
|
||
|
bge a5,s3,.L3
|
||
|
.L1:
|
||
|
ld ra,40(sp)
|
||
|
ld s0,32(sp)
|
||
|
ld s1,24(sp)
|
||
|
ld s2,16(sp)
|
||
|
ld s3,8(sp)
|
||
|
ld s4,0(sp)
|
||
|
addi sp,sp,48
|
||
|
jr ra
|
||
|
.size read_map, .-read_map
|
||
|
.align 1
|
||
|
.globl put_map
|
||
|
.type put_map, @function
|
||
|
put_map:
|
||
|
addi sp,sp,-64
|
||
|
sd s2,32(sp)
|
||
|
lla s2,.LANCHOR0
|
||
|
lw a5,4(s2)
|
||
|
sd ra,56(sp)
|
||
|
sd s0,48(sp)
|
||
|
sd s1,40(sp)
|
||
|
sd s3,24(sp)
|
||
|
sd s4,16(sp)
|
||
|
sd s5,8(sp)
|
||
|
ble a5,zero,.L11
|
||
|
lla s5,sheet1+2004
|
||
|
li s4,1
|
||
|
li s3,1
|
||
|
.L13:
|
||
|
lw a5,0(s2)
|
||
|
mv s0,s5
|
||
|
li s1,1
|
||
|
ble a5,zero,.L16
|
||
|
.L17:
|
||
|
lw a5,0(s0)
|
||
|
li a0,46
|
||
|
bne a5,s3,.L14
|
||
|
li a0,35
|
||
|
.L14:
|
||
|
call putch@plt
|
||
|
lw a5,0(s2)
|
||
|
addiw s1,s1,1
|
||
|
addi s0,s0,4
|
||
|
bge a5,s1,.L17
|
||
|
.L16:
|
||
|
li a0,10
|
||
|
call putch@plt
|
||
|
lw a5,4(s2)
|
||
|
addiw s4,s4,1
|
||
|
addi s5,s5,2000
|
||
|
bge a5,s4,.L13
|
||
|
.L11:
|
||
|
ld ra,56(sp)
|
||
|
ld s0,48(sp)
|
||
|
ld s1,40(sp)
|
||
|
ld s2,32(sp)
|
||
|
ld s3,24(sp)
|
||
|
ld s4,16(sp)
|
||
|
ld s5,8(sp)
|
||
|
addi sp,sp,64
|
||
|
jr ra
|
||
|
.size put_map, .-put_map
|
||
|
.align 1
|
||
|
.globl swap12
|
||
|
.type swap12, @function
|
||
|
swap12:
|
||
|
lla a4,.LANCHOR0
|
||
|
lw a5,4(a4)
|
||
|
ble a5,zero,.L26
|
||
|
addi sp,sp,-48
|
||
|
sd s3,8(sp)
|
||
|
lw s3,0(a4)
|
||
|
sd ra,40(sp)
|
||
|
sd s0,32(sp)
|
||
|
sd s1,24(sp)
|
||
|
sd s2,16(sp)
|
||
|
ble s3,zero,.L21
|
||
|
addiw s2,a5,-1
|
||
|
slli s2,s2,32
|
||
|
li a5,2000
|
||
|
srli s2,s2,32
|
||
|
mul s2,s2,a5
|
||
|
slli a5,s3,32
|
||
|
srli s3,a5,30
|
||
|
lla a5,sheet1+4004
|
||
|
lla s0,sheet1+2004
|
||
|
lla s1,sheet2+2004
|
||
|
add s2,s2,a5
|
||
|
.L23:
|
||
|
mv a1,s1
|
||
|
mv a0,s0
|
||
|
mv a2,s3
|
||
|
addi s0,s0,2000
|
||
|
call memcpy@plt
|
||
|
addi s1,s1,2000
|
||
|
bne s0,s2,.L23
|
||
|
.L21:
|
||
|
ld ra,40(sp)
|
||
|
ld s0,32(sp)
|
||
|
ld s1,24(sp)
|
||
|
ld s2,16(sp)
|
||
|
ld s3,8(sp)
|
||
|
addi sp,sp,48
|
||
|
jr ra
|
||
|
.L26:
|
||
|
ret
|
||
|
.size swap12, .-swap12
|
||
|
.align 1
|
||
|
.globl step
|
||
|
.type step, @function
|
||
|
step:
|
||
|
lla a4,.LANCHOR0
|
||
|
lw a5,4(a4)
|
||
|
ble a5,zero,.L39
|
||
|
lw a4,0(a4)
|
||
|
ble a4,zero,.L39
|
||
|
addi sp,sp,-32
|
||
|
sd s1,16(sp)
|
||
|
addiw s1,a5,-1
|
||
|
slli s1,s1,32
|
||
|
li a5,2000
|
||
|
srli s1,s1,32
|
||
|
mul s1,s1,a5
|
||
|
addiw t4,a4,-1
|
||
|
slli a5,t4,32
|
||
|
srli t4,a5,30
|
||
|
sd s2,8(sp)
|
||
|
add t4,a0,t4
|
||
|
li s2,4096
|
||
|
sd s0,24(sp)
|
||
|
mv t6,a0
|
||
|
addi t4,t4,4
|
||
|
addi t2,a1,2004
|
||
|
addi s2,s2,-96
|
||
|
li t5,1
|
||
|
add s1,a0,s1
|
||
|
li s0,2
|
||
|
.L35:
|
||
|
mv t0,t6
|
||
|
addi t6,t6,2000
|
||
|
add a2,t0,s2
|
||
|
mv a0,t2
|
||
|
mv a3,t6
|
||
|
mv a4,t0
|
||
|
.L34:
|
||
|
lw a7,4(a4)
|
||
|
lw a5,0(a4)
|
||
|
lw a6,8(a4)
|
||
|
lw a1,0(a3)
|
||
|
addw a5,a5,a7
|
||
|
lw t3,8(a3)
|
||
|
addw a5,a5,a6
|
||
|
lw t1,0(a2)
|
||
|
addw a5,a5,a1
|
||
|
lw a7,4(a2)
|
||
|
lw a6,8(a2)
|
||
|
addw a5,a5,t3
|
||
|
addw a5,a5,t1
|
||
|
lw a1,4(a3)
|
||
|
addw a5,a5,a7
|
||
|
addw a5,a5,a6
|
||
|
addi a6,a5,-3
|
||
|
beq a1,t5,.L31
|
||
|
.L33:
|
||
|
seqz a1,a6
|
||
|
.L32:
|
||
|
sw a1,0(a0)
|
||
|
addi a4,a4,4
|
||
|
addi a3,a3,4
|
||
|
addi a2,a2,4
|
||
|
addi a0,a0,4
|
||
|
bne a4,t4,.L34
|
||
|
addi t4,t4,2000
|
||
|
addi t2,t2,2000
|
||
|
bne t0,s1,.L35
|
||
|
ld s0,24(sp)
|
||
|
ld s1,16(sp)
|
||
|
ld s2,8(sp)
|
||
|
addi sp,sp,32
|
||
|
jr ra
|
||
|
.L31:
|
||
|
bne a5,s0,.L33
|
||
|
j .L32
|
||
|
.L39:
|
||
|
ret
|
||
|
.size step, .-step
|
||
|
.section .text.startup,"ax",@progbits
|
||
|
.align 1
|
||
|
.globl main
|
||
|
.type main, @function
|
||
|
main:
|
||
|
addi sp,sp,-48
|
||
|
sd ra,40(sp)
|
||
|
sd s0,32(sp)
|
||
|
sd s1,24(sp)
|
||
|
sd s2,16(sp)
|
||
|
sd s3,8(sp)
|
||
|
call read_map
|
||
|
li a0,97
|
||
|
lla s2,.LANCHOR0
|
||
|
call _sysy_starttime@plt
|
||
|
lw s0,8(s2)
|
||
|
lla s1,.LANCHOR1
|
||
|
ble s0,zero,.L47
|
||
|
lw a4,0(s1)
|
||
|
li a5,1
|
||
|
beq a4,a5,.L48
|
||
|
.L46:
|
||
|
lla a1,sheet1
|
||
|
lla a0,sheet2
|
||
|
call step
|
||
|
addiw s0,s0,-1
|
||
|
li a4,1
|
||
|
sw a4,0(s1)
|
||
|
sw s0,8(s2)
|
||
|
beq s0,zero,.L47
|
||
|
.L48:
|
||
|
lla a1,sheet2
|
||
|
lla a0,sheet1
|
||
|
call step
|
||
|
addiw s0,s0,-1
|
||
|
li a4,2
|
||
|
sw a4,0(s1)
|
||
|
sw s0,8(s2)
|
||
|
bne s0,zero,.L46
|
||
|
.L47:
|
||
|
li a0,108
|
||
|
call _sysy_stoptime@plt
|
||
|
lw a4,0(s1)
|
||
|
li a5,2
|
||
|
beq a4,a5,.L55
|
||
|
.L45:
|
||
|
call put_map
|
||
|
ld ra,40(sp)
|
||
|
ld s0,32(sp)
|
||
|
ld s1,24(sp)
|
||
|
ld s2,16(sp)
|
||
|
ld s3,8(sp)
|
||
|
li a0,0
|
||
|
addi sp,sp,48
|
||
|
jr ra
|
||
|
.L55:
|
||
|
lw a5,4(s2)
|
||
|
ble a5,zero,.L45
|
||
|
lw s3,0(s2)
|
||
|
ble s3,zero,.L45
|
||
|
addiw s2,a5,-1
|
||
|
slli s2,s2,32
|
||
|
li a5,2000
|
||
|
srli s2,s2,32
|
||
|
mul s2,s2,a5
|
||
|
slli a5,s3,32
|
||
|
srli s3,a5,30
|
||
|
lla a5,sheet1+4004
|
||
|
lla s0,sheet1+2004
|
||
|
lla s1,sheet2+2004
|
||
|
add s2,s2,a5
|
||
|
.L49:
|
||
|
mv a1,s1
|
||
|
mv a0,s0
|
||
|
mv a2,s3
|
||
|
addi s0,s0,2000
|
||
|
call memcpy@plt
|
||
|
addi s1,s1,2000
|
||
|
bne s0,s2,.L49
|
||
|
j .L45
|
||
|
.size main, .-main
|
||
|
.globl steps
|
||
|
.globl height
|
||
|
.globl width
|
||
|
.globl active
|
||
|
.globl sheet2
|
||
|
.globl sheet1
|
||
|
.globl _sysy_idx
|
||
|
.globl _sysy_us
|
||
|
.globl _sysy_s
|
||
|
.globl _sysy_m
|
||
|
.globl _sysy_h
|
||
|
.globl _sysy_l2
|
||
|
.globl _sysy_l1
|
||
|
.globl _sysy_end
|
||
|
.globl _sysy_start
|
||
|
.data
|
||
|
.align 2
|
||
|
.set .LANCHOR1,. + 0
|
||
|
.type active, @object
|
||
|
.size active, 4
|
||
|
active:
|
||
|
.word 1
|
||
|
.bss
|
||
|
.align 3
|
||
|
.set .LANCHOR0,. + 0
|
||
|
.type width, @object
|
||
|
.size width, 4
|
||
|
width:
|
||
|
.zero 4
|
||
|
.type height, @object
|
||
|
.size height, 4
|
||
|
height:
|
||
|
.zero 4
|
||
|
.type steps, @object
|
||
|
.size steps, 4
|
||
|
steps:
|
||
|
.zero 4
|
||
|
.zero 4
|
||
|
.type sheet2, @object
|
||
|
.size sheet2, 1000000
|
||
|
sheet2:
|
||
|
.zero 1000000
|
||
|
.type sheet1, @object
|
||
|
.size sheet1, 1000000
|
||
|
sheet1:
|
||
|
.zero 1000000
|
||
|
.type _sysy_idx, @object
|
||
|
.size _sysy_idx, 4
|
||
|
_sysy_idx:
|
||
|
.zero 4
|
||
|
.zero 4
|
||
|
.type _sysy_us, @object
|
||
|
.size _sysy_us, 4096
|
||
|
_sysy_us:
|
||
|
.zero 4096
|
||
|
.type _sysy_s, @object
|
||
|
.size _sysy_s, 4096
|
||
|
_sysy_s:
|
||
|
.zero 4096
|
||
|
.type _sysy_m, @object
|
||
|
.size _sysy_m, 4096
|
||
|
_sysy_m:
|
||
|
.zero 4096
|
||
|
.type _sysy_h, @object
|
||
|
.size _sysy_h, 4096
|
||
|
_sysy_h:
|
||
|
.zero 4096
|
||
|
.type _sysy_l2, @object
|
||
|
.size _sysy_l2, 4096
|
||
|
_sysy_l2:
|
||
|
.zero 4096
|
||
|
.type _sysy_l1, @object
|
||
|
.size _sysy_l1, 4096
|
||
|
_sysy_l1:
|
||
|
.zero 4096
|
||
|
.type _sysy_end, @object
|
||
|
.size _sysy_end, 16
|
||
|
_sysy_end:
|
||
|
.zero 16
|
||
|
.type _sysy_start, @object
|
||
|
.size _sysy_start, 16
|
||
|
_sysy_start:
|
||
|
.zero 16
|
||
|
.ident "GCC: (Debian 12.2.0-13) 12.2.0"
|
||
|
.section .note.GNU-stack,"",@progbits
|