Page 1 of 1

Bounds() Asm (my first asm code)

Posted: Sun Apr 03, 2005 1:26 pm
by Inner

Code: Select all

Procedure Bounds(value.l,min.l,max.l)
 	!mov eax,dword[esp]			; Move the value into a reg eax
	!cmp eax,dword[esp+4]   ; compare eax with argument 2 (min)
	!jng l_low							; jump to low if value is less than min
	!cmp eax,dword[esp+8]		; compare eax with argument 3 (max)
  !jnl l_high							; jump to high if value is greater than max
	!jmp l_term 						; if value is not greater than or less than min or max jump to end
low:
	!mov eax,dword[esp+4]		; value is lower so move the min value to eax which will return
	!jmp l_term							; jump to terminate
high:
	!mov eax,dword[esp+8]		; value is higher so move the max value to eax which will return
													; don't need to jump to term since procedurereturn is the next 
													; instruction
term:
	ProcedureReturn
EndProcedure
;
; Test
;
For i=-10 To 10
	Debug(Str(i)+" : "+Str(Bounds(i,-5,5)))
Next
I didn't think I had it in me :) okay it's my first bit of asm code.

Re: Bounds() Asm (my first asm code)

Posted: Sun Apr 03, 2005 1:37 pm
by NoahPhense
Very kewl ..

- np

Re: Bounds() Asm (my first asm code)

Posted: Fri Apr 22, 2005 2:09 pm
by va!n
really, very cool! nice work!