Pelles C forum

Assembly language => Assembly discussions => Topic started by: Vortex on June 02, 2025, 08:16:30 PM

Title: Assigning a string to a register or a variable
Post by: Vortex on June 02, 2025, 08:16:30 PM
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
Title: Re: Assigning a string to a register or a variable
Post by: Vortex on June 04, 2025, 12:23:59 PM
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