flat assembler
Message board for the users of flat assembler.

Index > Compiler Internals > bug report: dd has potential to delete unrelated labels

Author
Thread Post new topic Reply to topic
BAiC



Joined: 22 Mar 2011
Posts: 272
Location: California
BAiC 04 Jul 2012, 01:44
while increasing the usability of a macro I discovered that "dd" appears to delete (or block from creation) random labels. The code I'll upload was tested on the current version (1.70.03) as of today. here is a piece of the code:

line:411 of PsuedoInstructions.asm:
Code:
if lab < 8
        
        mov eax, dst
        db 0xB8+lab;mov eax
        dd dst ;       , label
        
        ali 2,8
        db 0xFF  ;cal
        db 0xD0+lab;    rax
        
    else
    
        db 0x41
        db 0xB8+(lab and 7);mov eax
        dd dst ;       , label
        
        ali 3,8
        db 0x41
        db 0xFF  ;cal
        db 0xD0+(lab and 7);    rax
        
end if    
removal of the "dd dst" causes the compile to succeed (though the code won't execute properly). for my particular situation I have a workaround (modifying the output of "mov eax, dst" using load/store).


Description: this is the current working version (includes workaround)
Download
Filename: Mathis2012July3.zip
Filesize: 410.68 KB
Downloaded: 503 Time(s)

Description: this fails to compile due to a "missing" label.
Download
Filename: Mathis_dd_problem.zip
Filesize: 384.23 KB
Downloaded: 482 Time(s)

Post 04 Jul 2012, 01:44
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 04 Jul 2012, 02:12
The problem is here:
Code:
    struc  ORB.Instigate 
    {
        ORB.Fx.Header .
        dd ORB.Instigate; last link.    
You are redefining 'dd' as a structure.
Post 04 Jul 2012, 02:12
View user's profile Send private message Visit poster's website Reply with quote
revolution
When all else fails, read the source


Joined: 24 Aug 2004
Posts: 20430
Location: In your JS exploiting you and your system
revolution 04 Jul 2012, 07:30
There are some things to take note of with structures and macros:
Code:
mac1=3
mac2=4

macro mac1 [x] {display '1'}
struc mac2 [x] {.#z: display '2'}

mac1 mac2 ;displays '1'

dd mac1   ;generates a dword in the output file
dd mac2 ;displays '2'    
Notice that dd has now been interpreted as a structure label in the final line above.

But note the difference in how the order of definitions changes things:
Code:
macro mac1 [x] {display '1'}
struc mac2 [x] {.#z: display '2'}

mac1=3             ;displays '1'
mac2=4               ;defines mac2 as value of 4. The structure above still exists

mac1 mac2  ;displays '1'

;dd mac1 ;error: undefined symbol 'mac1'
dd mac2                ;displays '2'

if 4=mac2        ;check the value of 4
 display '3' ;displays '3', the comparison is true
end if

if mac2=22     ;displays '2', this is a structure definition for 'if'
 display '4'    ;displays '4' because the 'if' is not a executed
;end if         ;error: unexpected instruction    
Post 04 Jul 2012, 07:30
View user's profile Send private message Visit poster's website 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-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.