home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
ftp.ee.pdx.edu
/
2014.02.ftp.ee.pdx.edu.tar
/
ftp.ee.pdx.edu
/
pub
/
users
/
Harry
/
compilers
/
p11
/
tst
/
param3.out.bak
< prev
next >
Wrap
Text File
|
2006-03-05
|
12KB
|
612 lines
!
! PCAT Compiler Version 1.0
!
.global .div
.global .rem
!
! Standard data fields
!
.data
.align 8
temp: .double 0
.text
strNL: .asciz "\n"
strInt: .asciz "%d"
strFlt: .asciz "%g"
strTrue: .asciz "TRUE"
strFalse: .asciz "FALSE"
message1: .asciz "Execution Error: Allocation failed!\n"
message2: .asciz "Execution Error: Pointer is NIL!\n"
message3: .asciz "Execution Error: Read statement failed!\n"
message4: .asciz "Execution Error: Array index is out of bounds!\n"
message5: .asciz "Execution Error: Count is not positive in array constructor!\n"
.align 8
!
! runtimeError1-5
!
! Branch to one of these labels to print an error message and abort.
!
runtimeError1:
set message1,%o0
call printf
nop
call exit
mov 1,%o0
runtimeError2:
set message2,%o0
call printf
nop
call exit
mov 1,%o0
runtimeError3:
set message3,%o0
call printf
nop
call exit
mov 1,%o0
runtimeError4:
set message4,%o0
call printf
nop
call exit
mov 1,%o0
runtimeError5:
set message5,%o0
call printf
nop
call exit
mov 1,%o0
! writeFlt
!
! This routine is passed a single precision floating number in %f0.
! It prints it by calling printf. It uses registers %f0, %f1.
!
writeFlt:
save %sp,-128,%sp
fstod %f0,%f0
set temp,%l0
std %f0,[%l0]
ldd [%l0],%o0
mov %o1,%o2
mov %o0,%o1
set strFlt,%o0
call printf
nop
ret
restore
! writeBool
!
! This routine is passed an integer in %i0/o0. It prints "FALSE" if this
! integer is 0 and "TRUE" otherwise.
!
writeBool:
save %sp,-128,%sp
cmp %i0,%g0
be printFalse
nop
set strTrue,%o0
ba printEnd
nop
printFalse:
set strFalse,%o0
printEnd:
call printf
nop
ret
restore
!
! Additional Fields
!
.data
display0: .word 0
display1: .word 0
display2: .word 0
.text
str32: .asciz " Leaving foo2"
str31: .asciz ", z1="
str30: .asciz ", y1="
str29: .asciz " Non-locals: x1="
str28: .asciz " Adding 1000 to non-locals..."
str27: .asciz ", z1="
str26: .asciz ", y1="
str25: .asciz " Non-locals: x1="
str24: .asciz ", z2="
str23: .asciz ", y2="
str22: .asciz " Locals: x2="
str21: .asciz " Adding 1000 to locals..."
str20: .asciz " )"
str19: .asciz ", z2="
str18: .asciz ", y2="
str17: .asciz " Entering foo2 ( x2="
str16: .asciz " Leaving foo1"
str15: .asciz ", z1="
str14: .asciz ", y1="
str13: .asciz " Locals within foo1: x1="
str12: .asciz " Calling foo2 (301,302,303)"
str11: .asciz ", z1="
str10: .asciz ", y1="
str9: .asciz " Locals within foo1: x1="
str8: .asciz " Calling foo2 (201,202,203)"
str7: .asciz " )"
str6: .asciz ", z1="
str5: .asciz ", y1="
str4: .asciz " Entering foo1 ( x1="
str3: .asciz "Leaving main"
str2: .asciz "Calling foo1 (101,102,103)"
str1: .asciz "Within main..."
.align 8
! MAIN...
! mainEntry
.global main
main: save %sp,-96,%sp
set display0,%o0
st %fp,[%o0]
! WRITE STMT...
! writeString str1
sethi %hi(str1),%o0
call printf
or %o0,%lo(str1),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! WRITE STMT...
! writeString str2
sethi %hi(str2),%o0
call printf
or %o0,%lo(str2),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! CALL STMT...
! param 1,101
set 101,%o0
st %o0,[%sp+68]
! param 2,102
set 102,%o0
st %o0,[%sp+72]
! param 3,103
set 103,%o0
st %o0,[%sp+76]
! call p1_foo1
call p1_foo1
nop
! WRITE STMT...
! writeString str3
sethi %hi(str3),%o0
call printf
or %o0,%lo(str3),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! MAIN EXIT...
! mainExit
ret
restore
! PROCEDURE...
! procEntry p1_foo1,lexLev=1,frameSize=96
p1_foo1: save %sp,-96,%sp
set display1,%o0
ld [%o0],%o1
st %o1,[%fp+64]
st %fp,[%o0]
! formal 1,x1
! formal 2,y1
! formal 3,z1
! WRITE STMT...
! writeString str4
sethi %hi(str4),%o0
call printf
or %o0,%lo(str4),%o0
! writeInt x1
ld [%fp+68],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str5
sethi %hi(str5),%o0
call printf
or %o0,%lo(str5),%o0
! writeInt y1
ld [%fp+72],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str6
sethi %hi(str6),%o0
call printf
or %o0,%lo(str6),%o0
! writeInt z1
ld [%fp+76],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str7
sethi %hi(str7),%o0
call printf
or %o0,%lo(str7),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! WRITE STMT...
! writeString str8
sethi %hi(str8),%o0
call printf
or %o0,%lo(str8),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! CALL STMT...
! param 1,201
set 201,%o0
st %o0,[%sp+68]
! param 2,202
set 202,%o0
st %o0,[%sp+72]
! param 3,203
set 203,%o0
st %o0,[%sp+76]
! call p2_foo2
call p2_foo2
nop
! WRITE STMT...
! writeString str9
sethi %hi(str9),%o0
call printf
or %o0,%lo(str9),%o0
! writeInt x1
ld [%fp+68],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str10
sethi %hi(str10),%o0
call printf
or %o0,%lo(str10),%o0
! writeInt y1
ld [%fp+72],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str11
sethi %hi(str11),%o0
call printf
or %o0,%lo(str11),%o0
! writeInt z1
ld [%fp+76],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! WRITE STMT...
! writeString str12
sethi %hi(str12),%o0
call printf
or %o0,%lo(str12),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! CALL STMT...
! param 1,301
set 301,%o0
st %o0,[%sp+68]
! param 2,302
set 302,%o0
st %o0,[%sp+72]
! param 3,303
set 303,%o0
st %o0,[%sp+76]
! call p2_foo2
call p2_foo2
nop
! WRITE STMT...
! writeString str13
sethi %hi(str13),%o0
call printf
or %o0,%lo(str13),%o0
! writeInt x1
ld [%fp+68],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str14
sethi %hi(str14),%o0
call printf
or %o0,%lo(str14),%o0
! writeInt y1
ld [%fp+72],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str15
sethi %hi(str15),%o0
call printf
or %o0,%lo(str15),%o0
! writeInt z1
ld [%fp+76],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! WRITE STMT...
! writeString str16
sethi %hi(str16),%o0
call printf
or %o0,%lo(str16),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! RETURN...
! returnVoid
set display1,%o0
ld [%fp+64],%o1
st %o1,[%o0]
ret
restore
! PROCEDURE...
! procEntry p2_foo2,lexLev=2,frameSize=120
p2_foo2: save %sp,-120,%sp
set display2,%o0
ld [%o0],%o1
st %o1,[%fp+64]
st %fp,[%o0]
! formal 1,x2
! formal 2,y2
! formal 3,z2
! WRITE STMT...
! writeString str17
sethi %hi(str17),%o0
call printf
or %o0,%lo(str17),%o0
! writeInt x2
ld [%fp+68],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str18
sethi %hi(str18),%o0
call printf
or %o0,%lo(str18),%o0
! writeInt y2
ld [%fp+72],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str19
sethi %hi(str19),%o0
call printf
or %o0,%lo(str19),%o0
! writeInt z2
ld [%fp+76],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str20
sethi %hi(str20),%o0
call printf
or %o0,%lo(str20),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! WRITE STMT...
! writeString str21
sethi %hi(str21),%o0
call printf
or %o0,%lo(str21),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! ASSIGNMENT STMT...
! t1 := 1000 + x2 (integer)
set 1000,%o0
ld [%fp+68],%o1
add %o0,%o1,%o1
st %o1,[%fp+-4]
! x2 := t1
ld [%fp+-4],%o0
st %o0,[%fp+68]
! ASSIGNMENT STMT...
! t2 := 1000 + y2 (integer)
set 1000,%o0
ld [%fp+72],%o1
add %o0,%o1,%o1
st %o1,[%fp+-8]
! y2 := t2
ld [%fp+-8],%o0
st %o0,[%fp+72]
! ASSIGNMENT STMT...
! t3 := 1000 + z2 (integer)
set 1000,%o0
ld [%fp+76],%o1
add %o0,%o1,%o1
st %o1,[%fp+-12]
! z2 := t3
ld [%fp+-12],%o0
st %o0,[%fp+76]
! WRITE STMT...
! writeString str22
sethi %hi(str22),%o0
call printf
or %o0,%lo(str22),%o0
! writeInt x2
ld [%fp+68],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str23
sethi %hi(str23),%o0
call printf
or %o0,%lo(str23),%o0
! writeInt y2
ld [%fp+72],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str24
sethi %hi(str24),%o0
call printf
or %o0,%lo(str24),%o0
! writeInt z2
ld [%fp+76],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! WRITE STMT...
! writeString str25
sethi %hi(str25),%o0
call printf
or %o0,%lo(str25),%o0
! writeInt x1
set display1,%o1
ld [%o1],%o1
ld [%o1+68],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str26
sethi %hi(str26),%o0
call printf
or %o0,%lo(str26),%o0
! writeInt y1
set display1,%o1
ld [%o1],%o1
ld [%o1+72],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str27
sethi %hi(str27),%o0
call printf
or %o0,%lo(str27),%o0
! writeInt z1
set display1,%o1
ld [%o1],%o1
ld [%o1+76],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! WRITE STMT...
! writeString str28
sethi %hi(str28),%o0
call printf
or %o0,%lo(str28),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! ASSIGNMENT STMT...
! t4 := 1000 + x1 (integer)
set 1000,%o0
set display1,%o1
ld [%o1],%o1
ld [%o1+68],%o1
add %o0,%o1,%o1
st %o1,[%fp+-16]
! x1 := t4
ld [%fp+-16],%o0
set display1,%o1
ld [%o1],%o1
st %o0,[%o1+68]
! ASSIGNMENT STMT...
! t5 := 1000 + y1 (integer)
set 1000,%o0
set display1,%o1
ld [%o1],%o1
ld [%o1+72],%o1
add %o0,%o1,%o1
st %o1,[%fp+-20]
! y1 := t5
ld [%fp+-20],%o0
set display1,%o1
ld [%o1],%o1
st %o0,[%o1+72]
! ASSIGNMENT STMT...
! t6 := 1000 + z1 (integer)
set 1000,%o0
set display1,%o1
ld [%o1],%o1
ld [%o1+76],%o1
add %o0,%o1,%o1
st %o1,[%fp+-24]
! z1 := t6
ld [%fp+-24],%o0
set display1,%o1
ld [%o1],%o1
st %o0,[%o1+76]
! WRITE STMT...
! writeString str29
sethi %hi(str29),%o0
call printf
or %o0,%lo(str29),%o0
! writeInt x1
set display1,%o1
ld [%o1],%o1
ld [%o1+68],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str30
sethi %hi(str30),%o0
call printf
or %o0,%lo(str30),%o0
! writeInt y1
set display1,%o1
ld [%o1],%o1
ld [%o1+72],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeString str31
sethi %hi(str31),%o0
call printf
or %o0,%lo(str31),%o0
! writeInt z1
set display1,%o1
ld [%o1],%o1
ld [%o1+76],%o1
sethi %hi(strInt),%o0
call printf
or %o0,%lo(strInt),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! WRITE STMT...
! writeString str32
sethi %hi(str32),%o0
call printf
or %o0,%lo(str32),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! RETURN...
! returnVoid
set display2,%o0
ld [%fp+64],%o1
st %o1,[%o0]
ret
restore