flat assembler
Message board for the users of flat assembler.

Index > Macroinstructions > du macro issue

Author
Thread Post new topic Reply to topic
murder



Joined: 03 Nov 2011
Posts: 14
murder 21 Jun 2024, 05:43
Seems du macro from encoding not work with equ. Here example (see what happens with equ_bug):
Code:
include 'encoding\win1251.inc'

equ_bug  equ 'фы','дж'
equ_fine equ 0444h,044Bh,0434h,0436h

du 'фыдж'
du equ_bug
du equ_fine    


I use equ to pass string with control symbols (e.g. new line) as macro parameter
Post 21 Jun 2024, 05:43
View user's profile Send private message Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20447
Location: In your JS exploiting you and your system
revolution 21 Jun 2024, 06:29
The "arg" parameter in the du macro needs to be deconstructed. You can use this as a replacement for win1251.inc.
Code:
rept 1 { local ..encoding
         __encoding equ ..encoding }

virtual at 0
  __encoding::
    times 80h dw %-1
    dw 401h,403h,201Ah,453h,201Eh,2026h,2020h,2021h,20ACh,2030h,409h,2039h,40Ah,40Ch,40Bh,40Fh
    dw 452h,2018h,2019h,201Ch,201Dh,2022h,2013h,2014h,?,2122h,459h,203Ah,45Ah,45Ch,45Bh,45Fh
    dw 0A0h,40Eh,45Eh,408h,0A4h,490h,0A6h,0A7h,401h,0A9h,404h,0ABh,0ACh,0ADh,0AEh,407h
    dw 0B0h,0B1h,406h,456h,491h,0B5h,0B6h,0B7h,451h,2116h,454h,0BBh,458h,405h,455h,457h
    times 40h dw 410h+%-1
end virtual

macro du [arg]
 { local offset,char
   offset = $-$$
   du arg
   match deref,arg \{ irp element,deref \\{
    if element eqtype ''
     repeat ($-offset-$$)/2
      load char byte from $$+offset+(%-1)*2
      if char > 7Fh
       load char word from __encoding:char*2
       store word char at $$+offset+(%-1)*2
      end if
     end repeat
    end if \\} \} }

struc du [args]
 { common label . word
   du args }    
Note the extra line "match deref,arg \{ irp element,deref \\{" that deconstructs the equ into its elements.
Post 21 Jun 2024, 06:29
View user's profile Send private message Visit poster's website Reply with quote
macomics



Joined: 26 Jan 2021
Posts: 1041
Location: Russia
macomics 21 Jun 2024, 06:34
WIN1251.INC
Code:
; Windows 1251

rept 1 { local ..encoding
         __encoding equ ..encoding }

virtual at 0
  __encoding::
    times 80h dw %-1
    dw 401h,403h,201Ah,453h,201Eh,2026h,2020h,2021h,20ACh,2030h,409h,2039h,40Ah,40Ch,40Bh,40Fh
    dw 452h,2018h,2019h,201Ch,201Dh,2022h,2013h,2014h,?,2122h,459h,203Ah,45Ah,45Ch,45Bh,45Fh
    dw 0A0h,40Eh,45Eh,408h,0A4h,490h,0A6h,0A7h,401h,0A9h,404h,0ABh,0ACh,0ADh,0AEh,407h
    dw 0B0h,0B1h,406h,456h,491h,0B5h,0B6h,0B7h,451h,2116h,454h,0BBh,458h,405h,455h,457h
    times 40h dw 410h+%-1
end virtual

macro du [arg]
 { local offset,char
   offset = $-$$
   du arg
   if $-offset-$$ > 0 ; arg eqtype ''
    repeat ($-offset-$$)/2
;    load char byte from $$+offset+(%-1)*2
     load char word from $$+offset+(%-1)*2
;    if char > 7Fh
     if char > 7Fh & char < 100h
      load char word from __encoding:char*2
      store word char at $$+offset+(%-1)*2
     end if
    end repeat
   end if }

struc du [args]
 { common label . word
   du args }    
Post 21 Jun 2024, 06:34
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.