[Info-vax] How to write "Hello, world" in x86 assembly (llvm-mc)?
Dan Cross
cross at spitfire.i.gajendra.net
Thu Nov 9 11:11:18 EST 2023
In article <60f6d6cf-92aa-4de0-9e39-a95ab630324en at googlegroups.com>,
Jake Hamby (Solid State Jake) <jake.hamby at gmail.com> wrote:
>[snip]
>
>[inherit('pascal$lib_routines', 'starlet')]
>
>program Hello;
>begin
> lib$put_output('Hello, world!');
> $exit(1)
>end.
>
>The only clue that something may be wrong with my asm directives is that ana/obj/disass shows the Pascal .OBJ file's code section as:
>
>.section $CODE$, "ax", "progbits" # EXE,SHR
>
>But my asm version, despite including the same source line, generates a file that disassembles into this:
>
>.section $CODE$, "ax", "progbits" # EXE
>
>The part after the "#" is a comment, so that's even more weird. I tried more UNIX-like section directives like ".text" and again, no
>difference. BTW, the VMS x86 disassembler treats constants as hex but doesn't include a "0x", so if you copy-and-paste the code into a
>gas-style .s file, it thinks they're octal numbers and you have to add the prefix. So I'm not surprised that there appears to be some
>round-trip issue with the disassembled section header directive not giving the same result when reassembled in llvm-mc.
>
>The VMS port of llvm-mc also doesn't recognize "$" as a reference to the current location in the source file. That's why I had to write
>"(message_end - message)" to get the string size, and not a line like:
Try `.`.
>message_len = ($ - message)
>
>When I try using "$" like that, I get "error: invalid token in expression" and "error: missing expression". Can someone please tell me what I
>need to change to generate a working minimal VMS .exe using llvm-mc?
If you can see that generated assembler from your Pascal program
I'd start by trying to assemble and link that into a working
executable, then look for differences.
- Dan C.
More information about the Info-vax
mailing list