flat assembler
Message board for the users of flat assembler.
![]() |
Author |
|
bitRAKE
In fasmg:
Code: macro T H* eval "dbx (lengthof `H)/2:0x",`H end macro T 2353657474696E67730D0A0923566F6C T 756D650D0A09094576616C3A20464C65 T 76656C3D Last edited by bitRAKE on 21 Jul 2020, 04:37; edited 1 time in total |
|||
![]() |
|
revolution
How is your data stored? In the source file, or on a separate file?
Code: virtual at 0 file "my_hex_data.hex" my_data:: ;do your ASCII to binary decoding here while ... ;.. end while end virtual |
|||
![]() |
|
bitRAKE
I should have said the macro assumes big endian. Using BWAP we can produce little endian - which is more common.
Code: macro t H* B = (lengthof `H)/2 eval "dbx B:0x",`H," bswap B" end macro t 2353657474696E67730D0A0923566F6C t 756D650D0A09094576616C3A20464C65 t 76656C3D |
|||
![]() |
|
Overclick
Data is an ASCII file which I want to put into my program as file buffer to write that file later. Some parts of this buffer should be modificated. I convert it to HEX, don't I need that?
Code: buff_point equ $ T 2353657474696E67730D0A0923566F6C T 756D650D0A09094576616C3A20464C65 T 76656C3D value_point equ $ T ... T ... buff_end equ $ db 0 I don't use fasmg as I don't know enough about it. There is no IDE editor for example. Is any chance to make fasm macro with the same functionality? |
|||
![]() |
|
revolution
Unrelated but important. Use equals =, not equ. equ is textual replacement so it always expands to current address where it is used, not the address where it was defined.
Overclick wrote: I don't use fasmg as I don't know enough about it. There is no IDE editor for example. |
|||
![]() |
|
Overclick
revolution wrote: Unrelated but important. Use equals = Got it, thanks About your post: You mean to copy-paste some huge massives of data or inklude files, but I was looking for some simple way, short one, to see and quickly edit HEX too. Macro above is an ideal way for me, just help me with that macro for fasm |
|||
![]() |
|
revolution
file will include the raw hex for you. No need to copy/paste. That is why I asked how your data was stored.
|
|||
![]() |
|
Overclick
I need to set up 100+ value points on it. In this way I need to use "file" 100+ times separatelly
|
|||
![]() |
|
revolution
Not sure if this will work. Try it;
Code: macro byteify hash { local ..hash,..length virtual at 0 ..hash:: db hash ..length = $/2 end virtual while % <= ..length load b_1 byte from ..hash:(%-1)*2 load b_2 byte from ..hash:(%-1)*2+1 if b_1 > '9' b_1 = b_1 - 'A' + 10 else b_1 = b_1 - '0' end if if b_2 > '9' b_2 = b_2 - 'A' + 10 else b_2 = b_2 - '0' end if db b_1 shl 4 + b_2 end while } byteify "2353657474696E67730D0A0923566F6C" |
|||
![]() |
|
Overclick
Seems it works thanks
|
||||||||||
![]() |
|
Overclick
little upgrade for your macro
Code: ..hash:: db `hash Allows it to use without quotes |
|||
![]() |
|
revolution
Also, if it is "too slow" you could replace the /2 with shr 1.
|
|||
![]() |
|
Overclick
Why fasm doesn't allow to use # to stick numeric value? Is there any another trick/macro to make it possible? I understand assembler doesn't sure what exactly value should be, but it can make some memory space where programmer could stick it for own riscs. Am I right?
For example: I have defined names as ID100, ID101 etc. I wish to stic ID with number to reach it, simple, why not? Also I understand variable names needed just for assembling/coding, but what if I save this names in memory by myself? Ok, it's different situation then let's see your macro. It simply works with decimal values but heximal where it needs just one mark "h" to go. |
|||
![]() |
|
revolution
String manipulation in macros is tricky. It can be done, but it is usually more trouble than alternatives.
Show your use case, perhaps there is a better way. |
|||
![]() |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2020, Tomasz Grysztar. Also on GitHub, YouTube, Twitter.
Website powered by rwasa.