Assigning a string to a register or a variable

Started by Vortex, June 02, 2025, 08:16:30 PM

Previous topic - Next topic

Vortex

Original macro from the Masm32 package adapted to Poasm :

sas MACRO var,quoted_text:VARARG
LOCAL txtname

IFNDEF __UNICODE__

    .data
        txtname db quoted_text,0
    align 4
    .code
   
ELSE

    .data
    txtname dw quoted_text,0
    align 4
    .code

ENDIF

    mov var,OFFSET txtname

ENDM

Example :

include    sasMacro.inc

.code

start:

    sas    edx,"This is a test.", " Another test."

    invoke  StdOut,edx
    invoke  ExitProcess,0

END start
Code it... That's all...

Vortex

#1
Macros split to handle ANSI and UNICODE strings:

sas MACRO var,quoted_text:VARARG

LOCAL txtname

.data

    txtname db quoted_text,0
    align 4

.code

    mov var,OFFSET txtname

ENDM


sasw MACRO var,quoted_text:VARARG

LOCAL txtname

.data

    txtname dw quoted_text,0
    align 4

.code

    mov var,OFFSET txtname

ENDM
Code it... That's all...