Oxygen Basic

Programming => Problems & Solutions => Topic started by: Peter on December 09, 2011, 12:24:04 PM

Title: AsmJunkError
Post by: Peter on December 09, 2011, 12:24:04 PM
Deleted..
Title: Re: AsmJunkError
Post by: Charles Pegge on December 09, 2011, 02:26:45 PM
Hi Peter,

Is that a 64-bit circle? :)


on the Asm clip:

I removed the <--- junk  and it worked!

Code: [Select]
sys Tx,x,y

   mov   [y],0
.A mov   [x],0
.B mov   ecx,[y]
   mov   edx,[Tx]
   imul  ecx,edx
   add   ecx,[x]
   mov   eax,3
Title: Re: AsmJunkError
Post by: Charles Pegge on December 09, 2011, 04:00:33 PM

Your clues are too cryptic for me.
Title: Re: AsmJunkError
Post by: JRS on December 09, 2011, 07:08:36 PM
It would be a big help to Charles if we can keep games separate from bug reports.
 



Title: Re: AsmJunkError
Post by: Aurel on December 10, 2011, 03:09:42 AM
And would be helpful if all 64 bit examples be separated.
I really don't know why insist on 64bit version.
Only because memory consuption advantage,right?
Afterall all 32bit programs work on 64 bit windows,right?
And i really doubt that someone here need 2gb for program.
Title: Re: AsmJunkError
Post by: Charles Pegge on December 10, 2011, 03:20:30 AM

Yes I agree Aurel, 32bits seems an optimal size for most programs. Some server applications benefit from the larger address space and the wide registers size helps with hash coding and encryption.

The Basic examples I've reworked will work as 32 or 64 bit binaries. Only the run-time library changes.

Charles
Title: Re: AsmJunkError
Post by: Charles Pegge on December 10, 2011, 07:14:25 AM
Peter,

I think that the line number / error is wrongly attributed to RTL64. That is why more information would helpful.

Similarly I cannot reproduce the problem you get with the dot labels.

Charles
Title: Re: AsmJunkError
Post by: Charles Pegge on December 10, 2011, 08:55:08 AM
Yes stay with dotted labels. The colon is interpreted as a delimiter when a statement follows on the same line.

Avoid using terminate. This is a macro to release program resources. It is only necessary in a customised Finish procedure (used in DLLs etc).
Otherwise the compiler inserts it automatically.

This works with RTLs

Code: [Select]
$filename "t.exe"
#include "RTL64.inc" 'add path if required
  sys   iEax
   mov   eax,100
   mov   edx,100
   mov   ecx,50
   sub   eax,ecx
   add   eax,edx
   cmp   eax,50
   jz    A
   mov   eax,15
   rol   eax,4
   mov   edx,eax
   jmp   B
.A mov   iEax,eax
   print iEax
   jmp fwd C
.B movzx rax, eax
   mov   iEax,eax
   print iEax
   jmp fwd C
.C

Charles
Title: Re: AsmJunkError
Post by: Charles Pegge on December 10, 2011, 10:01:25 AM

I don't know what is causing it Peter. Could you try the latest in-progress version, I have just posted a new one.

Charles
Title: Re: AsmJunkError
Post by: Charles Pegge on December 10, 2011, 12:34:18 PM

Peter,

I can't do anything with the binaries.

If you are using any 32bit assembler techniques in a 64bit system, expect trouble!
The calling convention and demand for 16 byte stack pointer alignment make it a very different place.


One of your demos below compiles successfully to 64bit binary using an amended version of your window64.h / Window.h

This, I have included with a suite of your programs in projects/GDIWindows/. I try to ensure that these programs work correctly with each release.

Code: [Select]
$ Filename "t.exe"
#include "..\..\inc\RTL64.inc"
indexbase 0
include "window64.h"

SetWindow "Load Check",320,240,w_2
Font 12,24,700,"courier"

dim map(108) as byte
sys x, loaded
loaded = LoadFile "maps/map1-1.bin", map
string s="Loaded= " + loaded
Text 0,0,s,white
WaitKey(32)

While Esckey()=0
cls 0
for x=0 to 8
   Text 0,x*24,"map" + x + "= " + map(x),white
next
DoEvents
SwapBuffers
Wend
WinEnd

Charles
Title: Re: AsmJunkError
Post by: efgee on December 12, 2011, 12:41:38 PM
And would be helpful if all 64 bit examples be separated.
I really don't know why insist on 64bit version.
Only because memory consuption advantage,right?
Afterall all 32bit programs work on 64 bit windows,right?
And i really doubt that someone here need 2gb for program.

Aurel,
if done right all examples should work on 32 or 64 bit.
The only need would be to change the runtime from RTL32 to RTL64.

No more no less.

If you look at C/C++ compilers they all have one set of include files because they work with both set of libraries (32 and 64 bit).

Oxygen can work the same.

Besides, computers nowadays come with Windows7-64bit pre-installed. 32bit programs run on it because there is a software layer that makes it happen. Because of that, 32bit programs are slightly slower on a 64bit OS than on a 32bit OS.

As a side note:
How many 32bit-only Basic compilers are actively developed today?

XBlite has a handful of users but no real community. (Windows 32bit only)
FreeBasic is adding a C emitter in order to create 64 bit apps. (Dos/Windows/Linux/BSD 32bit only)
IBasic/EBasic have a handful of users and a community (Windows 32bit only) but the creator of these languages jumped ship to .NET.
etc.

Because Oxygen creates machine code it's tight to x86/x64 platforms; so serving 32/64 bit Windows/Linux would inhibit Oxygen to gain more users, build a community, survive and stay active in the long run.

my $0.02
Title: Re: AsmJunkError
Post by: Aurel on December 13, 2011, 02:42:17 AM
Where you find Xblite?
Xblite even don't look like basic.And because of syntax complexity is not very
much popular at all.
IWBasic original author is not jump to .NET (Nova language-development on ice)
He work on MiniBASIC which is 32bit only for now.Long story....
PureBasic for now is only 32bit to.
etc..etc...

I don't tell that 64bit version is worthwhile.
And i really doubt that 64bit version will attract more people to OxygenBasic.
Basic - today ,is on the edge...
Title: Re: AsmJunkError
Post by: Charles Pegge on December 13, 2011, 06:05:34 AM

DLL developers need 64 bit compiling when their products are to be used by 64 bit applications.
Patrice Terrier develops modules for WinDev for example, and had to port some of his code from PB to C++ for this reason.

Charles
Title: Re: AsmJunkError
Post by: efgee on December 13, 2011, 10:03:13 AM
Where you find Xblite?
Xblite even don't look like basic.And because of syntax complexity is not very
much popular at all.

The only difference to traditional BASIC is that the type is in front of the variable name.
Other than that it's OK. Feels somewhat C-ish, but so can OxygenBasic...

IWBasic original author is not jump to .NET (Nova language-development on ice)
He work on MiniBASIC which is 32bit only for now.Long story....

So he stopped this compiler as well? I'm not really up to speed with all this...

PureBasic for now is only 32bit to.

This is not the case that's why I didn't list it...

PureBasic is Windows/Linux/OSX 32bit AND 64bit. (It even has an Amiga version  :P )
You pay once and can download all versions you want and have lifetime updates/upgrades.  8)
The syntax is not really traditional BASIC, it's BASIC-like.

Aurel, if you are a PureBasic user and need 64bit compiler just download it...  ;D

...Basic - today ,is on the edge...

On the edge to what? Extinction?


Take care
Title: Re: AsmJunkError
Post by: efgee on December 13, 2011, 10:05:24 AM
Patrice Terrier develops modules for WinDev for example, and had to port some of his code from PB to C++ for this reason.

You talk about PowerBasic?

(not PureBasic...)
Title: Re: AsmJunkError
Post by: Charles Pegge on December 13, 2011, 11:53:56 AM
Hi Peter,

Using the MS64 calling convention in Assembler:

You need to provide a 32 byte spill zone for the first four params in registers. (The stack pointer must also be aligned to 16 bytes whenever a call is made. It's okay here)

Code: [Select]

$ FileName "t.exe"
#include "..\..\inc\RTL64.inc"

Declare Function MessageBox Lib "user32.dll" Alias "MessageBoxA" (ByVal hwnd As Long, ByVal lpText As String, ByVal lpCaption As String, ByVal wType As Long) As Long

zstring tit[]="The 64Bit world of OxygenBasic..."
zstring msg[]="Hello Christmas"

sub  rsp,32
mov  r9d, 0      
lea  r8,  tit  
lea  rdx, msg  
mov  rcx, 0      
call MessageBox
add  rsp,32

I'll add this one with the rest of your demo code :)

Charles
Title: Re: AsmJunkError
Post by: Aurel on December 13, 2011, 12:32:33 PM
Yes i have PureBasic version 4.51 and i can say that PureBasic is very well
basic compiler.I use them in first place because i have whole bunch of source
code written in Pure Basic( from small programs to big application).

And yes Charles talk about Power Basic.
I don't know why ,but i simply don't like Power Basic. 
Title: Re: AsmJunkError
Post by: Charles Pegge on December 13, 2011, 01:29:02 PM
I should warn everybody that the standard used for O2 native functions differs from MS64 in that when a function is called it reads all its param from the stack. This is not cast in stone yet! And I am so cross about having to use the simd registers to pass floats that I may ditch this as well and go  to cdecl as the internal standard.

Functions which have extern, external, callback or export tags, use the proper MS64 standard.

Charles