Hi Petr,
Two problems to resolve.
First you can't feed literal numbers into the FPU, nor can it read CPU registers. It can only access numbers which are already present in memory. This leads to the second problem: How do you get local workspace, to store the temporary numbers, without using thinBasic variables?
The solution to the latter is to allocate memory on the stack by subtracting the required space from the stack pointer like this:
sub esp,1000
then using another register to index from.
mov ecx,esp
Now you can store integers
mov dword [ecx+00],15
mov dword [ecx+04],42
..etc
then you can load them into the FPU as dword integers
fild dword [ecx+00]
When you have finished it is vital to disallocate the memory from the stack.
This can be done by adding the space back to the stack pointer:
add esp,1000
ret
To create local variables using macro symbols:
def aa [ecx]
def bb [ecx+04]
def workspace 1000
then
add esp, workspace$
mov ecx,esp
mov aa$,15
fild aa$
....
add esp,workspace$
ret
In the next update I am about to send, the '$' will no longer be needed and further adjustments to the syntax allow system calls to be made in the same way as a high level language.
Bookmarks