Oxygen Basic
Programming => Problems & Solutions => Topic started by: Emil_halim on March 20, 2013, 07:37:08 AM
-
this was discussion in OXYEditor under tools section , but i see it is better to put it here.
Charles ,
this did not work as expect
$ filename "test2.exe"
#include "..\..\inc\RTL32.inc"
addr ecx,xx
[ecx] = 100
print hex [ecx]
end
.xx
dd 0
-
Hi Emil,
end means in OxygenBasic "marks the end of a code block"
Isn't termination!
-
Hi Peter ,
yes i know that end will tell the compiler to stop at that point and don't execute the following instruction.
but how this help in this case?
-
i was playing with my old strcpy function in Ziron and start to compile it under Oxygen and......
it compiled ok with a Little changes , but it refused to run as the above problem.
$ filename "test3.exe"
#include "..\..\inc\RTL32.inc"
function H_strcpy(Dword dst,src)
{
' uses edx ebx;
push edx : push ebx
Eax = dst;
Edx = src;
push Eax;
BL = char[Edx];
while ( BL != 0)
{
char[Eax] = BL;
Eax++; Edx++;
BL = char[Edx];
}
char[Eax] = 0;
pop Eax;
pop ebx : pop edx
}
dim as string * 1024 buf
H_strcpy(&buf,"Emil Halim")
print buf
-
indexbase 0
'$ filename "test3.exe"
'#include "..\..\inc\RTL32.inc"
string buf
Sub H_strcpy(string dst, string src)
pushad
mov Eax,dst
mov Edx,src
.w
mov CL, [Edx]
mov [Eax], CL
inc Eax
inc Edx
mov CL, [Edx]
cmp CL,0
jnz w
popad
End Sub
H_strcpy(buf,"Emil Halim ")
print buf
-
ok ,Peter thanks for converting.
but i really want to know Oxygen compiled it with no error and what could be the op-code that came out?
-
Hi Emil, Peter,
the '=' operator usually translates to something like this
a=b
---->
mov eax,b
mov a,eax
copy is a built-in function and works on the var address or strpr for strings
'copying from b to a , n bytes:
copy @a,@b,n
or
copy &a,&b,n
Using Oxygen Asm with block feature:
zstring a[]="ABCDE"
zstring b[]="12345"
sys n=len a
mycopy:
addr esi,b
addr edi,a
mov ecx,n
(
dec ecx
jl exit
mov al,[esi]
mov [edi],al
inc esi
inc edi
repeat
)
print b
NB: I noticed that addr does not handle bstrings and strings correctly, so I will add the mod to my next release.
zstrings / char is ok
Charles
-
I use Assembler in old style, I have no problems.
-
Hi Peter ,
this is old style but still did not work
addr ecx,xx
mov [ecx] , 100
print hex [ecx]
end
.xx
dd 0
-
Hi Emil,
X
-
this is very strange , it compiled okay but refused to run.
can Mr Charles give any hint here please!!!!!!!!!!
-
can Mr Charles give any hint here please!!!!!!!!!!
LOL :D
-
Hi Peter ,
i think Oxygen has some troubles with 32bit version of windows , to ensure that , want to test it with
other 32bit machine , do you have one ?
-
I run 32 bit XP in a VirtualBox under Ubuntu 64. I have Win7 64 bit in a separate bootable partition. (64 bit Windows testing only) For me this is a great way to test both 32 & 64 bit Windows and still use a sane OS for development. For quick tests without having to fire up the XP VirtiualBox, I use Wine.
-
No, I haven't.
But you can knock at Aurel. He drives ancient WinXP 32 Bit.
-
Something runs wrong with last OxygenBasic versions.
I have had never problems with making of dlls. But now, 24 hour on the day.
One could think, Charles don't like aliens dlls. It makes him afraid.
-
Hi Emil,
This will work when run directly in memory, but when compiled, it cannot work because you are writing into a code section, which is configured as read-only. To create some data space you can map to global and static variables for fixed-location storage, or local variables to stack storage or strings and bstrings for heap-allocated storage.
Interesting case :)
addr ecx,xx
mov [ecx] , 0x64
print hex [ecx]
end
.xx
dd 0
Peter,
I'm giving DLLs a thorough workout with ScriptBasic, PowerBasic and thinBasic interfacing. Since my last Oxygen posting (with the RTLs) I have not come across any major problems, though a few subtle ones, mainly associated with complex C headers.
Charles
-
oh . i got it Charles , this will work okay
sub main()
addr ecx , xx
print hex [ecx]
MOV [ecx] , 100
print hex [ecx]
end sub
main
end
.xx
dd 10
but see the next one it compiled and worked okay , as you said it will resident in read-only section!!!!!!!
addr ecx , xx
print hex [ecx]
end
.xx
dd 10
thanks ,
Emil.