         Edinburgh IMP77 Compiler - Version 8.4-2024.12.18

     1  ! Code to test %string
     2  ! Would be interesting to try %string(30) to test alignment
     3  ! Also similar test for %record (say 21 bytes per record?)
     4  %begin
 0000 C8 00 00 01                           ENTER 0000,1
     5  
     6    %routine test(%name param)         ;! ia1          ia2
 0004 EB 00                                 JMP L1001
 0006                      L1002  EQU $
 0006 C8 00 00 02                           ENTER 0000,2
     7      write(addr(param),0)  ; newline  ;! 2145833816   2145833816
 000A FF 75 08                              PUSH DWORD PTR [%EBP+8]
 000D 6A 00                                 PUSH #0
 000F E8 40 00                              CALL 'WRITE' (EXTERN 64)
 0012 83 C4 08                              ADD %ESP,#8
 0015 E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
     8      write(sizeof(param),0); newline  ;! 32           8
 0018 FF 75 0C                              PUSH DWORD PTR [%EBP+12]
 001B FF 75 08                              PUSH DWORD PTR [%EBP+8]
 001E E8 11 00                              CALL 'SIZEOF' (EXTERN 17)
 0021 83 C4 08                              ADD %ESP,#8
 0024 50                                    PUSH %EAX
 0025 6A 00                                 PUSH #0
 0027 E8 40 00                              CALL 'WRITE' (EXTERN 64)
 002A 83 C4 08                              ADD %ESP,#8
 002D E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
     9      write(typeof(param),0); newline  ;! 3            3
 0030 FF 75 0C                              PUSH DWORD PTR [%EBP+12]
 0033 FF 75 08                              PUSH DWORD PTR [%EBP+8]
 0036 E8 10 00                              CALL 'TYPEOF' (EXTERN 16)
 0039 83 C4 08                              ADD %ESP,#8
 003C 50                                    PUSH %EAX
 003D 6A 00                                 PUSH #0
 003F E8 40 00                              CALL 'WRITE' (EXTERN 64)
 0042 83 C4 08                              ADD %ESP,#8
 0045 E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
    10    %end
 0048 C9                                    LEAVE
 0049 C3                                    RET
 004A                      L1001  EQU $
    11  
    12    %string(31)%array ia1(3:5)
 004A C7 45 EC 01 00 00 00                  MOV DWORD PTR [%EBP-20],#1
 0051 C7 45 F0 03 00 00 00                  MOV DWORD PTR [%EBP-16],#3
 0058 C7 45 F4 05 00 00 00                  MOV DWORD PTR [%EBP-12],#5
 005F C7 45 F8 07 04 00 00                  MOV DWORD PTR [%EBP-8],#1031
 0066 8D 45 EC                              LEA %EAX,[%EBP-20]
 0069 50                                    PUSH %EAX
 006A E8 0A 00                              CALL '_IMPADEF' (EXTERN 10)
 006D 83 C4 04                              ADD %ESP,#4
 0070 8D 4D EC                              LEA %ECX,[%EBP-20]
 0073 89 E3                                 MOV %EBX,%ESP
 0075 29 D3                                 SUB %EBX,%EDX
 0077 89 5D E4                              MOV [%EBP-28],%EBX
 007A 89 4D E8                              MOV [%EBP-24],%ECX
 007D 01 C3                                 ADD %EBX,%EAX
 007F 89 DC                                 MOV %ESP,%EBX
    13    %string(7)%array ia2(2:4,3:6)
 0081 C7 45 CC 02 00 00 00                  MOV DWORD PTR [%EBP-52],#2
 0088 C7 45 D0 02 00 00 00                  MOV DWORD PTR [%EBP-48],#2
 008F C7 45 D4 04 00 00 00                  MOV DWORD PTR [%EBP-44],#4
 0096 C7 45 D8 03 00 00 00                  MOV DWORD PTR [%EBP-40],#3
 009D C7 45 DC 06 00 00 00                  MOV DWORD PTR [%EBP-36],#6
 00A4 C7 45 E0 07 01 00 00                  MOV DWORD PTR [%EBP-32],#263
 00AB 8D 45 CC                              LEA %EAX,[%EBP-52]
 00AE 50                                    PUSH %EAX
 00AF E8 0A 00                              CALL '_IMPADEF' (EXTERN 10)
 00B2 83 C4 04                              ADD %ESP,#4
 00B5 8D 4D CC                              LEA %ECX,[%EBP-52]
 00B8 89 E3                                 MOV %EBX,%ESP
 00BA 29 D3                                 SUB %EBX,%EDX
 00BC 89 5D C4                              MOV [%EBP-60],%EBX
 00BF 89 4D C8                              MOV [%EBP-56],%ECX
 00C2 01 C3                                 ADD %EBX,%EAX
 00C4 89 DC                                 MOV %ESP,%EBX
    14  
    15    printstring( "Testing ia1"); newline
 00C6 81 EC 00 01 00 00                     SUB %ESP,#256
 00CC 89 E0                                 MOV %EAX,%ESP
 00CE 50                                    PUSH %EAX
 00CF B8 00 00 00 00                        MOV %EAX,COT+#0
 00D4 50                                    PUSH %EAX
 00D5 68 FF 00 00 00                        PUSH #255
 00DA E8 03 00                              CALL '_IMPSTRCPY' (EXTERN 3)
 00DD 83 C4 0C                              ADD %ESP,#12
 00E0 E8 3B 00                              CALL 'PRINTSTRING' (EXTERN 59)
 00E3 81 C4 00 01 00 00                     ADD %ESP,#256
 00E9 E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
    16    write(addr(ia1),0); newline     ;! 2145833816
 00EC 8D 44 04 24                           LEA %EAX,[%ESP+4]
 00F0 8D 4D E4                              LEA %ECX,[%EBP-28]
 00F3 89 CA                                 MOV %EDX,%ECX
 00F5 89 50 04                              MOV [%EAX+4],%EDX
 00F8 89 08                                 MOV [%EAX],%ECX
 00FA 6A 00                                 PUSH #0
 00FC E8 40 00                              CALL 'WRITE' (EXTERN 64)
 00FF 83 C4 08                              ADD %ESP,#8
 0102 E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
    17    write(addr(ia1(3)),0); newline  ;! 2145833612
 0105 6A 03                                 PUSH #3
 0107 FF 75 E8                              PUSH DWORD PTR [%EBP-24]
 010A E8 09 00                              CALL '_IMPAREF' (EXTERN 9)
 010D 83 C4 08                              ADD %ESP,#8
 0110 89 C6                                 MOV %ESI,%EAX
 0112 03 75 E4                              ADD %ESI,[%EBP-28]
 0115 56                                    PUSH %ESI
 0116 6A 00                                 PUSH #0
 0118 E8 40 00                              CALL 'WRITE' (EXTERN 64)
 011B 83 C4 08                              ADD %ESP,#8
 011E E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
    18    write(sizeof(ia1),0); newline   ;! 32
 0121 FF 75 E8                              PUSH DWORD PTR [%EBP-24]
 0124 FF 75 E4                              PUSH DWORD PTR [%EBP-28]
 0127 E8 11 00                              CALL 'SIZEOF' (EXTERN 17)
 012A 83 C4 08                              ADD %ESP,#8
 012D 50                                    PUSH %EAX
 012E 6A 00                                 PUSH #0
 0130 E8 40 00                              CALL 'WRITE' (EXTERN 64)
 0133 83 C4 08                              ADD %ESP,#8
 0136 E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
    19    write(typeof(ia1),0); newline   ;! 3
 0139 FF 75 E8                              PUSH DWORD PTR [%EBP-24]
 013C FF 75 E4                              PUSH DWORD PTR [%EBP-28]
 013F E8 10 00                              CALL 'TYPEOF' (EXTERN 16)
 0142 83 C4 08                              ADD %ESP,#8
 0145 50                                    PUSH %EAX
 0146 6A 00                                 PUSH #0
 0148 E8 40 00                              CALL 'WRITE' (EXTERN 64)
 014B 83 C4 08                              ADD %ESP,#8
 014E E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
    20    test(ia1)
 0151 FF 75 E8                              PUSH DWORD PTR [%EBP-24]
 0154 FF 75 E4                              PUSH DWORD PTR [%EBP-28]
 0157 E8 00 00                              CALL 'TEST' (INTERNAL L1002 )
 015A 83 C4 08                              ADD %ESP,#8
    21  
    22    printstring( "Testing ia2"); newline
 015D 81 EC 00 01 00 00                     SUB %ESP,#256
 0163 89 E0                                 MOV %EAX,%ESP
 0165 50                                    PUSH %EAX
 0166 B8 0C 00 00 00                        MOV %EAX,COT+#12
 016B 50                                    PUSH %EAX
 016C 68 FF 00 00 00                        PUSH #255
 0171 E8 03 00                              CALL '_IMPSTRCPY' (EXTERN 3)
 0174 83 C4 0C                              ADD %ESP,#12
 0177 E8 3B 00                              CALL 'PRINTSTRING' (EXTERN 59)
 017A 81 C4 00 01 00 00                     ADD %ESP,#256
 0180 E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
    23    write(addr(ia2),0); newline      ;! 2145833816   again same as ia1
 0183 8D 44 04 24                           LEA %EAX,[%ESP+4]
 0187 8D 4D C4                              LEA %ECX,[%EBP-60]
 018A 89 CA                                 MOV %EDX,%ECX
 018C 89 50 04                              MOV [%EAX+4],%EDX
 018F 89 08                                 MOV [%EAX],%ECX
 0191 6A 00                                 PUSH #0
 0193 E8 40 00                              CALL 'WRITE' (EXTERN 64)
 0196 83 C4 08                              ADD %ESP,#8
 0199 E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
    24    write(addr(ia2(2,3)),0); newline ;! 2145833708   96 bytes past address of first element of ia1, i.e. ia1(3)
 019C 6A 02                                 PUSH #2
 019E 6A 03                                 PUSH #3
 01A0 FF 75 C8                              PUSH DWORD PTR [%EBP-56]
 01A3 E8 09 00                              CALL '_IMPAREF' (EXTERN 9)
 01A6 83 C4 0C                              ADD %ESP,#12
 01A9 89 C7                                 MOV %EDI,%EAX
 01AB 03 7D C4                              ADD %EDI,[%EBP-60]
 01AE 57                                    PUSH %EDI
 01AF 6A 00                                 PUSH #0
 01B1 E8 40 00                              CALL 'WRITE' (EXTERN 64)
 01B4 83 C4 08                              ADD %ESP,#8
 01B7 E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
    25                                      !              i.e. 3 elements of 32 bytes (%string(31)), ie complete contents of array ia1
    26    write(sizeof(ia2),0); newline    ;! 8
 01BA FF 75 C8                              PUSH DWORD PTR [%EBP-56]
 01BD FF 75 C4                              PUSH DWORD PTR [%EBP-60]
 01C0 E8 11 00                              CALL 'SIZEOF' (EXTERN 17)
 01C3 83 C4 08                              ADD %ESP,#8
 01C6 50                                    PUSH %EAX
 01C7 6A 00                                 PUSH #0
 01C9 E8 40 00                              CALL 'WRITE' (EXTERN 64)
 01CC 83 C4 08                              ADD %ESP,#8
 01CF E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
    27    write(typeof(ia2),0); newline    ;! 3
 01D2 FF 75 C8                              PUSH DWORD PTR [%EBP-56]
 01D5 FF 75 C4                              PUSH DWORD PTR [%EBP-60]
 01D8 E8 10 00                              CALL 'TYPEOF' (EXTERN 16)
 01DB 83 C4 08                              ADD %ESP,#8
 01DE 50                                    PUSH %EAX
 01DF 6A 00                                 PUSH #0
 01E1 E8 40 00                              CALL 'WRITE' (EXTERN 64)
 01E4 83 C4 08                              ADD %ESP,#8
 01E7 E8 43 00                              CALL 'NEWLINE' (EXTERN 67)
    28    test(ia2)
 01EA FF 75 C8                              PUSH DWORD PTR [%EBP-56]
 01ED FF 75 C4                              PUSH DWORD PTR [%EBP-60]
 01F0 E8 00 00                              CALL 'TEST' (INTERNAL L1002 )
 01F3 83 C4 08                              ADD %ESP,#8
    29  
    30  %endofprogram
 01F6 C9                                    LEAVE
 01F7 C3                                    RET

    34 Statements compiled



 ELF object file generated from IMP source file: '/home/gtoal/src/compilers101/new-parser/imps/tests/gtoal004.imp'
 +----------+---------------------+---------+---------+---------+------------+
 | Sections |       Symbols       | Code    | Data    | Diag    | Total size |
 +----------+----------+----------+---------+---------+---------+------------+
 |  (count) | Internal | External | (bytes) | (bytes) | (bytes) | (bytes)    |
 +----------+----------+----------+---------+---------+---------+------------+
 |       12 |        6 |       14 |     584 |      24 |      64 |        672 |
 +----------+----------+----------+---------+---------+---------+------------+


