flat assembler
Message board for the users of flat assembler.

Index > Windows > How to optimize this code?

Author
Thread Post new topic Reply to topic
sq4²



Joined: 31 Jul 2005
Posts: 13
sq4²
I have a long variable that contains following :
(using PureBasic)

Code:
a.b ;(minvalue)
b.b ;(maxvalue)
c.b ;(value)
varLong.l = 0<<24|a<<16|b<<8|c
    


Depending on minvalue and maxvalue :
Code:
a.b=varLong>>16
b.b=varLong>>8
c.b=varLong
if a<b
 c+1
 If c>b:c=a:EndIf
else
 c-1
 If c<b:c=a:EndIf
endif

varLong.l = 0<<24|a<<16|b<<8|c
    


There must be a really fast way to write this in inl. asm.
(but I am a complete idiot in asm)

Anybody?
Post 18 Nov 2005, 12:16
View user's profile Send private message Reply with quote
Madis731



Joined: 25 Sep 2003
Posts: 2140
Location: Estonia
Madis731
You gave us pseudocode so pseudo-assembly right back at you Very Happy
Code:
c         db 0
b         db 0
a         db 0
EmptyByte db 0
varLong=c
    

...and the second one...
Code:
    mov eax,[varLong]
    ror eax,8
    cmp ah,al
jnb aNotBelow
    rol eax,8
    inc eax
    cmp al,ah
    jna @f
        mov al,[a]
    @@:
    jmp EndCompare
aNotBelow:
    rol eax,8
    dec eax
    cmp al,ah
    jnb @f
        mov al,[a]
    @@:
EndCompare:
    mov [varLong],eax
    

What do you want to do anyway? I think you just need a better algo, because the operations you make just seem...excuse me...stupid Sad
Post 19 Nov 2005, 14:39
View user's profile Send private message Visit poster's website Yahoo Messenger MSN Messenger Reply with quote
sq4²



Joined: 31 Jul 2005
Posts: 13
sq4²
Thank you very much!
Post 19 Nov 2005, 15:01
View user's profile Send private message Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  


< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2020, Tomasz Grysztar. Also on YouTube, Twitter.

Website powered by rwasa.