flat assembler
Message board for the users of flat assembler.
Index
> Macroinstructions > Minor problem with 'if.inc' macro |
Author |
|
LocoDelAssembly 08 Aug 2010, 00:36
I think that detecting whether the jmp that skips the else (or elseIf) block is required or not is too hard even if considering ret alone only. For instance, I think you won't find a method to detect situations like this:
Code: proc foo, arg .if dword [arg] <> NULL call [arg] test eax, eax js @f return @@: .else return -1 .endif return -2 endp Code: proc foo, arg .if dword [arg] <> NULL call [arg] .if eax >= 0 return .endif @@: .else return -1 .endif return -2 endp |
|||
08 Aug 2010, 00:36 |
|
madmatt 08 Aug 2010, 13:05
Quote: But perhaps correctly detecting when the JMP to skip the else is needed is doable with fasm, the other one I think it is impossible to get it right. I was thinking something like having something like '.else NJ' (NJ = no jmp) to signal that a 'jmp' shouldn't be used when the .else macro keyword is used. |
|||
08 Aug 2010, 13:05 |
|
Tomasz Grysztar 08 Aug 2010, 13:23
madmatt wrote: I was thinking something like having something like '.else NJ' (NJ = no jmp) to signal that a 'jmp' shouldn't be used when the .else macro keyword is used. Code: .if dword [ddback] <> NULL cominvk ddback, Restore; ;this reattaches the video memory to the surface return .endif return -1 |
|||
08 Aug 2010, 13:23 |
|
madmatt 08 Aug 2010, 17:49
Tomasz Grysztar wrote:
Yeh, that would work better. But, still seems to need a fix when it is inserting code that is not needed (obviously, this should be a very low priority fix, nothing is truly broken here.). By the way, also discovered that the '.elseif' macro does the same thing. see code below. Code: ;[ORIGINAL CODE] proc DDGetDefaultFont fontaddress, fontnumber .if [fontnumber] = DDCHARFONTVGA8 cinvoke memcpy, [fontaddress], vgafont8x8, 2048 return DD_OK .elseif [fontnumber] = DDCHARFONTATR8 cinvoke memcpy, [fontaddress], atarifont8x8, 2048 return DD_OK .elseif [fontnumber] = DDCHARFONTAPP8 cinvoke memcpy, [fontaddress], AppleFont8x8, 2048 return DD_OK .elseif [fontnumber] = DDCHARFONTC648 cinvoke memcpy, [fontaddress], c64font8x8, 4096 return DD_OK .elseif [fontnumber] = DDCHARFONTVGA16 cinvoke memcpy, [fontaddress], vgafont8x16, 4096 return DD_OK .else 1 return -1 .endif endp ;[CODE DIS-ASSEMBLED WITH OBJCONV BY AGNER FOG] nop ; 00423D7A _ 90 nop ; 00423D7B _ 90 nop ; 00423D7C _ 90 nop ; 00423D7D _ 90 nop ; 00423D7E _ 90 nop ; 00423D7F _ 90 DDGetDefaultFont:; Function begin push ebp ; 00423D80 _ 55 mov ebp, esp ; 00423D81 _ 89. E5 cmp dword [ebp+0CH], 0 ; 00423D83 _ 83. 7D, 0C, 00 jnz ?_0716 ; 00423D87 _ 75, 24 push 2048 ; 00423D89 _ 68, 00000800 push ?_0145 ; 00423D8E _ 68, 004029C0(d) push dword [ebp+8H] ; 00423D93 _ FF. 75, 08 call near [imp_memcpy] ; 00423D96 _ FF. 15, 00429516(d) add esp, 12 ; 00423D9C _ 83. C4, 0C mov eax, 0 ; 00423D9F _ B8, 00000000 leave ; 00423DA4 _ C9 ret 8 ; 00423DA5 _ C2, 0008 ; Note: Inaccessible code jmp ?_0721 ; 00423DA8 _ E9, 000000A3 ?_0716: cmp dword [ebp+0CH], 1 ; 00423DAD _ 83. 7D, 0C, 01 jnz ?_0717 ; 00423DB1 _ 75, 21 push 2048 ; 00423DB3 _ 68, 00000800 push ?_0148 ; 00423DB8 _ 68, 004051C0(d) push dword [ebp+8H] ; 00423DBD _ FF. 75, 08 call near [imp_memcpy] ; 00423DC0 _ FF. 15, 00429516(d) add esp, 12 ; 00423DC6 _ 83. C4, 0C mov eax, 0 ; 00423DC9 _ B8, 00000000 leave ; 00423DCE _ C9 ret 8 ; 00423DCF _ C2, 0008 ; Note: Inaccessible code jmp ?_0721 ; 00423DD2 _ EB, 7C ?_0717: cmp dword [ebp+0CH], 2 ; 00423DD4 _ 83. 7D, 0C, 02 jnz ?_0718 ; 00423DD8 _ 75, 21 push 2048 ; 00423DDA _ 68, 00000800 push ?_0149 ; 00423DDF _ 68, 004059C0(d) push dword [ebp+8H] ; 00423DE4 _ FF. 75, 08 call near [imp_memcpy] ; 00423DE7 _ FF. 15, 00429516(d) add esp, 12 ; 00423DED _ 83. C4, 0C mov eax, 0 ; 00423DF0 _ B8, 00000000 leave ; 00423DF5 _ C9 ret 8 ; 00423DF6 _ C2, 0008 ; Note: Inaccessible code jmp ?_0721 ; 00423DF9 _ EB, 55 ?_0718: cmp dword [ebp+0CH], 3 ; 00423DFB _ 83. 7D, 0C, 03 jnz ?_0719 ; 00423DFF _ 75, 21 push 4096 ; 00423E01 _ 68, 00001000 push ?_0147 ; 00423E06 _ 68, 004041C0(d) push dword [ebp+8H] ; 00423E0B _ FF. 75, 08 call near [imp_memcpy] ; 00423E0E _ FF. 15, 00429516(d) add esp, 12 ; 00423E14 _ 83. C4, 0C mov eax, 0 ; 00423E17 _ B8, 00000000 leave ; 00423E1C _ C9 ret 8 ; 00423E1D _ C2, 0008 ; Note: Inaccessible code jmp ?_0721 ; 00423E20 _ EB, 2E ?_0719: cmp dword [ebp+0CH], 4 ; 00423E22 _ 83. 7D, 0C, 04 jnz ?_0720 ; 00423E26 _ 75, 1F push 4096 ; 00423E28 _ 68, 00001000 push ?_0146 ; 00423E2D _ 68, 004031C0(d) push dword [ebp+8H] ; 00423E32 _ FF. 75, 08 call near [imp_memcpy] ; 00423E35 _ FF. 15, 00429516(d) add esp, 12 ; 00423E3B _ 83. C4, 0C mov eax, 0 ; 00423E3E _ B8, 00000000 leave ; 00423E43 _ C9 ret 8 ; 00423E44 _ C2, 0008 ?_0720: mov eax, 4294967295 ; 00423E47 _ B8, FFFFFFFF leave ; 00423E4C _ C9 ret 8 ; 00423E4D _ C2, 0008 ?_0721: nop ; 00423E50 _ 90 nop ; 00423E51 _ 90 nop ; 00423E52 _ 90 nop ; 00423E53 _ 90 nop ; 00423E54 _ 90 nop ; 00423E55 _ 90 nop ; 00423E56 _ 90 nop ; 00423E57 _ 90 nop ; 00423E58 _ 90 nop ; 00423E59 _ 90 _________________ Gimme a sledge hammer! I'LL FIX IT! |
|||
08 Aug 2010, 17:49 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.