Danke Helle!
Das mit dem XOR eax,eax war wohl wirklich eine Copy&Paste-Leiche (und das bei 4 Zeilen Code

).
Bzgl. SetXX : Danke für den Hinweis ! Ich hatte ganz zu Anfang schonmal damit rumgespielt (als die Macro noch 20 ASM-code-Zeilen hatte

), aber dachte immer, dass die SetXX-Befehle das Register unberührt lassen, wenn die Bedingung
nicht erfüllt ist, aber dem ist ja gar nicht so! Tsja "ASM-learning by doing", (leider auf Kosten derer, die den Source unbedarft übernehmen, whoops...)
Hier nun die aktuellen Versionen, welche also noch weit schlanker als zuvor sind:
(Ich denke in den Macros ist weniger als 3 Befehle wohl nicht machbar. In den Proceduren muss das XOR eax, eax erhalten bleiben, denn selbst wenn man den Rückgabetyp auf .b setzt, wird das Ergebnis durch Reste im Register verfälscht, solange man es nicht ausdrücklich mit &$FF oder einem Bytewert empfängt.)
[edit]Hier der
nochmals korrigierte Code grrrgg[/edit]
Code: Alles auswählen
;/ Macros (and Procedures) for comparing two unsigned 32-bit-values (version 1.2)
;/
;/ all of them compare the first against the second parameter and
;/ store the result in the third parameter
;/
;/ To call them from PB you must introduce the line with '!', and mask
;/ all variablenames with '[v_MYVARIABLENAME]' (MYVARIABLENAME is case sensitive!!)
;/ Further you might use decimal values such as 12345,
;/ or hexadecimal values using leading '0x' instead of '$'
;/ In the macros the result-value is treated as if it were of type byte,
;/ so just the lower 8 bit are manipulated.
;/
;/ e.g. valid calls are (variables 'res', 'a', 'b' suspected to be already defined):
;/
;/ !greater 3, 9, [v_res]
;/ !smaller [v_a], 0x7FFFFFFF, [v_res]
;/ !smallerequal [v_a], [v_b], [v_res]
;/
;/ These Macros are about 4 times faster than the respective procedure.
;/ But if you don't really need this speed and want the convenience of a procedure,
;/ than you might use the ones below instead of the macros.
;/ These macros and proceudures are all independant of each other, so you can
;/ easily copy & paste the ones you need.
;/
;/ 14.02.2005 by Froggerprogger with the BIG help of remi_meier & horst & Helle
;- the macros:
!macro greater a, b, res
!{
!MOV ebx,a
!CMP ebx,b
!SETA byte res
!}
!macro greaterequal a, b, res
!{
!MOV ebx,a
!CMP ebx,b
!SETAE byte res
!}
!macro smaller a, b, res
!{
!MOV ebx,a
!CMP ebx,b
!SETB byte res
!}
!macro smallerequal a, b, res
!{
!MOV ebx,a
!CMP ebx,b
!SETBE byte res
!}
;- the procedures:
Procedure.l UINT_Greater(a.l, b.l)
!XOR eax,eax
!MOV ebx,[esp]
!CMP ebx,[esp+4]
!SETA al
ProcedureReturn
EndProcedure
Procedure.l UINT_GreaterEqual(a.l, b.l)
!XOR eax,eax
!MOV ebx,[esp]
!CMP ebx,[esp+4]
!SETAE al
ProcedureReturn
EndProcedure
Procedure.l UINT_Smaller(a.l, b.l)
!XOR eax,eax
!MOV ebx,[esp]
!CMP ebx,[esp+4]
!SETB al
ProcedureReturn
EndProcedure
Procedure.l UINT_SmallerEqual(a.l, b.l)
!XOR eax,eax
!MOV ebx,[esp]
!CMP ebx,[esp+4]
!SETBE al
ProcedureReturn
EndProcedure
;-
;- examples
;-
x = $99000000
y = $88000000
result.b = 0 ; we might use LONG instead if we don't manipulate the upper 24 bits, though BYTE is more safe because of that
!greater [v_x], [v_y], [v_result]
Debug result
Debug UINT_Greater(x, y)
!smallerequal 0x80000000, [v_y], [v_result]
Debug result
Debug UINT_SmallerEqual($88000000, y)