flat assembler
Message board for the users of flat assembler.
  
       
      Index
      > Main > Weird code problem | 
  
| Author | 
  | 
              
| 
                  
                   LocoDelAssembly 15 Aug 2007, 01:39 
                  With "AND_______________________" commented compiles for me.
 
                  
                Which version are you using? The mine is 1.67.22  | 
              |||
                  
  | 
              
| 
                  
                   shism2 15 Aug 2007, 02:08 
                  No no no.... The and I put in their intentionally.... I wanted to know the difference between the two...
 
                  
                mov dword [ebx-1],-1 cmp eax,320 ret db 0dbh AND mov dword [dword ebx-1],-1 ; Why does this compile ? cmp eax,320 ret db 0dbh  | 
              |||
                  
  | 
              
| 
                  
                   r22 15 Aug 2007, 03:35 
                  mov dword [dword ebx-1],-1
 
                  
                It compiles because it's technically correct. The [dword denotes that the address inside is a DWORD address which is true (being 32bit and all). Replace mov dword [dword ebx-1],-1 With mov word [word ebx-1],-1 And you'll get an "Address Size Error"  | 
              |||
                  
  | 
              
| 
                  
                   asmfan 15 Aug 2007, 06:58 
                  Somethind like this. Makes compiler to produce the full form of instruction, not the shortest possible.
 
                  Code: .00401000: C743FFFFFFFFFF mov d,[ebx][-01],-1 .00401007: 3D40010000 cmp eax,000000140 ;' @' .0040100C: C3 retn .0040100D: C783FFFFFFFFFFFFFFFF mov d,[ebx][-00000001],-1 .00401017: 3D40010000 cmp eax,000000140 ;' @' .0040101C: C3 retn _________________ Any offers?  | 
              |||
                  
  | 
              
| 
                  
                   shism2 15 Aug 2007, 11:44 
                  Asmfasm :
 
                  
                That's what you get when you look at the compiled code in a disasmbeller?  | 
              |||
                  
  | 
              
| 
                  
                   LocoDelAssembly 15 Aug 2007, 13:22 
                  shism2, I tested your code as you posted but I commented that line for obvious reasons.
 
                  
                My output is the same as asmfan, here my output with OllyDbg: Code: 00401000 >/$ C743 FF FFFFFFFF MOV DWORD PTR DS:[EBX-1],-1 00401007 |. 3D 40010000 CMP EAX,140 0040100C \. C3 RETN 0040100D DB DB DB 0040100E . C783 FFFFFFFF FFFFFFFF MOV DWORD PTR DS:[EBX-1],-1 00401018 . 3D 40010000 CMP EAX,140 0040101D . C3 RETN 0040101E DB DB DB And to clarify even more I tested exactly this: Code: format PE gui mov dword [ebx-1],-1 cmp eax,320 ret db 0dbh ;AND_______________________ mov dword [dword ebx-1],-1 ; Why does this compile ? cmp eax,320 ret db 0dbh Note that removing format also compiles fine and using "use32" also works, etc. Seems to work always. I insist, which version are you using? Is exactly that code that gives you troubles? [edit]Sorry, I'm clearly seriously stupid here... The difference is the size of the offset. With "dword" inside the square bracket you prevent fasm from using the short signed 8-bit immediate form. You also prevent the suppression of the offset when it is zero ("mov [dword ebx+0], eax" is not converted into "mov [ebx], eax" while "mov [ebx+0], eax" yes). Sorry for misreading you[/edit]  | 
              |||
                  
  | 
              
| 
                  
                   DOS386 15 Aug 2007, 22:01 
                  Code: use32 mov dword [ebx-1],-1 cmp eax,320 ret db 0dbh nop nop nop nop nop mov dword [dword ebx-1],-1 ; Why does this compile ? cmp eax,320 ret db 0dbh nop nop nop nop nop 00000000 C743FFFFFFFFFF mov dword [ebx-1],$ffffffff 00000007 3D40010000 cmp eax,$140 0000000C C3 ret 0000000D DB9090909090 fist dword [eax+$90909090] 00000013 C783FFFFFFFFFFFF mov dword [ebx+$ffffffff],$ffffffff -FFFF 0000001D 3D40010000 cmp eax,$140 00000022 C3 ret 00000023 DB9090909090 fist dword [eax+$90909090] Works perfectly as supposed. The only "weird" thing is the syntax of some disassemblers. See correct FASM syntax coming from NDISASM. _________________ Bug Nr.: 12345 Title: Hello World program compiles to 100 KB !!! Status: Closed: NOT a Bug  | 
              |||
                  
  | 
              
| 
                  
                   shism2 16 Aug 2007, 00:34 
                  I didn't know about this addressing. Thank you everyone. 
                  
                 | 
              |||
                  
  | 
              
< Last Thread | Next Thread >  | 
    
Forum Rules: 
  | 
    
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.