Recent Posts

Pages: [1] 2 3 ... 10
1
Example Code / Re: A little brother of OxIde
« Last post by Arnold on June 27, 2017, 08:40:04 AM »
The last two months I was incredibly lazy using my computer, but I got much distracted by the incidents which happen. During my working life I was not really aware of this extent of chaos in the world.

Version A43 introduced true=-1 / false=0. This makes some modifications necessary for O2HEdit.o2bas / O2HEdit.inc. I mentioned these changes in reply #44.

Although I have added some more features to my little editor project I will first of all adapt the code to the latest version of A43 and use some of the new advanced functions.

Roland
2
Problems & Solutions / Re: How to?
« Last post by Charles Pegge on June 27, 2017, 05:02:39 AM »
Hi Roland,

class_table is only created when a class contains methods and other static members, but not for extern virtual objects.

External objects use method table pointers,  and currently, non-virtual  objects call methods use the table directly.

The '?' symbol is another way of casting (sys)
3
Problems & Solutions / Re: How to?
« Last post by Arnold on June 27, 2017, 04:19:15 AM »
Hi Charles,

Quote
new ca a1 : ?a1=@ca_table
new cb b1 : ?b1=@cb_table

I assume _table is somehow built-in with Oxygenbasic and creates a pointer to a function table? Can this construct only be used with object oriented programming?

I am also not sure about the purpose of ?a1. Does this create an index? It seems to be different from @a1.

Roland
4
Problems & Solutions / Re: How to?
« Last post by helloworld on June 27, 2017, 03:25:24 AM »
Great!
5
Problems & Solutions / Re: How to?
« Last post by Charles Pegge on June 25, 2017, 08:10:07 PM »

It's quite complicated!

Code: [Select]
'2017-06-25 T 08:48:54
'ARRAY OF VIRTUAL OBJECTS
'
extern

'typical interface
'method act(){print "act"}
'...

class ca
method act(){print "act A"}
method constructor(){}
method destructor(){}
end class

class cb
method act(){print "act B"}
method constructor(){}
method destructor(){}
end class

extern virtual

class interface
  method act()
end class

end extern

new ca a1 : ?a1=@ca_table
new cb b1 : ?b1=@cb_table

typedef interface * pinterface
indexbase 1
pinterface vc[100]
@vc[]={@a1,@b1}

vc[1].act 'act A
vc[2].act 'act B
...
del a1
del b1
6
Problems & Solutions / How to?
« Last post by helloworld on June 24, 2017, 09:52:00 PM »
How to declare a container of (pointers to) an abstract class/type (aka interface)?
That is the equivalent of C++:

Code: [Select]
struct Interface
{
virtual void f()=0;
};
struct A : Interface
{
void f(){}
};
struct B : Interface
{
void f(){}
};
int main()
{
Interface* ic[]={new A(), new B()};
}
7
Problems & Solutions / Re: Need help with win32 api function CreateDIBSection
« Last post by helloworld on June 21, 2017, 02:03:12 AM »
You can output asm to text file:
co2 -a -m prog.o2bas > t.txt

My bad. I tried the pipe, but missed out the -m option :D

Quote
re: transferring pointers in asm:

I found this works:

Code: [Select]
dim p1 as integer ptr
dim p2 as integer ptr
dim a as integer
a=99
@p1=@a
(
mov eax,@p1
mov @p2,eax
)
print p2

But this does not:

Code: [Select]
dim as integer ptr p1
dim as integer ptr p2
dim a as integer
a=99
@p1=@a
(
mov eax,@p1
mov @p2,eax
)
print p2

This also works:

Code: [Select]
int* p1
int* p2
int a
a=99
@p1=@a
(
mov eax,@p1
mov @p2,eax
)
print p2
8
Glad it worked for you :)


re co2:

You can output asm to text file:

co2 -a -m prog.o2bas > t.txt

re: transferring pointers in asm:

One crude solution is to embed the basic line into your asm.

push edi
@pointer1 = @pointer2
pop edi

but what I need to do is support @:  addr eax,@pointer1
then this will be possible:

addr edx,@pointer1
addr eax,pointer2
mov [ecx],eax

Another solution is to go C :o
I have not tested this in depth yet, but it certainly works for simple expressions.

#cpointer on
'pointer1=pointer2
mov eax,pointer2
mov pointer1,eax
#cpointer off


9
Problems & Solutions / Re: Need help with win32 api function CreateDIBSection
« Last post by helloworld on June 20, 2017, 10:56:29 PM »
I use Oxide for most of my code testing without the 's' and 'e' problems you describe.
The problem may have been due to keyboard layout..
I.e., it arised when I type the open bracket "[" (to do so, on my keyboard I have to prefix "Alr Gr"-key a.k.a. the right-side "Alt"-key) followed by i.e. "e" (->execute) or "s" (->save).

And now is fixed. :)

Other issues:
-The -a option to co2.exe is quite useless, because the listing is normally longer than the display height. Output shoud happen to file instead.

-It seems that it is not possible to transfer pointers via asm (!): there is no equivalent to @pointer1=@pointer2 witout knowing the stack position of the pointers?

10

HelloWorld64 fix:

https://github.com/Charles-Pegge/OxygenBasic/blob/master/Oxygen.zip


And the attached Oxide should be free of any ctrl-s and Ctrl-e problems:
Pages: [1] 2 3 ... 10