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 / goto1.out.bak < prev    next >
Text File  |  2006-03-05  |  5KB  |  248 lines

  1. !
  2. ! PCAT Compiler Version 1.0
  3. !
  4.              .global  .div
  5.              .global  .rem
  6. !
  7. ! Standard data fields
  8. !
  9.              .data
  10.              .align   8
  11. temp:        .double  0
  12.              .text
  13. strNL:       .asciz   "\n"
  14. strInt:      .asciz   "%d"
  15. strFlt:      .asciz   "%g"
  16. strTrue:     .asciz   "TRUE"
  17. strFalse:    .asciz   "FALSE"
  18. message1:    .asciz   "Execution Error: Allocation failed!\n"
  19. message2:    .asciz   "Execution Error: Pointer is NIL!\n"
  20. message3:    .asciz   "Execution Error: Read statement failed!\n"
  21. message4:    .asciz   "Execution Error: Array index is out of bounds!\n"
  22. message5:    .asciz   "Execution Error: Count is not positive in array constructor!\n"
  23.              .align   8
  24. !
  25. ! runtimeError1-5
  26. !
  27. ! Branch to one of these labels to print an error message and abort.
  28. !
  29. runtimeError1:
  30.              set      message1,%o0
  31.              call     printf
  32.              nop
  33.              call     exit
  34.              mov      1,%o0
  35. runtimeError2:
  36.              set      message2,%o0
  37.              call     printf
  38.              nop
  39.              call     exit
  40.              mov      1,%o0
  41. runtimeError3:
  42.              set      message3,%o0
  43.              call     printf
  44.              nop
  45.              call     exit
  46.              mov      1,%o0
  47. runtimeError4:
  48.              set      message4,%o0
  49.              call     printf
  50.              nop
  51.              call     exit
  52.              mov      1,%o0
  53. runtimeError5:
  54.              set      message5,%o0
  55.              call     printf
  56.              nop
  57.              call     exit
  58.              mov      1,%o0
  59. ! writeFlt
  60. !
  61. ! This routine is passed a single precision floating number in %f0.
  62. ! It prints it by calling printf.  It uses registers %f0, %f1.
  63. !
  64. writeFlt:
  65.         save    %sp,-128,%sp
  66.         fstod   %f0,%f0
  67.         set     temp,%l0
  68.         std     %f0,[%l0]
  69.         ldd     [%l0],%o0
  70.         mov     %o1,%o2
  71.         mov     %o0,%o1
  72.         set     strFlt,%o0
  73.         call    printf
  74.         nop
  75.         ret
  76.         restore
  77. ! writeBool
  78. !
  79. ! This routine is passed an integer in %i0/o0.  It prints "FALSE" if this
  80. ! integer is 0 and "TRUE" otherwise.
  81. !
  82. writeBool:
  83.         save    %sp,-128,%sp
  84.         cmp     %i0,%g0
  85.         be      printFalse
  86.         nop
  87.         set     strTrue,%o0
  88.         ba      printEnd
  89.         nop
  90. printFalse:
  91.         set     strFalse,%o0
  92. printEnd:
  93.         call    printf
  94.         nop
  95.         ret
  96.         restore
  97. !
  98. ! Additional Fields
  99. !
  100.     .data
  101. display0:    .word    0
  102.     .text
  103. str6:    .asciz    "ERROR 3"
  104. str5:    .asciz    "OK 3"
  105. str4:    .asciz    "OK 2"
  106. str3:    .asciz    "ERROR 2"
  107. str2:    .asciz    "ERROR 1"
  108. str1:    .asciz    "OK 1"
  109.     .align    8
  110. ! MAIN...
  111. !   mainEntry
  112.     .global    main
  113. main:    save    %sp,-104,%sp
  114.     set    display0,%o0
  115.     st    %fp,[%o0]
  116. ! VAR INITIALIZATION...
  117. !   f := 0
  118.     set    0,%o0
  119.     st    %o0,[%fp+-4]
  120. ! VAR INITIALIZATION...
  121. !   t := 1
  122.     set    1,%o0
  123.     st    %o0,[%fp+-8]
  124. ! IF...
  125. !   if t = 0 goto Label_2        (integer)
  126.     ld    [%fp+-8],%o0
  127.     set    0,%o1
  128.     cmp    %o0,%o1
  129.     be    Label_2
  130.     nop
  131. !   goto Label_1
  132.     ba    Label_1
  133.     nop
  134. !   Label_1:
  135. Label_1:
  136. ! THEN...
  137. ! WRITE STMT...
  138. !   writeString str1
  139.     sethi    %hi(str1),%o0
  140.     call    printf
  141.     or    %o0,%lo(str1),%o0
  142. !   writeNewline
  143.     sethi    %hi(strNL),%o0
  144.     call    printf
  145.     or    %o0,%lo(strNL),%o0
  146. !   goto Label_3
  147.     ba    Label_3
  148.     nop
  149. !   Label_2:
  150. Label_2:
  151. ! ELSE...
  152. ! WRITE STMT...
  153. !   writeString str2
  154.     sethi    %hi(str2),%o0
  155.     call    printf
  156.     or    %o0,%lo(str2),%o0
  157. !   writeNewline
  158.     sethi    %hi(strNL),%o0
  159.     call    printf
  160.     or    %o0,%lo(strNL),%o0
  161. ! END IF...
  162. !   Label_3:
  163. Label_3:
  164. ! IF...
  165. !   if f = 0 goto Label_5        (integer)
  166.     ld    [%fp+-4],%o0
  167.     set    0,%o1
  168.     cmp    %o0,%o1
  169.     be    Label_5
  170.     nop
  171. !   goto Label_4
  172.     ba    Label_4
  173.     nop
  174. !   Label_4:
  175. Label_4:
  176. ! THEN...
  177. ! WRITE STMT...
  178. !   writeString str3
  179.     sethi    %hi(str3),%o0
  180.     call    printf
  181.     or    %o0,%lo(str3),%o0
  182. !   writeNewline
  183.     sethi    %hi(strNL),%o0
  184.     call    printf
  185.     or    %o0,%lo(strNL),%o0
  186. !   goto Label_6
  187.     ba    Label_6
  188.     nop
  189. !   Label_5:
  190. Label_5:
  191. ! ELSE...
  192. ! WRITE STMT...
  193. !   writeString str4
  194.     sethi    %hi(str4),%o0
  195.     call    printf
  196.     or    %o0,%lo(str4),%o0
  197. !   writeNewline
  198.     sethi    %hi(strNL),%o0
  199.     call    printf
  200.     or    %o0,%lo(strNL),%o0
  201. ! END IF...
  202. !   Label_6:
  203. Label_6:
  204. ! IF...
  205. !   if f = f goto Label_7        (integer)
  206.     ld    [%fp+-4],%o0
  207.     ld    [%fp+-4],%o1
  208.     cmp    %o0,%o1
  209.     be    Label_7
  210.     nop
  211. !   goto Label_8
  212.     ba    Label_8
  213.     nop
  214. !   Label_7:
  215. Label_7:
  216. ! THEN...
  217. ! WRITE STMT...
  218. !   writeString str5
  219.     sethi    %hi(str5),%o0
  220.     call    printf
  221.     or    %o0,%lo(str5),%o0
  222. !   writeNewline
  223.     sethi    %hi(strNL),%o0
  224.     call    printf
  225.     or    %o0,%lo(strNL),%o0
  226. !   goto Label_9
  227.     ba    Label_9
  228.     nop
  229. !   Label_8:
  230. Label_8:
  231. ! ELSE...
  232. ! WRITE STMT...
  233. !   writeString str6
  234.     sethi    %hi(str6),%o0
  235.     call    printf
  236.     or    %o0,%lo(str6),%o0
  237. !   writeNewline
  238.     sethi    %hi(strNL),%o0
  239.     call    printf
  240.     or    %o0,%lo(strNL),%o0
  241. ! END IF...
  242. !   Label_9:
  243. Label_9:
  244. ! MAIN EXIT...
  245. !   mainExit
  246.     ret
  247.     restore
  248.