flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > How using store ? |
Author |
|
Tomasz Grysztar 15 Apr 2023, 09:33
If the STORE is within the same addressing space (that is: before END VIRTUAL), you can do this quite directly:
Code: virtual text db "a tion" store byte "c" at text+1 end virtual Code: virtual area:: text db "a tion" end virtual store byte "c" at area:text+1 Note: these examples apply to both fasm 1 and fasmg. For fasmg this is a legacy syntax though, the new syntax would have <"c":byte> instead of <byte "c">. |
|||
15 Apr 2023, 09:33 |
|
revolution 15 Apr 2023, 09:37
You have a bad value
Quote: store byte a "c" at hex_digits:2 ;fasm error |
|||
15 Apr 2023, 09:37 |
|
Roman 15 Apr 2023, 09:41
Thanks.
How put virtual text in data ? Code: ;section data virtual at 0 area:: text db "a tion",0 end virtual textA area ;fasm error I do this variant. Work Code: virtual at 0 area:: text db "a tion",0 end virtual textAa: rept 7 n:0 { load a byte from area:text+n store byte 'c' at area:text+1 db a } db 0 ;now textAa db 'action',0 in data section. Last edited by Roman on 15 Apr 2023, 09:55; edited 1 time in total |
|||
15 Apr 2023, 09:41 |
|
Tomasz Grysztar 15 Apr 2023, 09:55
With fasmg it could go like this:
Code: virtual at 0 area:: text db "a tion",0 area_size: end virtual load all: area_size from area:0 textA db all Code: virtual at 0 area:: text db "a tion",0 area_size: end virtual textA: repeat area_size load a byte from area:%-1 db a end repeat |
|||
15 Apr 2023, 09:55 |
|
Roman 15 Apr 2023, 09:57
Thanks.
rept not see area_size repeat see area_size |
|||
15 Apr 2023, 09:57 |
|
revolution 15 Apr 2023, 16:11
With the named virtual blocks if there is a non-numeric base we have to remember the register base when it is used later. If the load/store code is in a macro and has the "area" label passed as a parameter then it might be unknown to the macro how to correctly address the bytes.
Code: virtual at edx area:: text db "a tion",0 area_size = $-edx end virtual repeat area_size load a byte from area: edx + % - 1 ; <--- we have to know the implicit edx register base db a end repeat Code: virtual at edx area:: text db "a tion",0 end virtual repeat area:$ - area:$$ ; <--- get start and end offsets without knowing any internal details load a byte from area:$$ + % - 1 ; <--- use $$ to get the base offset that may include non-numeric components db a end repeat |
|||
15 Apr 2023, 16:11 |
|
Tomasz Grysztar 15 Apr 2023, 17:48
fasmg allows "1 metadataof area" to get the base address of the block:
Code: include 'cpu/x64.inc' virtual at edx area:: end virtual mov eax,[1 metadataof area] ; assembles to mov eax,[edx] Last edited by Tomasz Grysztar on 16 Apr 2023, 07:20; edited 1 time in total |
|||
15 Apr 2023, 17:48 |
|
Roman 15 Apr 2023, 19:55
Mini c.
How convert text number to int ? Code: macro m1 { mov al,1 } macro m2 { mov bl,2 } macro ifcmd p1,p2,pp { load a p1 from cmdout:0 if a = p2 display 13,10,'yes '#`p2 pp end if } macro valCMD { repeat 300 load a byte from area:cnt1+%-1+cnt0 if a = ';' break end if store byte a at cmdout:cnt1+%-1 display a end repeat } macro nxtcmd { store qword ' ' at cmdout:0 store qword ' ' at cmdout:8 store qword ' ' at cmdout:16 repeat area_size load a byte from area:%-1+cnt0 cnt2 = cnt0+% if a = ';' break end if end repeat cnt0 = cnt2 } macro fcmd { display 13,10 repeat area_size cnt1 = % load a byte from area:%-1+cnt0 if a = ' ' break end if store byte a at cmdout:%-1 display a end repeat } virtual at 0 area:: text1 db 'for_ 551450022;',\ 'next 44 ;',\ 'deco ; ',0 area_size: end virtual virtual at 0 cmdout:: text db 40 dup (32) cmdout_size: end virtual ;in code cnt0 = 0 fcmd valCMD ifcmd dword,'for_',m1 nxtcmd fcmd valCMD ifcmd dword,'next',m1 nxtcmd fcmd ifcmd dword,'deco',m2 |
|||
15 Apr 2023, 19:55 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.