[Info-vax] Native compilers

John Reagan xyzzy1959 at gmail.com
Tue Feb 22 00:27:27 EST 2022


On Monday, February 21, 2022 at 9:52:36 PM UTC-5, Craig A. Berry wrote:
> On 2/21/22 8:01 PM, John Reagan wrote: 
> > On Monday, February 21, 2022 at 2:26:44 PM UTC-5, Simon Clubley wrote: 
> >> On 2022-02-19, John Reagan <xyzz... at gmail.com> wrote: 
> >>> With all the various threads talking about compilers and such, here's a "demo" (compilers are hard to demo) of a the native Macro compiler. 
> >>> 
> >>> $ type hw.mar 
> >>> .TITLE hello 
> >>> .PSECT RDATA,NOWRT,SHR,NOPIC,NOEXE,RD,QUAD 
> >>> HI: .ASCID /Hello, World!/ 
> >>> .PSECT CODE,NOWRT,SHR,PIC,EXE,RD,QUAD 
> >>> START:: .CALL_ENTRY PRESERVE=<>,MAX_ARGS=0,HOME_ARGS=TRUE 
> >>> PUSHAQ HI 
> >>> CALLS #1,G^LIB$PUT_OUTPUT 
> >>> BLBC R0,10$ 
> >>> MOVL #SS$_NORMAL,R0 
> >>> 10$: RET 
> >>> .END START 
> >>> $ 
> >>> $ show system /noproc 
> >>> OpenVMS XG5P-H4S on node X86VMS 19-FEB-2022 13:09:56.72 Uptime 2 03:28:17 
> >>> $ write sys$output f$getsyi("arch_name") 
> >>> x86_64 
> >>> $ macro hw 
> >>> $ link hw 
> >>> $ run hw 
> >>> Hello, World! 
> >>> 
> >> Is there any chance we can have a look at the generated code for this ? 
> >> 
> >> Would be interesting to see what it looks like... 
> >> Simon. 
> >> 
> >> -- 
> >> Simon Clubley, clubley at remove_me.eisner.decus.org-Earth.UFP 
> >> Walking destinations on a map are further away than they appear. 
> > .text 
> > .cfi_sections .eh_frame 
> > .globl LIB$PUT_OUTPUT 
> > .globl SS$_NORMAL 
> > .globl ELF$TFRADR 
> > .set ELF$TFRADR, START 
> > .file 1 "DKA100:[JREAGAN]HW.MAR;2" 
> > .section CODE,"ax", at progbits 
> > .globl START 
> > .type START, at function 
> > .p2align 4, 0x90 
> > START: 
> > .cfi_startproc 
> > 
> > # Prologue code for routine START on line 5 
> > .loc 1 5 0 is_stmt 0 # DKA100:[JREAGAN]HW.MAR;2:5:0 
> > pushq %rbp # encoding: [0x55] 
> > .cfi_def_cfa_offset 16 
> > .cfi_offset %rbp, -16 
> > movq %rsp, %rbp # encoding: [0x48,0x89,0xe5] 
> > .cfi_def_cfa_register %rbp 
> > pushq %rbx # encoding: [0x53] 
> > .cfi_offset %rbx, -24 
> > pushq %r15 # encoding: [0x41,0x57] 
> > .cfi_offset %r15, -32 
> > pushq %r14 # encoding: [0x41,0x56] 
> > .cfi_offset %r14, -40 
> > pushq %r13 # encoding: [0x41,0x55] 
> > .cfi_offset %r13, -48 
> > movzbl %ah, %ebx # encoding: [0x0f,0xb6,0xdc] 
> > callq LIB$ALPHA_REG_VECTOR_BASE at PLT # encoding: [0xe8,A,A,A,A] 
> > # fixup A - offset: 1, value: LIB$ALPHA_REG_VECTOR_BASE at PLT-4, kind: FK_PCRel_4 
> > xchgq %rbx, %rax # encoding: [0x48,0x93] 
> > pushq %r12 # encoding: [0x41,0x54] 
> > .cfi_offset %r12, -56 
> > addq $-40, %rsp # encoding: [0x48,0x83,0xc4,0xd8] 
> > movl %r9d, 24(%rsp) # encoding: [0x44,0x89,0x4c,0x24,0x18] 
> > movl %r8d, 20(%rsp) # encoding: [0x44,0x89,0x44,0x24,0x14] 
> > movl %ecx, 16(%rsp) # encoding: [0x89,0x4c,0x24,0x10] 
> > movl %edx, 12(%rsp) # encoding: [0x89,0x54,0x24,0x0c] 
> > movl %esi, 8(%rsp) # encoding: [0x89,0x74,0x24,0x08] 
> > movl %edi, 4(%rsp) # encoding: [0x89,0x7c,0x24,0x04] 
> > movl %eax, (%rsp) # encoding: [0x89,0x04,0x24] 
> > movq %rsp, %r12 # encoding: [0x49,0x89,0xe4] 
> > .loc 1 5 0 prologue_end # DKA100:[JREAGAN]HW.MAR;2:5:0 
> > _$$L1: 
> > 
> > # Processing instruction PUSHAQ on line 6 
> > .loc 1 58 0 # DKA100:[JREAGAN]HW.MAR;2:58:0 
> > movq _$$PSECT_BASE3 at GOTPCREL(%rip), %r10 # encoding: [0x4c,0x8b,0x15,A,A,A,A] 
> > # fixup A - offset: 3, value: _$$PSECT_BASE3 at GOTPCREL-4, kind: reloc_riprel_4byte_movq_loa 
> > d 
> > pushq %r10 # encoding: [0x41,0x52] 
> > 
> > # Processing instruction CALLS on line 7 
> > .loc 1 59 0 # DKA100:[JREAGAN]HW.MAR;2:59:0 
> > popq %rdi # encoding: [0x5f] 
> > movq $256, %rax # encoding: [0x48,0xc7,0xc0,0x00,0x01,0x00,0x00] 
> > # imm = 0x100 
> > callq LIB$PUT_OUTPUT at PLT # encoding: [0xe8,A,A,A,A] 
> > # fixup A - offset: 1, value: LIB$PUT_OUTPUT at PLT-4, kind: FK_PCRel_4 
> > movq %rax, (%rbx) # encoding: [0x48,0x89,0x03] 
> > movq %rdx, 8(%rbx) # encoding: [0x48,0x89,0x53,0x08] 
> > 
> > # Processing instruction BLBC on line 8 
> > .loc 1 60 0 # DKA100:[JREAGAN]HW.MAR;2:60:0 
> > btq $0, (%rbx) # encoding: [0x48,0x0f,0xba,0x23,0x00] 
> > jae 5_10$ # encoding: [0x0f,0x83,A,A,A,A] 
> > # fixup A - offset: 2, value: 5_10$-4, kind: FK_PCRel_4 
> > 
> > # Processing instruction MOVL on line 9 
> > .loc 1 61 0 # DKA100:[JREAGAN]HW.MAR;2:61:0 
> > movq SS$_NORMAL at GOTPCREL(%rip), %r10 # encoding: [0x4c,0x8b,0x15,A,A,A,A] 
> > # fixup A - offset: 3, value: SS$_NORMAL at GOTPCREL-4, kind: reloc_riprel_4byte_movq_load 
> > movq %r10, (%rbx) # encoding: [0x4c,0x89,0x13] 
> > 5_10$: 
> > 
> > # Processing instruction RET on line 10 
> > .loc 1 62 0 # DKA100:[JREAGAN]HW.MAR;2:62:0 
> > _$$_0: 
> > .loc 1 62 0 epilogue_begin # DKA100:[JREAGAN]HW.MAR;2:62:0 
> > leaq -40(%rbp), %rsp # encoding: [0x48,0x8d,0x65,0xd8] 
> > andb $-2, 240(%rbx) # encoding: [0x80,0xa3,0xf0,0x00,0x00,0x00,0xfe] 
> > movq (%rbx), %rax # encoding: [0x48,0x8b,0x03] 
> > movq 8(%rbx), %rdx # encoding: [0x48,0x8b,0x53,0x08] 
> > popq %r12 # encoding: [0x41,0x5c] 
> > .cfi_restore %r12 
> > popq %r13 # encoding: [0x41,0x5d] 
> > .cfi_restore %r13 
> > popq %r14 # encoding: [0x41,0x5e] 
> > .cfi_restore %r14 
> > popq %r15 # encoding: [0x41,0x5f] 
> > .cfi_restore %r15 
> > popq %rbx # encoding: [0x5b] 
> > .cfi_restore %rbx 
> > popq %rbp # encoding: [0x5d] 
> > .cfi_restore %rbp 
> > .cfi_def_cfa %rsp, 8 
> > retq # encoding: [0xc3] 
> > _$$_2: 
> > .size START, _$$_2-START 
> > .cfi_endproc 
> > .section ". ABS .","a", at progbits 
> > .section ". BLANK .","axw", at progbits 
> > .section RDATA,"a", at progbits 
> > .type _$$PSECT_BASE3, at object 
> > _$$PSECT_BASE3: 
> > .type HI, at object 
> > HI: 
> > .short 13 
> > .byte 14 
> > .byte 1 
> > .long 0_0$ 
> > .type 0_0$, at object 
> > 0_0$: 
> > .ascii "Hello, World!" 
> > .section .note,"", at note 
> > .quad 8 
> > .quad 43 
> > .quad 1 
> > .ascii "IPF/VMS" 
> > .byte 0 
> > .ascii "19-FEB-2022 13:12" 
> > .ascii "19-FEB-2022 13:12" 
> > .ascii "HELLO" 
> > .byte 0 
> > .ascii "V1" 
> > .byte 0 
> > .p2align 3 
> > .quad 8 
> > .quad 14 
> > .quad 2 
> > .ascii "IPF/VMS" 
> > .byte 0 
> > .ascii "XMAC X6.0-109" 
> > .byte 0 
> > .p2align 3
> Cool. Now we just need MACRO-32 added as one of the source languages here: 
> 
> https://godbolt.org
I'm a Patreon of Matt's.  He runs all of his systems on AWS.  However, I doubt he'll want to spin up an OpenVMS x86 system when available.

And hosting Macro-32 on a Linux system comes with its own unique nightmare.  MLB files.  Macro has no real include file system.  You get plus-list on the DCL command and macro expansions with MLB files.  Both would be a challenge with a Linux-hosted compiler.



More information about the Info-vax mailing list