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 / param2.out.bak < prev    next >
Text File  |  2006-03-05  |  4KB  |  186 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. display1:    .word    0
  103.     .text
  104. float1:    .single    0r43.21
  105. str2:    .asciz    "Should print 43.21..."
  106. str1:    .asciz    "Should print 123..."
  107.     .align    8
  108. ! MAIN...
  109. !   mainEntry
  110.     .global    main
  111. main:    save    %sp,-104,%sp
  112.     set    display0,%o0
  113.     st    %fp,[%o0]
  114. ! WRITE STMT...
  115. !   writeString str1
  116.     sethi    %hi(str1),%o0
  117.     call    printf
  118.     or    %o0,%lo(str1),%o0
  119. !   call p1_foo1
  120.     call    p1_foo1
  121.     nop
  122. !   resultTo t1
  123.     st    %o0,[%fp+-4]
  124. !   writeInt t1
  125.     ld    [%fp+-4],%o1
  126.     sethi    %hi(strInt),%o0
  127.     call    printf
  128.     or    %o0,%lo(strInt),%o0
  129. !   writeNewline
  130.     sethi    %hi(strNL),%o0
  131.     call    printf
  132.     or    %o0,%lo(strNL),%o0
  133. ! WRITE STMT...
  134. !   writeString str2
  135.     sethi    %hi(str2),%o0
  136.     call    printf
  137.     or    %o0,%lo(str2),%o0
  138. !   call p2_foo2
  139.     call    p2_foo2
  140.     nop
  141. !   resultTo t2
  142.     st    %o0,[%fp+-8]
  143. !   writeFloat t2
  144.     ld    [%fp+-8],%f0
  145.     call    writeFlt
  146.     nop
  147. !   writeNewline
  148.     sethi    %hi(strNL),%o0
  149.     call    printf
  150.     or    %o0,%lo(strNL),%o0
  151. ! MAIN EXIT...
  152. !   mainExit
  153.     ret
  154.     restore
  155. ! PROCEDURE...
  156. !   procEntry p1_foo1,lexLev=1,frameSize=96
  157. p1_foo1:    save    %sp,-96,%sp
  158.     set    display1,%o0
  159.     ld    [%o0],%o1
  160.     st    %o1,[%fp+64]
  161.     st    %fp,[%o0]
  162. ! RETURN...
  163. !   returnExpr 123
  164.     set    123,%i0
  165.     set    display1,%o0
  166.     ld    [%fp+64],%o1
  167.     st    %o1,[%o0]
  168.     ret
  169.     restore
  170. ! PROCEDURE...
  171. !   procEntry p2_foo2,lexLev=1,frameSize=96
  172. p2_foo2:    save    %sp,-96,%sp
  173.     set    display1,%o0
  174.     ld    [%o0],%o1
  175.     st    %o1,[%fp+64]
  176.     st    %fp,[%o0]
  177. ! RETURN...
  178. !   returnExpr 43.21
  179.     set    float1,%o1
  180.     ld    [%o1],%i0
  181.     set    display1,%o0
  182.     ld    [%fp+64],%o1
  183.     st    %o1,[%o0]
  184.     ret
  185.     restore
  186.