flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Work with chars of string in macro |
Author |
|
baldr 01 Dec 2012, 15:45
demoth,
String literal is a token, it can't be decomposed using preprocessor. Your crypting routine can be implemented using assembler directives: Code: struc crypt [def] { common local b . def repeat $-. load b from .+%-1 store b xor 10 at .+%-1 end repeat } someString crypt db "hello" db 0 |
|||
01 Dec 2012, 15:45 |
|
demoth 01 Dec 2012, 16:41
baldr, thank You!
I upgraded it: Code: struc crypt key, [def] { common local b . def repeat $-. load b from .+%-1 store b xor key at .+%-1 end repeat } macro DeclareCryptStr name, key, dat { db key name crypt key, db dat db 0 } |
|||
01 Dec 2012, 16:41 |
|
baldr 01 Dec 2012, 20:30
demoth,
It can be improved more: Code: struc reEqu [v] { common; probably «v» contains «,» match _v, v \{; save «.» value to protect it from «restore» restore . . equ _v \} match , v \{; heh, «v» is empty restore . . equ \} } struc xcrypt [def*] { common !mask equ 10; establish defaults !def equ def; unless «key=#» is used local b match =key==mask _def, !def \{ !mask reEqu mask; extract mask !def reEqu _def; and definition \} match _def, !def \{ . _def \}; guess why not plain «. !def» repeat $-. load b from $-%; now do it backward store b xor !mask at $-% end repeat restore !mask; clean up restore !def } macro xcrypt [def*] {; wrapper for unusual usage local ..label ..label xcrypt def } cryptedString xcrypt key=11 db "hello" db 0 cryptedUnicodeString xcrypt key=12 du "hello" du 0 ; Now «macro» takes its turn (label «letItBe» is optional, as you may guess) letItBe: xcrypt key=13 db "hello" db 0 Your approach somewhat limits their usefulness, and «DeclareCryptStr» looks strange (key is stored alongside with keyed string?) |
|||
01 Dec 2012, 20:30 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.