flat assembler
Message board for the users of flat assembler.
Index
> Compiler Internals > jge dword [ebx] |
Author |
|
MazeGen 25 Jan 2006, 12:59
You can't use such conditional jump with memory or register operand. You should use something like
jnle over jmp dword [ebx] over: |
|||
25 Jan 2006, 12:59 |
|
vid 25 Jan 2006, 13:22
or use macro: (untested)
Code: ;allow double-negated jumps (same is also done in %FASMINC%/INCLUDE/IF.INC) jnne equ je jnnle equ jle jnnl equ jl jnnge equ jge jnng equ jg jnnae equ jae jnna equ ja jnnbe equ jbe jnnb equ jb ;for every type of jump irp cc, g ge l le ng nge nl nle a ae b be na nae nb nbe { ;overload conditional jump instruction macro j#cc arg \{ ;if it's indirect jump if op eqtype dword [something] local ..dest ;always don't forget local and ".." in macro's internal labels jn#cc ..dest jmp arg ..dest: else j#cc arg end if \} } hope it works [edit] fixed few bugs in code |
|||
25 Jan 2006, 13:22 |
|
LocoDelAssembly 25 Jan 2006, 14:20
I had to change IRP to IRPS because with IRP throws "Invalid macro arguments" at "macro j#cc arg" line and I had to change "op" with "arg".
|
|||
25 Jan 2006, 14:20 |
|
vid 25 Jan 2006, 14:31
ooops, yes. it's because "ebx eqtype something" is false. Then it could be bigger problem... You need to check if "arg" is "<size_operator> [any_allowed_address]", which would be much more tricky (maybe someone can find simple solution...).
At least, here is a corrected version which should work for register as address. (Not for things like "jge dword [eax+5]") Code: ;allow double-negated jumps (same is also done in %FASMINC%/INCLUDE/IF.INC) jnne equ je jnnle equ jle jnnl equ jl jnnge equ jge jnng equ jg jnnae equ jae jnna equ ja jnnbe equ jbe jnnb equ jb ;for every type of jump irp cc, g, ge, l, le, ng, nge, nl, nle, a, ae, b, be, na, nae, nb, nbe { ;overload conditional jump instruction macro j#cc arg \{ ;if it's indirect jump if arg eqtype dword [eax] local ..dest ;always don't forget local and ".." in macro's internal labels jn#cc ..dest jmp arg ..dest: else j#cc arg end if \} } |
|||
25 Jan 2006, 14:31 |
|
LocoDelAssembly 25 Jan 2006, 14:48
Sorry Vid, it's my fault, you probably read my previous post. The problem was that when I trying to find the problem I'd changed "if arg eqtype dword [something]" to "if arg eqtupe dword **ptr**[something]" (without "**"). Thats works good for "jge dword ptr [ebx]" but not for "jge dword [ebx]", I thought that "ptr" in the eqtype was needed .
However I note that IRP works fine with this code :S while in the first one you need IRPS :S:S, why happend this? PS: Checked before posting, IRP works now because you use "," for every condition now [edit]Another problem, if I put "jge dword[ebx]" twice I get "Error: already defined symbol" and the symbol is "..dest?0000001". Preprocesor output: Code: use32 ;jge dword[ebx] if dword[ebx]eqtype dword[eax] ;jnge ..dest?0000001 if ..dest?0000001 eqtype dword[eax] jge ..dest?0000005 jmp ..dest?0000001 ..dest?0000005: else jnge ..dest?0000001 end if jmp dword[ebx] ..dest?0000001: else jge dword[ebx] end if ;jge dword[ebx] if dword[ebx]eqtype dword[eax] ;jnge ..dest?0000001 if ..dest?0000001 eqtype dword[eax] jge ..dest?0000005 jmp ..dest?0000001 ..dest?0000005: else jnge ..dest?0000001 end if jmp dword[ebx] ..dest?0000001: else jge dword[ebx] end if |
|||
25 Jan 2006, 14:48 |
|
vid 25 Jan 2006, 15:05
locodelassembly wrote: Another problem, if I put "jge dword[ebx]" twice I get "Error: already defined symbol" and the symbol is "..dest?0000001". Of course, i forgot to escape "local" (it should make symbol local for inner macro, not for irp). so it's Code: ;allow double-negated jumps (same is also done in %FASMINC%/INCLUDE/IF.INC) jnne equ je jnnle equ jle jnnl equ jl jnnge equ jge jnng equ jg jnnae equ jae jnna equ ja jnnbe equ jbe jnnb equ jb ;for every type of jump irp cc, g, ge, l, le, ng, nge, nl, nle, a, ae, b, be, na, nae, nb, nbe { ;overload conditional jump instruction macro j#cc arg \{ ;if it's indirect jump if arg eqtype dword [eax] \local ..dest ;always don't forget local and ".." in macro's internal labels jn#cc ..dest jmp arg ..dest: else j#cc arg end if \} } |
|||
25 Jan 2006, 15:05 |
|
Posetf 25 Jan 2006, 20:17
MazeGen wrote: You can't use such conditional jump with memory or register operand. You should use something like Thanks, I'll do that. Regards, Pete PS. vid: thanks for the macro but I shall stick with the above. |
|||
25 Jan 2006, 20:17 |
|
vid 25 Jan 2006, 20:31
posetf: yes, it's better solution, overdefining instruction syntax with macros kills readability. I wrote it just to show some example of macrofeatures.
|
|||
25 Jan 2006, 20:31 |
|
Borsuc 25 Jan 2006, 20:40
It could have been quite nice macro, but it's not in standard instruction set, so... i agree
|
|||
25 Jan 2006, 20:40 |
|
< Last Thread | Next Thread > |
Forum Rules:
|
Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.