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 / error2.out.bak < prev    next >
Text File  |  2006-03-05  |  3KB  |  146 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. str1:    .asciz    "Should cause a pointer-is-nil message..."
  104.     .align    8
  105. ! MAIN...
  106. !   mainEntry
  107.     .global    main
  108. main:    save    %sp,-104,%sp
  109.     set    display0,%o0
  110.     st    %fp,[%o0]
  111. ! VAR INITIALIZATION...
  112. !   p := 0
  113.     set    0,%o0
  114.     st    %o0,[%fp+-4]
  115. ! VAR INITIALIZATION...
  116. !   i := 0
  117.     set    0,%o0
  118.     st    %o0,[%fp+-8]
  119. ! WRITE STMT...
  120. !   writeString str1
  121.     sethi    %hi(str1),%o0
  122.     call    printf
  123.     or    %o0,%lo(str1),%o0
  124. !   writeNewline
  125.     sethi    %hi(strNL),%o0
  126.     call    printf
  127.     or    %o0,%lo(strNL),%o0
  128. ! ASSIGNMENT STMT...
  129. !   if p = 0 goto runtimeError2        (integer)
  130.     ld    [%fp+-4],%o0
  131.     set    0,%o1
  132.     cmp    %o0,%o1
  133.     be    runtimeError2
  134.     nop
  135. !   t1 := *p
  136.     ld    [%fp+-4],%o0
  137.     ld    [%o0],%o0
  138.     st    %o0,[%fp+-12]
  139. !   i := t1
  140.     ld    [%fp+-12],%o0
  141.     st    %o0,[%fp+-8]
  142. ! MAIN EXIT...
  143. !   mainExit
  144.     ret
  145.     restore
  146.