         Edinburgh IMP77 Compiler - Version 8.4

    1  %begin
    2  
    3  %routine mouseswrite(%integer n, p)
    4     %string (72) %fn itos(%integer n, p)
    5        %byte %array s(0 : 72)
    6        %integer x, sign
    7        x = 73
    8        sign = 0
    9        %if p > 0 %start
   10           sign = ' '
   11           p = 72 - p
   12        %else
   13           p = p + 73
   14        %finish
   15        p = 1 %if p <= 0
   16        %if n < 0 %start
   17           sign = '-'
   18           n = -n
   19           %if n < 0 %start
   20              !max int
   21              n = n // (-10)
   22              x = x - 1
   23              s(x) = '8'
   24           %finish
   25        %finish
   26        %cycle 
   27           x = x - 1
   28           s(x) = rem(n, 10) + '0'
   29           n = n // 10
   30        %repeat %until n = 0
   31        %if sign # 0 %start
   32           x = x - 1
   33           s(x) = sign
   34        %finish
   35        %while x > p %cycle
   36           x = x - 1
   37           s(x) = ' '
   38        %repeat
   39        x = x - 1
   40        s(x) = 72 - x
   41        %result = string(addr(s(x)))
   42     %end
   43     printstring(itos(n, p))
   44  %end
   45  %routine mousesprintfl(%real r, %integer places)
   46     %routine round(%real %name v, %integer p)
   47        %real x
   48        %return %if v = 0
   49        %if v < 0 %then x = -0.5 %else x = 0.5
   50        %cycle 
   51           p = p - 1
   52           %exit %if p < 0
   53           x = x / 10
   54        %repeat
   55        v = v + x
   56     %end
   57     %routine fraction(%real r, %integer places, %string (*) %name s)
   58        %return %if places <= 0
   59        s = s . "."
   60        %while places > 0 %cycle
   61           places = places - 1
   62           r = fracpt(r) * 10
   63           s = s . tostring(intpt(r) + '0')
   64        %repeat
   65     %end
   66     {%external} %string (64) %fn ftos(%real r, %integer p)
   67        {XOWN}%string (64) s = ""
   68        %integer exp, sym
   69        p = 7 %if p > 7
   70        %if r < 0 %then sym = '-' %and r = -r %else sym = ' '
   71        %if r = 0 %start
   72           exp = -99
   73        %else
   74           exp = 0
   75           exp = exp + 1 %and r = r / 10 %while r >= 10
   76           exp = exp - 1 %and r = r * 10 %while r < 1
   77        %finish
   78        round(r, p)
   79        exp = exp + 1 %and r = r / 10 %if r >= 10
   80        s = s . tostring(intpt(r) + '0')
   81        fraction(r, p, s)
   82        s = s . "@" . itos(exp, 0)
   83        %result = s
   84     %end
   85     printstring(ftos(r, places))
   86  %end
   87  
   88  %endofprogram
?MOUSESPRINTFL unused
?MOUSESWRITE unused

   85 Statements compiled
