Code: Select all
!macro Blign value ;Begin Macro
!{
!a = value - (($ - $$) mod value) ;$=this Offset-Adress, $$=Basis-Adress of the Section
!if a = value
!a = 0
!end if
!if a=1
!irp value, $90 ;NOP, the well-known standard-value
!\{
!DB value
!\}
!end if
!if a=2
!irp value, $8B, $C0 ;MOV EAX,EAX
!\{
!DB value
!\}
!end if
!if a=3
!irp value, $8D, $40, $00 ;LEA EAX, dword ptr[EAX + 00]
!\{
!DB value
!\}
!end if
!if a=4
!irp value, $8D, $44, $20, $00 ;LEA EAX, dword ptr[EAX]
!\{
!DB value
!\}
!end if
!if a=5
!irp value, $66, $8D, $54, $22, $00 ;LEA DX, word ptr[EDX]
!\{
!DB value
!\}
!end if
!if a=6
!irp value, $8D, $80, $00, $00, $00, $00 ;LEA EAX, dword ptr[EAX + 00000000]
!\{
!DB value
!\}
!end if
!if a=7
!irp value, $8D, $04, $05, $00, $00, $00, $00 ;LEA EAX, dword ptr[EAX + 00000000]
!\{
!DB value
!\}
!end if
!if a=8
!irp value, $66, $8D, $04, $05, $00, $00, $00, $00 ;LEA AX, word ptr[EAX + 00000000]
!\{
!DB value
!\}
!end if
!if a=9
!irp value, $90, $66, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=10
!irp value, $8B, $C0, $66, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=11
!irp value, $66, $8D, $54, $22, $00, $8D, $80, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=12
!irp value, $66, $8D, $54, $22, $00, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=13
!irp value, $66, $8D, $54, $22, $00, $66, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=14
!irp value, $8D, $80, $00, $00, $00, $00, $66, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!if a=15
!irp value, $8D, $04, $05, $00, $00, $00, $00, $66, $8D, $04, $05, $00, $00, $00, $00
!\{
!DB value
!\}
!end if
!} ;End Macro
;========================================================================================
;- Test
Global TimeToRun.l = 5000
Global IntIterations.l
Global FpIterations.l
OpenConsole()
Timer.d = ElapsedMilliseconds()
IntIterations = 0
PrintN("Starting...")
Delay(20)
While ElapsedMilliseconds() < Timer + TimeToRun
IntA.l = 1234
IntB.l = 4321
IntIterations = IntIterations + 1
For i = 1 To 1000
iAns.l = IntA + IntB
iAns = IntA - IntB
iAns = IntB % IntA
iAns = IntA * IntB
IntA = IntA + i
IntB = IntB - i
Next
Wend
PrintN("Integer Iterations: " + Str(IntIterations))
Timer.d = ElapsedMilliseconds()
FpIterations = 0
Delay(100) ;let the cpus calm down
While ElapsedMilliseconds() < Timer + TimeToRun
!Blign 8
FPA.d = 1234.1234
FPB.d = 4321.4321
FpIterations = FpIterations + 1
For i = 1 To 1000
fAns.d = FPA + FPB
fAns = FPA - FPB
fAns = FPB / FPA
fAns = FPA * FPB
FPA = FPA + i
FPB = FPB - i
Next
Wend
PrintN("Floating Point Iterations: " + Str(FPIterations))
Input()
CloseConsole()
But the right effect is only in asm-code...