Oxygen Basic
Programming => Example Code => General => Topic started by: Charles Pegge on October 17, 2014, 03:02:09 PM
-
include "$/inc/console.inc"
indexbase 0
! funA cdecl (sys a,b,c,d) as sys at _funA
jmp fwd nfun
._funA
push ebp
mov ebp,esp
sub esp,0x100
scope
sys a at [ebp+0x08]
sys b at [ebp+0x0C]
sys c at [ebp+0x10]
sys d at [ebp+0x14]
sys r at edx
sys i at ecx
r=0
for i=1 to 10
r=r+a+b+c+d
next
=r
end scope
mov esp,ebp
pop ebp
ret
.nfun
'print "here"
sys a
a=funA 1,2,3,4
print a
waitkey
-
You know how to hurt a guy. 8)
I'm still looking for the magic hooker that knows the ins and outs of BASIC functions.
-
Hi Charles,
What does =r mean?
-
OT - Where you been? On vacation?
-
Hi Mike,
=r
-->
mov eax,r
-->
mov eax,edx
Also works with floats
float s
#show =s
-->
fld dword [ebx+0x1000]
-
Another trick for improving performance in simple numeric procedures, is to use the bespoke cpu calling convention:
Instead of passing params on the stack, registers ecx,edx,esi,edi, are used. (max 4 params.)
include "$/inc/console.inc"
indexbase 0
function funA cpu (a,b,c,d) as sys
#show return a+(b*c)+d
end function
sys a
#show a=funA 1,2,3,4
print a
waitkey
-
nice work Charles,
but why you don't use registers as a parameters
e.g.
include "$/inc/console.inc"
indexbase 0
function funA cpu (ecx,edx,esi,edi) as sys
#show return ecx+(edx*esi)+edi
end function
sys a
#show a=funA 1,2,3,4
print a
waitkey
-
Hi Emil,
The registers are platform-specific.
In 64 bit mode the registers will be rcx rdx r8 r9
-
The registers are platform-specific.
In 64 bit mode the registers will be rcx rdx r8 r9
i think it is not aproblem at all , with 32bits use ecx,.... and with 64bits use rec,.....
thanks ,
just want to know how much is Oxygen basic bug free?
-
Hi Emil,
There are plenty more bugs. I guarantee it :)
Most of them are to be found in C/Basic mixed syntax, and the more complex constructs. But within simple Basic and Assembler, you are fairly safe.