flat assembler
Message board for the users of flat assembler.

Index > High Level Languages > Assembly with clang:

Author
Thread Post new topic Reply to topic
bitRAKE



Joined: 21 Jul 2003
Posts: 4043
Location: vpcmpistri
bitRAKE 30 Apr 2021, 23:11
So far I've found it very buggy - even for simple things:
Code:
.intel_syntax noprefix
.globl WinMainCRTStartup
WinMainCRTStartup:
        pop rax

        xor ecx,ecx
        lea rdx,[rip + _message]
        lea r8,[rip + _caption]
        mov r9,rcx
        call MessageBoxW

        xchg ecx,eax
        call ExitProcess
        int3

.macro wchars name:req foo:vararg
        .align 2,0
        \name :
        .irpc bar,"\foo"
        .ifnc \bar\bar,""
                .ascii "\bar"
                .byte 0
        .else # without this else cc1as generates incorrect output
                .print "\\bar"
        .endif
        .endr
        .byte 0,0
.endmacro

.data
wchars _caption Win64 assembly program
wchars _message Hello World!

# commands for the linker
.section .drectve,"yn"
.ascii  " /SUBSYSTEM:WINDOWS"
.ascii  " /DEFAULTLIB:kernel32.lib"
.ascii  " /DEFAULTLIB:user32.lib"    
Build with...
Code:
clang -cc1as -triple x86_64-pc-windows-msvc19.28.29910 -filetype obj -o thisfile.obj thisfile.s
lld-link -out:thisfile.exe thisfile.obj    
I'm kind of leery about trying anything more challenging. There doesn't appear to be a directive to output wide chars, or any UTF-8 support of any kind. All strings must be escapable ASCII - otherwise they are interpreted as symbols.

_________________
¯\(°_o)/¯ “languages are not safe - uses can be” Bjarne Stroustrup
Post 30 Apr 2021, 23:11
View user's profile Send private message Visit poster's website Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.