Author Topic: BxbAsm  (Read 178860 times)

jcfuller

  • Guest
Re: BxbAsm
« Reply #135 on: April 18, 2012, 03:18:15 AM »
Steve,
  I found the problem.
 It was line endings. When I cut and pasted test, test2 from README.TXT they were saved with linux line endings LF, but the Sub1 and ucase were used as is and they had CRLF. When save with just LF they converted just fine.

James

jcfuller

  • Guest
Re: BxbAsm
« Reply #136 on: April 18, 2012, 05:37:46 AM »
Steve,
  In your asm output I believe you need to replace the ret in your Main proc to:
Code: [Select]
invoke exit,0

I added a proto in bxb.inc
Code: [Select]
exit proto c :DWORD

The ret caused a gpf on Linux. The invoke exit,0 appears to work fine on windows?

Conrary to what I though there is no _getch() on Linux. I looked in the ubx code and found how it was done,
and wrote a library that I linked to the demos and it worked fine.

I see you have a couple console routines in bxblib. I do believe that is the way to go.
Put all your routines in the library and I can help out by converting them to linux compatable code.

Go ahead and add your console routines back in and I'll see what I can do with them on Linux.


James

SteveA

  • Guest
Re: BxbAsm
« Reply #137 on: April 18, 2012, 07:19:52 AM »
Quote
It was line endings.
...but the Sub1 and ucase were used as is and they had CRLF.
When save with just LF they converted just fine.

This is good to know.
I wonder how I could fix that ?

Quote
In your asm output I believe you need to replace the ret in your Main proc to:

You are right, it should be "exit, 0"
It was originally "ExitProcess", which is a win32 function.
I was playing around with it and never finished it.
In old dos programs you could use "ret".


SteveA

  • Guest
Re: BxbAsm
« Reply #138 on: April 18, 2012, 07:24:54 AM »
What do you want to replace "_getch" with ?

jcfuller

  • Guest
Re: BxbAsm
« Reply #139 on: April 18, 2012, 07:52:44 AM »
What do you want to replace "_getch" with ?


Nothing. It's working fine now that I added a Linux substitute and link it in during jwasm compiling / linking of the asm source.

James

SteveA

  • Guest
Re: BxbAsm
« Reply #140 on: April 18, 2012, 08:02:07 AM »
Nothing. It's working fine now that I added a Linux substitute and link it in during jwasm compiling / linking of the asm source.

Okay.

About the console mode functions:
if I understand correctly, you want me to reactivate them...?

For the most part, I didn't delete them, I just commented them out.
That's what all the comment warnings were about, yesterday.
So, you want me to uncomment them...?

jcfuller

  • Guest
Re: BxbAsm
« Reply #141 on: April 18, 2012, 08:08:42 AM »
 I tried to uncomment just CLS because I wanted to test code I had added but I got a gpf on translation from bas -> asm

Code: [Select]
REM  test.bas version 1
CLS
PRINT "hello world!"

END


I figured I must have missed something??

On another front:

  In order to compile test 5 from BXBASIC.txt I needed to compile BxbLib.c.
Was there a reason for _stdcall? I removed it and used proto c when adding the Float2Str2 proto to bxb.inc.
Compiled and worked fine. On linux the conversion routine is gcvt.

James



SteveA

  • Guest
Re: BxbAsm
« Reply #142 on: April 18, 2012, 08:12:49 AM »
Quote
In order to compile test 5 from BXBASIC.txt I needed to compile BxbLib.c.
Was there a reason for _stdcall?

No, that's a windows thing.
They should be normal C calls.

Quote
I removed it and used proto c when adding the Float2Str2 proto to bxb.inc.
Compiled and worked fine. On linux the conversion routine is gcvt.

Right.




jcfuller

  • Guest
Re: BxbAsm
« Reply #143 on: April 18, 2012, 08:17:03 AM »
Steve,
  I found my error. I missed uncommenting  in Input.c

James

SteveA

  • Guest
Re: BxbAsm
« Reply #144 on: April 18, 2012, 08:17:56 AM »
Bxblib.inc, in /../Include, needs to be changed:

Here is how it reads:

Code: [Select]
testlib      proto stdcall
value2strng  proto stdcall :REAL8, :SBYTE
FloatToStr2  proto stdcall :REAL8, :PTR DWORD
ClearScreen  proto stdcall
locate       proto stdcall :DWORD, :DWORD
StrToFloat   proto stdcall :PTR DWORD, : PTR QWORD

remove all "stdcall".

SteveA

  • Guest
Re: BxbAsm
« Reply #145 on: April 18, 2012, 08:33:28 AM »
When uncommenting, check these, in this order:

1)  Input.c, --> get_byte()

2)  Bxbasm.c --> parser()

3)  prototype.h  --> any/all

4)  the functions themselves, in whatever filename.c
     prototype.h lists file name.

jcfuller

  • Guest
Re: BxbAsm
« Reply #146 on: April 18, 2012, 10:48:03 AM »
Steve,
  I would like to suggest a different approach for os dependent items.
Instead of outputing asm to be compiled use a precompiled library and link to it.
Case in point cls.
I created an object file with this code
Code: [Select]
#include <stdio.h>
#include <curses.h>
// clear console screen linux
char    ESC [2]={27,0};  // Escape
void cls(void);
void cls(void)
{
printf("%s%s%s%s",ESC,"[2J",ESC,"[H");
}
compiled with gcc -c cls.c

I then added it to a library with ar:

ar cr libbxbasm.a cls.o

I then linked this library when compiling test1.asm with this script:
Code: [Select]
~/jwasm/jwasm -elf -zcw -Fo=$1.o $1.asm
gcc -s -nostartfiles -o $1 $1.o /home/james/bxbasmx/bxblib/BxbLib.o -L/home/james/bxbasmx/bxblib -lbxbasm


Your console routines seem to be in spread out in more than one file. Your Do_color is in AVars.c while Do_locate is in AFunc.
Can these be moved to individual files, compiled, then added to a static library?
James


SteveA

  • Guest
Re: BxbAsm
« Reply #147 on: April 18, 2012, 11:15:38 AM »
  I would like to suggest a different approach for os dependent items.
Instead of outputing asm to be compiled use a precompiled library and link to it.

I think that is a great idea.


Quote
Your console routines seem to be in spread out in more than one file.
Your Do_color is in AVars.c while Do_locate is in AFunc.
Can these be moved to individual files, compiled, then added to a static library?

Yes,
I previously wasn't too concerned with where they ended up.
Okay, I'll gather up all the win32/console functions and put them in a seperate file.
Would you suggest a seperate file or would you prefer a seperate LIB ?
Like: console.c or console.lib ?




jcfuller

  • Guest
Re: BxbAsm
« Reply #148 on: April 18, 2012, 01:23:38 PM »
Steve,
  To keep it as granular as possible put each func in a file by itself and compile them separately. Combine the obj files to create a library. That will also will help me on the Linux side to see just what needs to be supplied.

James

SteveA

  • Guest
Re: BxbAsm
« Reply #149 on: April 19, 2012, 01:00:39 PM »
Hey james,
were you able to get any of the deleted functions working ?

Do the normal C library functions seem to be working okay ?