
     1  %begin
     2  
        LINE   1 "regression-bugs-tmp/ercc-write.imp"
        BEGIN  _lev0id0 {lev=0 --> 1}

     3  %routine emaswrite(%integer value, places)
     4     !***********************************************************************
     5     !*    SIMPLE MINDED ALL IMP VERSION NOT USING STRINGS                  *
     6     !***********************************************************************
           LINE   3 "regression-bugs-tmp/ercc-write.imp"
           DEF    EMASWRITE (_lev0id0_EMASWRITE) p1=V_0082 a/tf=7 b/format=0 c/ostate=0  type=0 (<type:0>) form=7 (routine) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
              START  ( FORMAL PARAMETERS  {lev=2 --> 3, nested=0 --> 1}
                 DEF    VALUE p1=V_0083 a/tf=11 b/format=1 c/ostate=0  type=1 (integer) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
                 DEF    PLACES p1=V_0084 a/tf=11 b/format=1 c/ostate=0  type=1 (integer) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
              FINISH ) {lev=2}

     7     %string (15) %fn swrite %alias "S#SWRITE"(%integer value, places)
     8        !***********************************************************************
     9        !*    SIMPLE MINDED ALL IMP VERSION                                    *
    10        !***********************************************************************
              LINE   7 "regression-bugs-tmp/ercc-write.imp"
              ALIAS  "S#SWRITE"
              DEF    SWRITE (_lev0id0_EMASWRITE_SWRITE) p1=V_0085 a/tf=38 b/format=f c/ostate=10  type=3 (string) form=8 (function) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=1 unass=0
                 START  ( FORMAL PARAMETERS  {lev=3 --> 4, nested=0 --> 1}
                    DEF    VALUE p1=V_0086 a/tf=11 b/format=1 c/ostate=0  type=1 (integer) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
                    DEF    PLACES p1=V_0087 a/tf=11 b/format=1 c/ostate=0  type=1 (integer) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
                 FINISH ) {lev=3}

    11        %string (1) sign
                 LINE   11 "regression-bugs-tmp/ercc-write.imp"
                 DEF    SIGN p1=V_0088 a/tf=31 b/format=1 c/ostate=0  type=3 (string) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0

    12        %string (15) res
                 LINE   12 "regression-bugs-tmp/ercc-write.imp"
                 DEF    RES p1=V_0089 a/tf=31 b/format=f c/ostate=0  type=3 (string) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0

    13        %integer work, ptr
                 LINE   13 "regression-bugs-tmp/ercc-write.imp"
                 DEF    WORK p1=V_008a a/tf=11 b/format=1 c/ostate=0  type=1 (integer) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
                 DEF    PTR p1=V_008b a/tf=11 b/format=1 c/ostate=0  type=1 (integer) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0

    14        %string (1) %array ch(0 : 15)
                 LINE   14 "regression-bugs-tmp/ercc-write.imp"
                 DEF    CH p1=V_008c a/tf=3b b/format=1 c/ostate=100  type=3 (string) form=11 (array) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
                 PUSHI  #0x00000000
                 PUSHI  #0x0000000f
                 DIM    0001 0001

    15        res = ""
                 LINE   15 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   RES
                 PUSHS  ""
                 ASSVAL

    16        sign = " "
                 LINE   16 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   SIGN
                 PUSHS  " "
                 ASSVAL

    17        %if value = X'80000000' %then %start
                 LINE   17 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   VALUE
                 PUSHI  #0x80000000
                 JUMPIF # L_0004

    18           res = "-2147483548"
                 LINE   18 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   RES
                 PUSHS  "-2147483548"
                 ASSVAL

    19           res = " " . res %for ptr = 1, 1, places - 10
                 LINE   19 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   PTR
                 PUSHI  #0x00000001
                 PUSH   PLACES
                 PUSHI  #0x0000000a
                 SUB   
                 PUSHI  #0x00000001
                 FOR    L_0006
                 PUSH   RES
                 PUSHS  " "
                 PUSH   RES
                 CONCAT
                 ASSVAL
                 REPEAT L_0006
                 LOCATE L_0007

    20           %result = res
                 LINE   20 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   RES
                 RESULT

    21        %finish
                 LINE   21 "regression-bugs-tmp/ercc-write.imp"
                 LOCATE L_0004

    22        %if value = X'80000000' %then %result = "-2147483648"
                 LINE   22 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   VALUE
                 PUSHI  #0x80000000
                 JUMPIF # L_0004
                 PUSHS  "-2147483648"
                 RESULT
                 LOCATE L_0004

    23        %if value < 0 %then sign = "-" %and value = -value
                 LINE   23 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   VALUE
                 PUSHI  #0x00000000
                 JUMPIF >= L_0004
                 PUSH   SIGN
                 PUSHS  "-"
                 ASSVAL
                 PUSH   VALUE
                 PUSH   VALUE
                 NEGATE
                 ASSVAL
                 LOCATE L_0004

    24        ptr = 0
                 LINE   24 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   PTR
                 PUSHI  #0x00000000
                 ASSVAL

    25        %cycle 
                 LINE   25 "regression-bugs-tmp/ercc-write.imp"
                 LOCATE L_0003

    26           work = value // 10
                 LINE   26 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   WORK
                 PUSH   VALUE
                 PUSHI  #0x0000000a
                 QUOT  
                 ASSVAL

    27           ch(ptr) = tostring(value - 10 * work + '0')
                 LINE   27 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   CH
                 PUSH   PTR
                 ACCESS
                 PUSH   TOSTRING
                 PUSH   VALUE
                 PUSHI  #0x0000000a
                 PUSH   WORK
                 MUL   
                 SUB   
                 PUSHI  #0x00000030
                 ADD   
                 ASSPAR
                 CALL  
                 ASSVAL

    28           value = work
                 LINE   28 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   VALUE
                 PUSH   WORK
                 ASSVAL

    29           ptr = ptr + 1
                 LINE   29 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   PTR
                 PUSH   PTR
                 PUSHI  #0x00000001
                 ADD   
                 ASSVAL

    30        %repeat %until value = 0
                 LINE   30 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   VALUE
                 PUSHI  #0x00000000
                 JUMPIF = L_0004
                 REPEAT L_0003
                 LOCATE L_0004

    31        res = res . " " %for work = ptr, 1, places - 1
                 LINE   31 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   WORK
                 PUSHI  #0x00000001
                 PUSH   PLACES
                 PUSHI  #0x00000001
                 SUB   
                 PUSH   PTR
                 FOR    L_0003
                 PUSH   RES
                 PUSH   RES
                 PUSHS  " "
                 CONCAT
                 ASSVAL
                 REPEAT L_0003
                 LOCATE L_0004

    32        work = ptr - 1
                 LINE   32 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   WORK
                 PUSH   PTR
                 PUSHI  #0x00000001
                 SUB   
                 ASSVAL

    33        res = res . sign
                 LINE   33 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   RES
                 PUSH   RES
                 PUSH   SIGN
                 CONCAT
                 ASSVAL

    34        res = res . ch(ptr) %for ptr = work, -1, 0
                 LINE   34 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   PTR
                 PUSHI  #0x00000001
                 NEGATE
                 PUSHI  #0x00000000
                 PUSH   WORK
                 FOR    L_0003
                 PUSH   RES
                 PUSH   RES
                 PUSH   CH
                 PUSH   PTR
                 ACCESS
                 CONCAT
                 ASSVAL
                 REPEAT L_0003
                 LOCATE L_0004

    35        %result = res
                 LINE   35 "regression-bugs-tmp/ercc-write.imp"
                 PUSH   RES
                 RESULT

    36     %end
                 LINE   36 "regression-bugs-tmp/ercc-write.imp"
              END    _lev0id0_EMASWRITE_SWRITE {lev=3 --> 2}

    37     %integer sign, work, ptr
              LINE   37 "regression-bugs-tmp/ercc-write.imp"
              DEF    SIGN p1=V_0086 a/tf=11 b/format=1 c/ostate=0  type=1 (integer) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
              DEF    WORK p1=V_0087 a/tf=11 b/format=1 c/ostate=0  type=1 (integer) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0
              DEF    PTR p1=V_0088 a/tf=11 b/format=1 c/ostate=0  type=1 (integer) form=1 (simple) special=0 (<special:0>) linkage=0 (auto) spec=0 indirect=0 unass=0

    38     %byte %integer %array ch(0 : 15)
              LINE   38 "regression-bugs-tmp/ercc-write.imp"
              DEF    CH p1=V_0089 a/tf=1b b/format=2 c/ostate=100  type=1 (integer) form=11 (array) special=1 (byte-integer) linkage=0 (auto) spec=0 indirect=0 unass=0
              PUSHI  #0x00000000
              PUSHI  #0x0000000f
              DIM    0001 0001

    39     sign = ' '
              LINE   39 "regression-bugs-tmp/ercc-write.imp"
              PUSH   SIGN
              PUSHI  #0x00000020
              ASSVAL

    40     %if value = X'80000000' %then printstring(swrite(value, places)) %and %return
              LINE   40 "regression-bugs-tmp/ercc-write.imp"
              PUSH   VALUE
              PUSHI  #0x80000000
              JUMPIF # L_0004
              PUSH   PRINTSTRING
              PUSH   SWRITE
              PUSH   VALUE
              ASSPAR
              PUSH   PLACES
              ASSPAR
              CALL  
              ASSPAR
              CALL  
              RETURN
              LOCATE L_0004

    41     %if value < 0 %then sign = '-' %and value = -value
              LINE   41 "regression-bugs-tmp/ercc-write.imp"
              PUSH   VALUE
              PUSHI  #0x00000000
              JUMPIF >= L_0004
              PUSH   SIGN
              PUSHI  #0x0000002d
              ASSVAL
              PUSH   VALUE
              PUSH   VALUE
              NEGATE
              ASSVAL
              LOCATE L_0004

    42     ptr = 0
              LINE   42 "regression-bugs-tmp/ercc-write.imp"
              PUSH   PTR
              PUSHI  #0x00000000
              ASSVAL

    43     %cycle 
              LINE   43 "regression-bugs-tmp/ercc-write.imp"
              LOCATE L_0003

    44        work = value // 10
              LINE   44 "regression-bugs-tmp/ercc-write.imp"
              PUSH   WORK
              PUSH   VALUE
              PUSHI  #0x0000000a
              QUOT  
              ASSVAL

    45        ch(ptr) = value - 10 * work
              LINE   45 "regression-bugs-tmp/ercc-write.imp"
              PUSH   CH
              PUSH   PTR
              ACCESS
              PUSH   VALUE
              PUSHI  #0x0000000a
              PUSH   WORK
              MUL   
              SUB   
              ASSVAL

    46        value = work
              LINE   46 "regression-bugs-tmp/ercc-write.imp"
              PUSH   VALUE
              PUSH   WORK
              ASSVAL

    47        ptr = ptr + 1
              LINE   47 "regression-bugs-tmp/ercc-write.imp"
              PUSH   PTR
              PUSH   PTR
              PUSHI  #0x00000001
              ADD   
              ASSVAL

    48     %repeat %until value = 0
              LINE   48 "regression-bugs-tmp/ercc-write.imp"
              PUSH   VALUE
              PUSHI  #0x00000000
              JUMPIF = L_0004
              REPEAT L_0003
              LOCATE L_0004

    49     %if places > ptr %then spaces(places - ptr)
              LINE   49 "regression-bugs-tmp/ercc-write.imp"
              PUSH   PLACES
              PUSH   PTR
              JUMPIF <= L_0004
              PUSH   SPACES
              PUSH   PLACES
              PUSH   PTR
              SUB   
              ASSPAR
              CALL  
              LOCATE L_0004

    50     work = ptr - 1
              LINE   50 "regression-bugs-tmp/ercc-write.imp"
              PUSH   WORK
              PUSH   PTR
              PUSHI  #0x00000001
              SUB   
              ASSVAL

    51     printsymbol(sign)
              LINE   51 "regression-bugs-tmp/ercc-write.imp"
              PUSH   PRINTSYMBOL
              PUSH   SIGN
              ASSPAR
              CALL  

    52     printsymbol(ch(ptr) + '0') %for ptr = work, -1, 0
              LINE   52 "regression-bugs-tmp/ercc-write.imp"
              PUSH   PTR
              PUSHI  #0x00000001
              NEGATE
              PUSHI  #0x00000000
              PUSH   WORK
              FOR    L_0003
              PUSH   PRINTSYMBOL
              PUSH   CH
              PUSH   PTR
              ACCESS
              PUSHI  #0x00000030
              ADD   
              ASSPAR
              CALL  
              REPEAT L_0003
              LOCATE L_0004

    53  %end
    54  
              LINE   53 "regression-bugs-tmp/ercc-write.imp"
           END    _lev0id0_EMASWRITE {lev=2 --> 1}

    55  %endofprogram
           LINE   55 "regression-bugs-tmp/ercc-write.imp"
        END    _lev0id0 {lev=1 --> 0}
        END     {lev=0 --> -1}


