66c9092c by Ulrich Schoepp

risc386 Simulator

1 parent 0f814cfa
Showing 69 changed files with 5004 additions and 0 deletions
.intel_syntax
.global Lmain
.type Lmain, @function
Lmain:
push %ebp
mov %ebp, %esp
mov t11, %ebx
mov t12, %esi
mov t13, %edi
L$6:
push 4
call L_halloc
add %esp, 4
mov t9, %eax
push t9
call LAA$run
add %esp, 4
mov t10, %eax
push t10
call L_println_int
add %esp, 4
mov t0, %eax
mov t1, 0
L$7:
mov %eax, t1
mov %edi, t13
mov %esi, t12
mov %ebx, t11
leave
ret
.global LAA$run
.type LAA$run, @function
LAA$run:
push %ebp
mov %ebp, %esp
mov t16, %ebx
mov t17, %esi
mov t18, %edi
L$8:
mov t3, 2
mov t15, t3
add t15, 1
mov t14, t15
sal t14, 2
push t14
call L_halloc
add %esp, 4
mov t4, %eax
mov DWORD PTR [t4], t3
mov t2, t4
add t2, 4
cmp DWORD PTR [t2-4], 0
jg L$0
L$1:
push 0
call L_raise
add %esp, 4
mov t5, %eax
L$0:
mov DWORD PTR [t2], 5
cmp DWORD PTR [t2-4], 1
jg L$2
L$3:
push 0
call L_raise
add %esp, 4
mov t6, %eax
L$2:
mov DWORD PTR [t2+4], 10
cmp DWORD PTR [t2-4], 0
jg L$4
L$5:
push 0
call L_raise
add %esp, 4
mov t7, %eax
L$4:
mov t8, DWORD PTR [t2]
L$9:
mov %eax, t8
mov %edi, t18
mov %esi, t17
mov %ebx, t16
leave
ret
.intel_syntax
.global Lmain
Lmain:
PUSH %ebp
MOV %ebp, %esp
SUB %esp, 0
L$$8:
PUSH 4
CALL L_halloc
MOV %edx, %eax
ADD %esp, 4
MOV DWORD PTR [%edx], 0
PUSH %edx
CALL LAA$run
MOV %edx, %eax
ADD %esp, 4
PUSH %edx
CALL L_println_int
MOV %edx, %eax
ADD %esp, 4
L$$0:
XOR %edx, %edx
L$$7:
MOV %eax, %edx
MOV %esp, %ebp
POP %ebp
RET
LAA$run:
PUSH %ebp
MOV %ebp, %esp
SUB %esp, 4
MOV DWORD PTR [%ebp-4], %edi
L$$10:
MOV %edi, 2
LEA %edx, DWORD PTR [%edi*4+4]
PUSH %edx
CALL L_halloc
MOV %edx, %eax
ADD %esp, 4
MOV DWORD PTR [%edx], %edi
MOV %edi, %edx
MOV %edx, 0
CMP %edx, DWORD PTR [%edi]
JGE L$$3
L$$4:
MOV DWORD PTR [%edi+4], 5
MOV %edx, 1
CMP %edx, DWORD PTR [%edi]
JGE L$$3
L$$5:
MOV DWORD PTR [%edi+8], 10
L$$2:
MOV %edx, 0
CMP %edx, DWORD PTR [%edi]
JGE L$$3
L$$6:
MOV %edx, DWORD PTR [%edi+4]
JMP L$$9
L$$3:
PUSH -17
CALL L_raise
MOV %edx, %eax
ADD %esp, 4
JMP L$$3
L$$9:
MOV %eax, %edx
MOV %edi, DWORD PTR [%ebp-4]
MOV %esp, %ebp
POP %ebp
RET
.intel_syntax
.global Lmain
.type Lmain, @function
Lmain:
push %ebp
mov %ebp, %esp
mov t19, %ebx
mov t20, %esi
mov t21, %edi
L$15:
push 12
call L_halloc
add %esp, 4
mov t15, %eax
push 10
push 5
push t15
call LA$run
add %esp, 12
mov t16, %eax
push t16
call L_println_int
add %esp, 4
mov t0, %eax
mov t1, 0
L$16:
mov %eax, t1
mov %edi, t21
mov %esi, t20
mov %ebx, t19
leave
ret
.global LA$run
.type LA$run, @function
LA$run:
push %ebp
mov %ebp, %esp
mov t36, %ebx
mov t37, %esi
mov t38, %edi
L$17:
mov t17, 4
add t17, DWORD PTR [%ebp+8]
mov t3, DWORD PTR [%ebp+16]
mov t35, t3
add t35, 1
mov t34, t35
sal t34, 2
push t34
call L_halloc
add %esp, 4
mov t4, %eax
mov DWORD PTR [t4], t3
mov t33, t4
add t33, 4
mov DWORD PTR [t17], t33
mov t2, 0
L$0:
mov t32, DWORD PTR [%ebp+16]
inc t32
cmp t2, t32
jl L$1
L$2:
mov t18, 8
add t18, DWORD PTR [%ebp+8]
mov t7, DWORD PTR [%ebp+16]
mov t31, t7
add t31, 1
mov t30, t31
sal t30, 2
push t30
call L_halloc
add %esp, 4
mov t8, %eax
mov DWORD PTR [t8], t7
mov t29, t8
add t29, 4
mov DWORD PTR [t18], t29
mov t2, 0
L$6:
mov t28, DWORD PTR [%ebp+16]
inc t28
cmp t2, t28
jl L$7
L$8:
mov t27, DWORD PTR [%ebp+8]
mov t11, DWORD PTR [t27+4]
mov t12, DWORD PTR [%ebp+16]
cmp t12, 0
jl L$14
L$12:
cmp t12, DWORD PTR [t11-4]
jl L$13
L$14:
push 0
call L_raise
add %esp, 4
mov t13, %eax
L$13:
mov t14, DWORD PTR [t12*4+t11]
jmp L$18
L$1:
mov t26, DWORD PTR [%ebp+8]
mov t5, DWORD PTR [t26+4]
cmp t2, 0
jl L$5
L$3:
cmp t2, DWORD PTR [t5-4]
jl L$4
L$5:
push 0
call L_raise
add %esp, 4
mov t6, %eax
L$4:
mov t25, t2
sal t25, 1
mov DWORD PTR [t2*4+t5], t25
inc t2
jmp L$0
L$10:
mov t24, t2
sal t24, 1
mov t23, t24
inc t23
mov DWORD PTR [t2*4+t9], t23
inc t2
jmp L$6
L$11:
push 0
call L_raise
add %esp, 4
mov t10, %eax
jmp L$10
L$7:
mov t22, DWORD PTR [%ebp+8]
mov t9, DWORD PTR [t22+8]
cmp t2, 0
jl L$11
L$9:
cmp t2, DWORD PTR [t9-4]
jl L$10
jmp L$11
L$18:
mov %eax, t14
mov %edi, t38
mov %esi, t37
mov %ebx, t36
leave
ret
.intel_syntax
.global Lmain
Lmain:
PUSH %ebp
MOV %ebp, %esp
L$$2:
L$$1:
PUSH 16
CALL L_halloc
ADD %esp, 4
L$$0:
MOV DWORD PTR [%eax], 0
PUSH 10
PUSH 5
PUSH %eax
CALL LA$run
ADD %esp, 12
PUSH %eax
CALL L_println_int
ADD %esp, 4
XOR %eax, %eax
L$$3:
L$$21:
LEAVE
RET
LA$run:
PUSH %ebp
MOV %ebp, %esp
SUB %esp, 32
L$$19:
MOV %eax, %ebx
MOV DWORD PTR [%ebp-16], %eax
XOR %eax, %eax
MOV DWORD PTR [%ebp-8], %eax
MOV %eax, DWORD PTR [%ebp+8]
ADD %eax, 12
MOV DWORD PTR [%ebp-24], %eax
MOV %ebx, DWORD PTR [%ebp+16]
LEA %eax, DWORD PTR [%ebx*4+4]
PUSH %eax
CALL L_halloc
ADD %esp, 4
MOV DWORD PTR [%eax], %ebx
MOV %ebx, DWORD PTR [%ebp-24]
MOV DWORD PTR [%ebx], %eax
XOR %eax, %eax
MOV DWORD PTR [%ebp-8], %eax
L$$7:
MOV %eax, DWORD PTR [%ebp+16]
ADD %eax, 1
MOV %ebx, DWORD PTR [%ebp-8]
CMP %ebx, %eax
JL L$$8
L$$9:
MOV %eax, DWORD PTR [%ebp+8]
ADD %eax, 8
MOV %ebx, %eax
MOV %eax, DWORD PTR [%ebp+16]
MOV DWORD PTR [%ebp-20], %eax
MOV %eax, DWORD PTR [%ebp-20]
LEA %eax, DWORD PTR [%eax*4+4]
PUSH %eax
CALL L_halloc
ADD %esp, 4
MOV %ecx, DWORD PTR [%ebp-20]
MOV DWORD PTR [%eax], %ecx
MOV DWORD PTR [%ebx], %eax
XOR %eax, %eax
MOV DWORD PTR [%ebp-8], %eax
L$$13:
MOV %ebx, DWORD PTR [%ebp+16]
ADD %ebx, 1
MOV %eax, DWORD PTR [%ebp-8]
CMP %eax, %ebx
JL L$$14
L$$15:
MOV %eax, DWORD PTR [%ebp+8]
MOV %eax, DWORD PTR [%eax+12]
MOV DWORD PTR [%ebp-28], %eax
MOV %ebx, DWORD PTR [%ebp+16]
MOV %eax, DWORD PTR [%ebp-28]
CMP %ebx, DWORD PTR [%eax]
JGE L$$17
L$$16:
CMP %ebx, 0
JL L$$17
L$$18:
MOV %eax, DWORD PTR [%ebp-28]
MOV %eax, DWORD PTR [%eax+%ebx*4+4]
L$$20:
MOV %ebx, DWORD PTR [%ebp-16]
JMP L$$22
L$$6:
MOV %eax, DWORD PTR [%ebp-8]
LEA %eax, DWORD PTR [%eax*2]
MOV %ecx, DWORD PTR [%ebp-4]
MOV DWORD PTR [%ebx+%ecx*4+4], %eax
MOV %eax, DWORD PTR [%ebp-8]
LEA %eax, DWORD PTR [%eax+1]
MOV DWORD PTR [%ebp-8], %eax
JMP L$$7
L$$5:
PUSH -17
CALL L_raise
ADD %esp, 4
JMP L$$6
L$$4:
MOV %eax, DWORD PTR [%ebp-4]
CMP %eax, 0
JL L$$5
L$$23:
JMP L$$6
L$$17:
PUSH -17
CALL L_raise
ADD %esp, 4
JMP L$$18
L$$8:
MOV %eax, DWORD PTR [%ebp+8]
MOV %ebx, DWORD PTR [%eax+12]
MOV %eax, DWORD PTR [%ebp-8]
MOV DWORD PTR [%ebp-4], %eax
MOV %eax, DWORD PTR [%ebp-4]
CMP %eax, DWORD PTR [%ebx]
JGE L$$5
L$$24:
JMP L$$4
L$$14:
MOV %eax, DWORD PTR [%ebp+8]
MOV %ebx, DWORD PTR [%eax+8]
MOV %eax, DWORD PTR [%ebp-8]
MOV DWORD PTR [%ebp-12], %eax
MOV %eax, DWORD PTR [%ebp-12]
CMP %eax, DWORD PTR [%ebx]
JGE L$$11
L$$10:
MOV %eax, DWORD PTR [%ebp-12]
CMP %eax, 0
JL L$$11
L$$12:
MOV %eax, DWORD PTR [%ebp-8]
LEA %eax, DWORD PTR [%eax*2+1]
MOV %ecx, DWORD PTR [%ebp-12]
MOV DWORD PTR [%ebx+%ecx*4+4], %eax
MOV %eax, DWORD PTR [%ebp-8]
LEA %eax, DWORD PTR [%eax+1]
MOV DWORD PTR [%ebp-8], %eax
JMP L$$13
L$$11:
PUSH -17
CALL L_raise
ADD %esp, 4
JMP L$$12
L$$22:
LEAVE
RET
.intel_syntax
.global Lmain
Lmain:
PUSH %ebp
MOV %ebp, %esp
SUB %esp, 0
L$$75:
PUSH 12
CALL L_halloc
ADD %esp, 4
MOV DWORD PTR [%eax], 0
PUSH 20
PUSH %eax
CALL LBS$Start
ADD %esp, 8
PUSH %eax
CALL L_println_int
ADD %esp, 4
L$$0:
XOR %eax, %eax
L$$74:
MOV %esp, %ebp
POP %ebp
RET
LBS$Start:
PUSH %ebp
MOV %ebp, %esp
SUB %esp, 0
L$$77:
PUSH DWORD PTR [%ebp+12]
PUSH DWORD PTR [%ebp+8]
CALL LBS$Init
ADD %esp, 8
PUSH DWORD PTR [%ebp+8]
CALL LBS$Print
ADD %esp, 4
PUSH 8
PUSH DWORD PTR [%ebp+8]
CALL LBS$Search
ADD %esp, 8
CMP %eax, 0
JNE L$$4
L$$5:
PUSH 0
CALL L_println_int
ADD %esp, 4
L$$6:
PUSH 19
PUSH DWORD PTR [%ebp+8]
CALL LBS$Search
ADD %esp, 8
CMP %eax, 0
JNE L$$7
L$$8:
PUSH 0
CALL L_println_int
ADD %esp, 4
L$$9:
PUSH 20
PUSH DWORD PTR [%ebp+8]
CALL LBS$Search
ADD %esp, 8
CMP %eax, 0
JNE L$$10
L$$11:
PUSH 0
CALL L_println_int
ADD %esp, 4
L$$12:
PUSH 21
PUSH DWORD PTR [%ebp+8]
CALL LBS$Search
ADD %esp, 8
CMP %eax, 0
JNE L$$13
L$$14:
PUSH 0
CALL L_println_int
ADD %esp, 4
L$$15:
PUSH 37
PUSH DWORD PTR [%ebp+8]
CALL LBS$Search
ADD %esp, 8
CMP %eax, 0
JNE L$$16
L$$17:
PUSH 0
CALL L_println_int
ADD %esp, 4
L$$18:
PUSH 38
PUSH DWORD PTR [%ebp+8]
CALL LBS$Search
ADD %esp, 8
CMP %eax, 0
JNE L$$19
L$$20:
PUSH 0
CALL L_println_int
ADD %esp, 4
L$$21:
PUSH 39
PUSH DWORD PTR [%ebp+8]
CALL LBS$Search
ADD %esp, 8
CMP %eax, 0
JNE L$$22
L$$23:
PUSH 0
CALL L_println_int
ADD %esp, 4
L$$24:
PUSH 50
PUSH DWORD PTR [%ebp+8]
CALL LBS$Search
ADD %esp, 8
CMP %eax, 0
JNE L$$25
L$$26:
PUSH 0
CALL L_println_int
ADD %esp, 4
L$$27:
L$$2:
MOV %eax, 999
JMP L$$76
L$$25:
PUSH 1
CALL L_println_int
ADD %esp, 4
JMP L$$27
L$$22:
PUSH 1
CALL L_println_int
ADD %esp, 4
JMP L$$24
L$$19:
PUSH 1
CALL L_println_int
ADD %esp, 4
JMP L$$21
L$$16:
PUSH 1
CALL L_println_int
ADD %esp, 4
JMP L$$18
L$$13:
PUSH 1
CALL L_println_int
ADD %esp, 4
JMP L$$15
L$$10:
PUSH 1
CALL L_println_int
ADD %esp, 4
JMP L$$12
L$$7:
PUSH 1
CALL L_println_int
ADD %esp, 4
JMP L$$9
L$$4:
PUSH 1
CALL L_println_int
ADD %esp, 4
JMP L$$6
L$$76:
MOV %esp, %ebp
POP %ebp
RET
LBS$Search:
PUSH %ebp
MOV %ebp, %esp
SUB %esp, 12
MOV DWORD PTR [%ebp-12], %esi
MOV DWORD PTR [%ebp-4], %edi
L$$79:
XOR %esi, %esi
XOR %eax, %eax
MOV %eax, DWORD PTR [%ebp+8]
ADD %eax, 4
MOV %eax, DWORD PTR [%eax]
MOV %edi, DWORD PTR [%eax]
MOV %eax, %edi
SUB %eax, 1
MOV %edi, %eax
MOV %eax, 1
MOV DWORD PTR [%ebp-8], %eax
MOV %eax, 1
L$$41:
CMP %eax, 0
JNE L$$42
L$$43:
PUSH DWORD PTR [%ebp+12]
PUSH %esi
PUSH DWORD PTR [%ebp+8]
CALL LBS$Compare
ADD %esp, 12
CMP %eax, 0
JNE L$$44
L$$45:
XOR %eax, %eax
L$$46:
L$$28:
JMP L$$78
L$$44:
MOV %eax, 1
JMP L$$46
L$$42:
MOV %eax, DWORD PTR [%ebp-8]
LEA %eax, DWORD PTR [%edi+%eax]
PUSH %eax
PUSH DWORD PTR [%ebp+8]
CALL LBS$Div
ADD %esp, 8
MOV %ecx, DWORD PTR [%ebp+8]
MOV %ecx, DWORD PTR [%ecx+4]
CMP %eax, DWORD PTR [%ecx]
JGE L$$29
L$$30:
CMP %eax, 0
JL L$$29
L$$31:
MOV %esi, DWORD PTR [%ecx+%eax*4+4]
CMP DWORD PTR [%ebp+12], %esi
JGE L$$33
L$$32:
SUB %eax, 1
MOV %edi, %eax
L$$34:
PUSH DWORD PTR [%ebp+12]
PUSH %esi
PUSH DWORD PTR [%ebp+8]
CALL LBS$Compare
ADD %esp, 12
CMP %eax, 0
JNE L$$35
L$$36:
MOV %eax, 1
L$$37:
MOV %ecx, DWORD PTR [%ebp-8]
CMP %edi, %ecx
JGE L$$39
L$$38:
XOR %eax, %eax
L$$40:
JMP L$$41
L$$39:
XOR %ecx, %ecx
JMP L$$40
L$$35:
XOR %eax, %eax
JMP L$$37
L$$33:
LEA %eax, DWORD PTR [%eax+1]
MOV DWORD PTR [%ebp-8], %eax
JMP L$$34
L$$29:
PUSH -17
CALL L_raise
ADD %esp, 4
JMP L$$29
L$$78:
MOV %esi, DWORD PTR [%ebp-12]
MOV %edi, DWORD PTR [%ebp-4]
MOV %esp, %ebp
POP %ebp
RET
LBS$Div:
PUSH %ebp
MOV %ebp, %esp
SUB %esp, 0
MOV %ecx, %edi
L$$81:
XOR %eax, %eax
XOR %edi, %edi
MOV %edx, DWORD PTR [%ebp+12]
SUB %edx, 1
L$$49:
CMP %edi, %edx
JGE L$$51
L$$50:
LEA %eax, DWORD PTR [%eax+1]
LEA %edi, DWORD PTR [%edi+2]
JMP L$$49
L$$51:
L$$47:
L$$80:
MOV %edi, %ecx
MOV %esp, %ebp
POP %ebp
RET
LBS$Compare:
PUSH %ebp
MOV %ebp, %esp
SUB %esp, 0
MOV %edx, %edi
L$$83:
XOR %eax, %eax
MOV %eax, DWORD PTR [%ebp+16]
ADD %eax, 1
MOV %ecx, %eax
MOV %eax, DWORD PTR [%ebp+12]
CMP %eax, DWORD PTR [%ebp+16]
JGE L$$58
L$$57:
XOR %eax, %eax
L$$59:
L$$52:
JMP L$$82
L$$58:
CMP DWORD PTR [%ebp+12], %ecx
JGE L$$54
L$$55:
MOV %eax, 1
L$$56:
JMP L$$59
L$$54:
XOR %eax, %eax
JMP L$$56
L$$82:
MOV %edi, %edx
MOV %esp, %ebp
POP %ebp
RET
LBS$Print:
PUSH %ebp
MOV %ebp, %esp
SUB %esp, 8
MOV DWORD PTR [%ebp-8], %ebx
L$$85:
MOV %eax, 1
MOV DWORD PTR [%ebp-4], %eax
L$$64:
MOV %ebx, DWORD PTR [%ebp+8]
MOV %eax, DWORD PTR [%ebp-4]
CMP %eax, DWORD PTR [%ebx+8]
JGE L$$66
L$$65:
MOV %eax, DWORD PTR [%ebp+8]
MOV %ebx, DWORD PTR [%eax+4]
MOV %eax, DWORD PTR [%ebp-4]
CMP %eax, DWORD PTR [%ebx]
JGE L$$61
L$$62:
CMP %eax, 0
JL L$$61
L$$63:
PUSH DWORD PTR [%ebx+%eax*4+4]
CALL L_println_int
ADD %esp, 4
MOV %eax, DWORD PTR [%ebp-4]
LEA %eax, DWORD PTR [%eax+1]
MOV DWORD PTR [%ebp-4], %eax
JMP L$$64
L$$61:
PUSH -17
CALL L_raise
ADD %esp, 4
JMP L$$61
L$$66:
PUSH 99999
CALL L_println_int
ADD %esp, 4
L$$60:
XOR %eax, %eax
L$$84:
MOV %ebx, DWORD PTR [%ebp-8]
MOV %esp, %ebp
POP %ebp
RET
LBS$Init:
PUSH %ebp
MOV %ebp, %esp
SUB %esp, 16
MOV DWORD PTR [%ebp-16], %ebx
MOV DWORD PTR [%ebp-8], %esi
L$$87:
MOV %ebx, DWORD PTR [%ebp+8]
MOV %eax, DWORD PTR [%ebp+12]
MOV DWORD PTR [%ebx+8], %eax
MOV %eax, DWORD PTR [%ebp+8]
ADD %eax, 4
MOV %esi, %eax
MOV %eax, DWORD PTR [%ebp+12]
MOV DWORD PTR [%ebp-12], %eax
MOV %eax, DWORD PTR [%ebp-12]
LEA %eax, DWORD PTR [%eax*4+4]
PUSH %eax
CALL L_halloc
ADD %esp, 4
MOV %ebx, %eax
MOV %eax, DWORD PTR [%ebp-12]
MOV DWORD PTR [%ebx], %eax
MOV DWORD PTR [%esi], %ebx
MOV %ebx, 1
MOV %eax, DWORD PTR [%ebp+8]
ADD %eax, 8
MOV %eax, DWORD PTR [%eax]
ADD %eax, 1
MOV DWORD PTR [%ebp-4], %eax
L$$71:
MOV %eax, DWORD PTR [%ebp+8]
CMP %ebx, DWORD PTR [%eax+8]
JGE L$$73
L$$72:
LEA %eax, DWORD PTR [%ebx*2]
MOV %ecx, %eax
MOV %eax, DWORD PTR [%ebp-4]
SUB %eax, 3
MOV %edx, DWORD PTR [%ebp+8]
MOV %edx, DWORD PTR [%edx+4]
CMP %ebx, DWORD PTR [%edx]
JGE L$$68
L$$69:
CMP %ebx, 0
JL L$$68
L$$70:
LEA %eax, DWORD PTR [%ecx+%eax]
MOV DWORD PTR [%edx+%ebx*4+4], %eax
LEA %eax, DWORD PTR [%ebx+1]
MOV %ebx, %eax
MOV %eax, DWORD PTR [%ebp-4]
SUB %eax, 1
MOV DWORD PTR [%ebp-4], %eax
JMP L$$71
L$$68:
PUSH -17
CALL L_raise
ADD %esp, 4
JMP L$$68
L$$73:
L$$67:
XOR %eax, %eax
L$$86:
MOV %ebx, DWORD PTR [%ebp-16]
MOV %esi, DWORD PTR [%ebp-8]
MOV %esp, %ebp
POP %ebp
RET
.intel_syntax
.global Lmain
.type Lmain, @function
Lmain:
push %ebp
mov %ebp, %esp
mov t6, %ebx
mov t7, %esi
mov t8, %edi
L$4:
push 4
call L_halloc
add %esp, 4
mov t4, %eax
push 10
push 5
push t4
call LB$run