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
/
goto2.out.bak
< prev
next >
Wrap
Text File
|
2006-03-05
|
15KB
|
864 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
.text
str39: .asciz " OK"
str38: .asciz " ERROR"
str37: .asciz " ERROR"
str36: .asciz " OK"
str35: .asciz " ERROR"
str34: .asciz " OK"
str33: .asciz "TESTING >=..."
str32: .asciz " ERROR"
str31: .asciz " OK"
str30: .asciz " OK"
str29: .asciz " ERROR"
str28: .asciz " ERROR"
str27: .asciz " OK"
str26: .asciz "TESTING <=..."
str25: .asciz " OK"
str24: .asciz " ERROR"
str23: .asciz " ERROR"
str22: .asciz " OK"
str21: .asciz " OK"
str20: .asciz " ERROR"
str19: .asciz "TESTING >..."
str18: .asciz " ERROR"
str17: .asciz " OK"
str16: .asciz " OK"
str15: .asciz " ERROR"
str14: .asciz " OK"
str13: .asciz " ERROR"
str12: .asciz "TESTING <..."
str11: .asciz " OK"
str10: .asciz " ERROR"
str9: .asciz " ERROR"
str8: .asciz " OK"
str7: .asciz "TESTING <>..."
str6: .asciz " ERROR"
str5: .asciz " OK"
str4: .asciz " OK"
str3: .asciz " ERROR"
str2: .asciz "TESTING =..."
str1: .asciz "SHOULD PRINT ALL OKS AFTER EACH TEST:"
.align 8
! MAIN...
! mainEntry
.global main
main: save %sp,-104,%sp
set display0,%o0
st %fp,[%o0]
! VAR INITIALIZATION...
! i := 1
set 1,%o0
st %o0,[%fp+-4]
! VAR INITIALIZATION...
! j := 2
set 2,%o0
st %o0,[%fp+-8]
! 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
! IF...
! if i = j goto Label_1 (integer)
ld [%fp+-4],%o0
ld [%fp+-8],%o1
cmp %o0,%o1
be Label_1
nop
! goto Label_2
ba Label_2
nop
! Label_1:
Label_1:
! THEN...
! 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
! goto Label_3
ba Label_3
nop
! Label_2:
Label_2:
! ELSE...
! WRITE STMT...
! writeString str4
sethi %hi(str4),%o0
call printf
or %o0,%lo(str4),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_3:
Label_3:
! IF...
! if i = i goto Label_4 (integer)
ld [%fp+-4],%o0
ld [%fp+-4],%o1
cmp %o0,%o1
be Label_4
nop
! goto Label_5
ba Label_5
nop
! Label_4:
Label_4:
! THEN...
! WRITE STMT...
! writeString str5
sethi %hi(str5),%o0
call printf
or %o0,%lo(str5),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_6
ba Label_6
nop
! Label_5:
Label_5:
! ELSE...
! WRITE STMT...
! writeString str6
sethi %hi(str6),%o0
call printf
or %o0,%lo(str6),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_6:
Label_6:
! WRITE STMT...
! 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
! IF...
! if i != j goto Label_7 (integer)
ld [%fp+-4],%o0
ld [%fp+-8],%o1
cmp %o0,%o1
bne Label_7
nop
! goto Label_8
ba Label_8
nop
! Label_7:
Label_7:
! THEN...
! 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
! goto Label_9
ba Label_9
nop
! Label_8:
Label_8:
! ELSE...
! WRITE STMT...
! writeString str9
sethi %hi(str9),%o0
call printf
or %o0,%lo(str9),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_9:
Label_9:
! IF...
! if i != i goto Label_10 (integer)
ld [%fp+-4],%o0
ld [%fp+-4],%o1
cmp %o0,%o1
bne Label_10
nop
! goto Label_11
ba Label_11
nop
! Label_10:
Label_10:
! THEN...
! WRITE STMT...
! writeString str10
sethi %hi(str10),%o0
call printf
or %o0,%lo(str10),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_12
ba Label_12
nop
! Label_11:
Label_11:
! ELSE...
! WRITE STMT...
! writeString str11
sethi %hi(str11),%o0
call printf
or %o0,%lo(str11),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_12:
Label_12:
! 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
! IF...
! if i < i goto Label_13 (integer)
ld [%fp+-4],%o0
ld [%fp+-4],%o1
cmp %o0,%o1
bl Label_13
nop
! goto Label_14
ba Label_14
nop
! Label_13:
Label_13:
! THEN...
! WRITE STMT...
! writeString str13
sethi %hi(str13),%o0
call printf
or %o0,%lo(str13),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_15
ba Label_15
nop
! Label_14:
Label_14:
! ELSE...
! WRITE STMT...
! writeString str14
sethi %hi(str14),%o0
call printf
or %o0,%lo(str14),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_15:
Label_15:
! IF...
! if j < i goto Label_16 (integer)
ld [%fp+-8],%o0
ld [%fp+-4],%o1
cmp %o0,%o1
bl Label_16
nop
! goto Label_17
ba Label_17
nop
! Label_16:
Label_16:
! THEN...
! WRITE STMT...
! writeString str15
sethi %hi(str15),%o0
call printf
or %o0,%lo(str15),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_18
ba Label_18
nop
! Label_17:
Label_17:
! ELSE...
! 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
! END IF...
! Label_18:
Label_18:
! IF...
! if i < j goto Label_19 (integer)
ld [%fp+-4],%o0
ld [%fp+-8],%o1
cmp %o0,%o1
bl Label_19
nop
! goto Label_20
ba Label_20
nop
! Label_19:
Label_19:
! THEN...
! WRITE STMT...
! writeString str17
sethi %hi(str17),%o0
call printf
or %o0,%lo(str17),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_21
ba Label_21
nop
! Label_20:
Label_20:
! ELSE...
! WRITE STMT...
! writeString str18
sethi %hi(str18),%o0
call printf
or %o0,%lo(str18),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_21:
Label_21:
! WRITE STMT...
! writeString str19
sethi %hi(str19),%o0
call printf
or %o0,%lo(str19),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! IF...
! if i > i goto Label_22 (integer)
ld [%fp+-4],%o0
ld [%fp+-4],%o1
cmp %o0,%o1
bg Label_22
nop
! goto Label_23
ba Label_23
nop
! Label_22:
Label_22:
! THEN...
! WRITE STMT...
! 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
! goto Label_24
ba Label_24
nop
! Label_23:
Label_23:
! ELSE...
! 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
! END IF...
! Label_24:
Label_24:
! IF...
! if j > i goto Label_25 (integer)
ld [%fp+-8],%o0
ld [%fp+-4],%o1
cmp %o0,%o1
bg Label_25
nop
! goto Label_26
ba Label_26
nop
! Label_25:
Label_25:
! THEN...
! WRITE STMT...
! writeString str22
sethi %hi(str22),%o0
call printf
or %o0,%lo(str22),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_27
ba Label_27
nop
! Label_26:
Label_26:
! ELSE...
! WRITE STMT...
! writeString str23
sethi %hi(str23),%o0
call printf
or %o0,%lo(str23),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_27:
Label_27:
! IF...
! if i > j goto Label_28 (integer)
ld [%fp+-4],%o0
ld [%fp+-8],%o1
cmp %o0,%o1
bg Label_28
nop
! goto Label_29
ba Label_29
nop
! Label_28:
Label_28:
! THEN...
! WRITE STMT...
! writeString str24
sethi %hi(str24),%o0
call printf
or %o0,%lo(str24),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_30
ba Label_30
nop
! Label_29:
Label_29:
! ELSE...
! WRITE STMT...
! writeString str25
sethi %hi(str25),%o0
call printf
or %o0,%lo(str25),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_30:
Label_30:
! WRITE STMT...
! writeString str26
sethi %hi(str26),%o0
call printf
or %o0,%lo(str26),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! IF...
! if i <= i goto Label_31 (integer)
ld [%fp+-4],%o0
ld [%fp+-4],%o1
cmp %o0,%o1
ble Label_31
nop
! goto Label_32
ba Label_32
nop
! Label_31:
Label_31:
! THEN...
! WRITE STMT...
! writeString str27
sethi %hi(str27),%o0
call printf
or %o0,%lo(str27),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_33
ba Label_33
nop
! Label_32:
Label_32:
! ELSE...
! 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
! END IF...
! Label_33:
Label_33:
! IF...
! if j <= i goto Label_34 (integer)
ld [%fp+-8],%o0
ld [%fp+-4],%o1
cmp %o0,%o1
ble Label_34
nop
! goto Label_35
ba Label_35
nop
! Label_34:
Label_34:
! THEN...
! WRITE STMT...
! writeString str29
sethi %hi(str29),%o0
call printf
or %o0,%lo(str29),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_36
ba Label_36
nop
! Label_35:
Label_35:
! ELSE...
! WRITE STMT...
! writeString str30
sethi %hi(str30),%o0
call printf
or %o0,%lo(str30),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_36:
Label_36:
! IF...
! if i <= j goto Label_37 (integer)
ld [%fp+-4],%o0
ld [%fp+-8],%o1
cmp %o0,%o1
ble Label_37
nop
! goto Label_38
ba Label_38
nop
! Label_37:
Label_37:
! THEN...
! WRITE STMT...
! writeString str31
sethi %hi(str31),%o0
call printf
or %o0,%lo(str31),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_39
ba Label_39
nop
! Label_38:
Label_38:
! ELSE...
! 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
! END IF...
! Label_39:
Label_39:
! WRITE STMT...
! writeString str33
sethi %hi(str33),%o0
call printf
or %o0,%lo(str33),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! IF...
! if i >= i goto Label_40 (integer)
ld [%fp+-4],%o0
ld [%fp+-4],%o1
cmp %o0,%o1
bge Label_40
nop
! goto Label_41
ba Label_41
nop
! Label_40:
Label_40:
! THEN...
! WRITE STMT...
! writeString str34
sethi %hi(str34),%o0
call printf
or %o0,%lo(str34),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_42
ba Label_42
nop
! Label_41:
Label_41:
! ELSE...
! WRITE STMT...
! writeString str35
sethi %hi(str35),%o0
call printf
or %o0,%lo(str35),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_42:
Label_42:
! IF...
! if j >= i goto Label_43 (integer)
ld [%fp+-8],%o0
ld [%fp+-4],%o1
cmp %o0,%o1
bge Label_43
nop
! goto Label_44
ba Label_44
nop
! Label_43:
Label_43:
! THEN...
! WRITE STMT...
! writeString str36
sethi %hi(str36),%o0
call printf
or %o0,%lo(str36),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_45
ba Label_45
nop
! Label_44:
Label_44:
! ELSE...
! WRITE STMT...
! writeString str37
sethi %hi(str37),%o0
call printf
or %o0,%lo(str37),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_45:
Label_45:
! IF...
! if i >= j goto Label_46 (integer)
ld [%fp+-4],%o0
ld [%fp+-8],%o1
cmp %o0,%o1
bge Label_46
nop
! goto Label_47
ba Label_47
nop
! Label_46:
Label_46:
! THEN...
! WRITE STMT...
! writeString str38
sethi %hi(str38),%o0
call printf
or %o0,%lo(str38),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! goto Label_48
ba Label_48
nop
! Label_47:
Label_47:
! ELSE...
! WRITE STMT...
! writeString str39
sethi %hi(str39),%o0
call printf
or %o0,%lo(str39),%o0
! writeNewline
sethi %hi(strNL),%o0
call printf
or %o0,%lo(strNL),%o0
! END IF...
! Label_48:
Label_48:
! MAIN EXIT...
! mainExit
ret
restore