Not frustrated enough? Too much spare time?

Started by Pelle, Yesterday at 10:09:19 AM

Previous topic - Next topic

Pelle

Well, why not try writing some ARM64 (RISC) assembly code?

Here is a small example for POASM, displaying a typical "Hello, world" message box:

NULL            equ     0
MB_OK           equ     0
EXIT_SUCCESS    equ     0

                area .rdata, data, readonly

message         dcb     "Hello, Windows on ARM64!", 0
title           dcb     "POASM test", 0

                area .text, code

                export main

                import __imp_ExitProcess
                import __imp_MessageBoxA

main            function

                stp     fp,lr,[sp,#-16]!
                mov     fp,sp

                mov     x0,NULL
                adrp    x1,message
                add     x1,x1,message
                adrp    x2,title
                add     x2,x2,title
                mov     w3,MB_OK
                adrp    x8,__imp_MessageBoxA
                ldr     x8,[x8,__imp_MessageBoxA]
                blr     x8

                mov     w0,EXIT_SUCCESS
                adrp    x8,__imp_ExitProcess
                ldr     x8,[x8,__imp_ExitProcess]
                blr     x8

                ldp     fp,lr,[sp],#16
                ret       

                endfunc

                end

The C version is just a tad shorter:

int main(void) {
  MessageBoxA(NULL, "Hello, Windows on ARM64!", "POASM test", MB_OK);
  ExitProcess(EXIT_SUCCESS);
}
/Pelle

Vortex

#1
Hi Pelle,

Thanks for the ARM64 example. I don't have a computer with an ARM processor, so not easy to the test sample. Thanks for maintaining Poasm. Yes, the C version is shorter and is looking better.
Code it... That's all...

Pelle

Quote from: Vortex on Yesterday at 09:09:29 PMThanks for the ARM64 example. I don't have a computer with an ARM processor, so not easy to the test sample. Thanks for maintaining Poasm. Yes, the C version is shorter and is looking better.
I have seen some hints on the web that Windows 11 (on X64) may be able to emulate ARM64 code (not just using the weird ARM64EC mode). I can't verify this myself since my only Windows 11 machine right now is a laptop with an ARM64 processor.
/Pelle