mov eax,$-TADD ("This's String length is 26")-1
macro (altered to from macros.asm to return offset)
TADD MACRO quoted_text:VARARG
LOCAL vname,lbl
jmp lbl
vname db quoted_text,0
lbl:
EXITM <offset vname>
ENDM
Firstly you have no way of referring to the string.
Secondly I do not like to use CADD because of the unnecessary jmp (use SADD and CTXT instead)
Thirdly you can do the same thing without a macro like this:
.data
szText db "Hello",0
szText_len equ $-offset szText-1
.code
mov eax,szText_len
Aero,
The value of the CADD macro an similar techniques is that it writes the text into the .CODE section rather than the .DATA section. With very small apps, this saves a data section being added and it also makes the text read only and directly embedded in the code which makes it a bit harder to hack as you cannot make the string longer.
What use do very small apps have? What is wrong with the .const section?
Try you luck building it to see if you get an extra section or not. When you put data in the code section, you don't.
.code
txt db "Tis is ascii text",0
start:
; your code etc ....
AeroASM,
what i wrote was for the .code section string len for compile time.
yes i know we can use the .data section :)
All right then do it your way (sigh)
You want a macro for this, right?
.code
jmp @F
szText db "My Text",0
szText_len equ $-offset szText
@@:
mov eax,szText_len
CSSTR macro name,value
LOCAL lbl
jmp lbl
name db value,0
name_len equ $-offset name
lbl:
CSSTR endm
.code
CSSTR szText,"My Text"
mov eax,szText_len
mov edx,offset szText
(BTW this is my first time making a macro)
Aero,
If you put data AFTER the .CODE location but BEFORE the "start" label, you don't have to jump over it. Execution starts at the "start" location label so anything before it that is in the .CODE section does not get executed, IE does not get treated as instructions.
I know, you ahve already shown me.