Author Topic: BxbAsm  (Read 178819 times)

SteveA

  • Guest
Re: BxbAsm
« Reply #105 on: April 13, 2012, 01:20:55 PM »
Okay,
here is the latest version of Bxbasm, without any Windows GUI specific stuff added.
It dates back to 03-13-12.
...okay..., so that was a month ago.
It has a number of small functions added from the CRT and some minor refinements.

The single zip file contains a cluster of zips within. Each zip is labeled as to the location where it should be unzipped.
Example:
      bin-folder.zip:  ../jwasm/bin/*.*        ::contains a win32 EXE and batch files I use to compile,
bxbasm-folder.zip:  ../jwasm/bxbasm/*.*  ::(or working directory) contains bxbasm needed include files,
  inc-lib-folder.zip:  ../jwasm/Include/*.*  :: bxbasm include file
                           ../jwasm/Lib/*.*        :: bxbasm lib file

I have not made any changes to bxblib.lib, so, the sources for that file remain the same as the prior version.

James,
if you run into the same *snag* as before, please let me know what it pertains to.
I'd like to resolve that problem.

And, the same to anyone else..., since there has been minimal testing, I'd like to be made aware of the breaking points.

Thanks,
Steve


P.S.
the document Bxbasic.txt contains a listing of the most recent function additions in chronological order.
« Last Edit: May 02, 2012, 03:30:44 PM by SteveA »

jcfuller

  • Guest
Re: BxbAsm
« Reply #106 on: April 13, 2012, 04:06:59 PM »
Steve,
  In my opinion you need to eliminate all Windows api code in your bas -> asm translation.
I don't even have a number of of the jwasm inc files you stuff in the asm code.

I can compile bxbasm.c with gcc and tcc on windows using:

Code: [Select]
/* Bxbasm.c : Masm, JWasm  alpha version 1.06.3 */
/* Bxbasic, Bxbasm (C) Copyright sarbayo, 2004-2012 */


//#define LccWin32


/*--------------------- DECLARE HEADERS ---------------------*/
/*----------------------               ----------------------*/
#include <stdio.h>
#include <conio.h>
#include <io.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <malloc.h>
#include <math.h>
#include <time.h>
//#include <winuser.h>
//#include <windows.h>
#include <direct.h>
#include <stdbool.h>

and by eliminating:
//SetConsoleTitle(t_holder);

in main()


I know this is an alpha but I see no way to port it with the windows specific asm source output.


It compiled on linux by eliminating:
#include <conio.h>
#include <io.h>
#include <winuser.h>
#include <windows.h>
#include <direct.h>

but still hangs after printing the copyright and destination file name when attempting to translate a bas file to asm.

James



SteveA

  • Guest
Re: BxbAsm
« Reply #107 on: April 13, 2012, 04:57:46 PM »
Here is a Win32 (exclusive) version that incorporates some GDI functions.

SteveA

  • Guest
Re: BxbAsm
« Reply #108 on: April 13, 2012, 05:20:02 PM »
In my opinion you need to eliminate all Windows api code in your bas -> asm translation.
I don't even have a number of of the jwasm inc files you stuff in the asm code.

In a Linux version I would do just that.
Bare in mind, I am working with a Win32 system.
There is no way to write one single piece of code that is going to compile on both a Win32 and Linux system.
I didn't expect the Win32 version to compile correctly, under Linux, without modifications.

Yes, I've had to add new INC files to jwasm, as jwasm is missing many headers and/or some don't work correctly.


Quote
...and by eliminating:
//SetConsoleTitle(t_holder);

in main()

I know this is an alpha but I see no way to port it with the windows specific asm source output.

No..., you are right.
That part of the code needs to be changed to whatever Linux requires.
As I've indicated, I do not have a Linux system setup at this time and I am unfamiliar with the Linux API.

It can be ported by substituting the win32 specific function calls with the correct Linux calls.
Are you saying, for instance, Linux has no substitution for "SetConsoleTitle" ?

Quote
It compiled on linux by eliminating:
#include <conio.h>
#include <io.h>
#include <winuser.h>
#include <windows.h>
#include <direct.h>

but still hangs after printing the copyright and destination file name when attempting to translate a bas file to asm.

There are a number of required functions within those headers. That may be the problem.

Offline John

  • Forum Support / SB Dev
  • Posts: 3597
    • ScriptBasic Open Source Project
Re: BxbAsm
« Reply #109 on: April 13, 2012, 05:51:24 PM »
Maybe it would be easier to port if there was a working version on whatever platform.

My vote is to get a stable Windows version going. (largest user base)

This will give you time to get up to speed with Linux.

Charles (O2) is getting his arms around Linux as well. He is a member/developer here and I hope he finds time to  chime in.

I find this project interesting because of the intermediate ASM source code that is generated. Once it works, the fun begins when the hard core ASM guys feel the need to tweak it just a bit more.  :D
« Last Edit: April 13, 2012, 06:01:47 PM by JRS »

jcfuller

  • Guest
Re: BxbAsm
« Reply #110 on: April 14, 2012, 04:24:24 AM »

Quote
There is no way to write one single piece of code that is going to compile on both a Win32 and Linux system.

I did it with ubx with just one CONSTANT (#define).

I am also working on bcx9 which is a windows only app but will spit out *nix compatable source on demand.

This is what I use for linux:
Code: [Select]
// *********************************************************************
// Created with BCX32 - BASIC To C/C++ Translator (V) 9.0.0.7 (2012/03/23)
//                 BCX (c) 1999 - 2012 by Kevin Diggins
// *********************************************************************
//          Translated for compiling with an ANSI/ISO C Compiler
// *********************************************************************
#include <ctype.h>      // dos/linux
#include <fcntl.h>      // dos/linux
#include <math.h>       // dos/linux
#include <stdio.h>      // dos/linux
#include <string.h>     // dos/linux
#include <stddef.h>     // dos/linux
#include <stdlib.h>     // dos/linux
#include <setjmp.h>     // dos/linux
#include <time.h>       // dos/linux
#include <stdarg.h>     // dos/linux
#include <sys/types.h>
#include <sys/stat.h>   
#include <wchar.h>      // linux only
#include <stdbool.h>    // linux only
#include <dirent.h>     // linux only
#include <sys/wait.h>   // linux only
#include <unistd.h>     // linux only
#include <dlfcn.h>      // linux only
#include <termios.h>    // linux only

and this is for Windows:

Code: [Select]
// *********************************************************************
// Created with BCX32 - BASIC To C/C++ Translator (V) 9.0.0.7 (2012/03/23)
//                 BCX (c) 1999 - 2012 by Kevin Diggins
// *********************************************************************
//          Translated for compiling with an ANSI/ISO C Compiler
// *********************************************************************
#include <process.h>    // dos
#include <conio.h>      // dos
#include <direct.h>     // dos
#include <io.h>         // dos
#include <ctype.h>      // dos/linux
#include <fcntl.h>      // dos/linux
#include <math.h>       // dos/linux
#include <stdio.h>      // dos/linux
#include <string.h>     // dos/linux
#include <stddef.h>     // dos/linux
#include <stdlib.h>     // dos/linux
#include <setjmp.h>     // dos/linux
#include <time.h>       // dos/linux
#include <stdarg.h>     // dos/linux
#include <sys/types.h> 
#include <sys/stat.h>   


There are big differences in console/terminal manipulation code( pos,locate,color...) as Linux uses escape sequences (ala old dos)
 where with windows you do need the winapi.

I have the code if you want it when you reach that stage but first I think you need to create code that only uses the standard "c" libraries.

James

jcfuller

  • Guest
Re: BxbAsm
« Reply #111 on: April 15, 2012, 05:38:49 AM »
Steve,
  I tried to track down the problems on Linux to no avail. It appears to hang at different places depending on the source to be translated.
I ran it against valgrind but it did not help.
I am really a novice when it comes to linux (and "c") so unless an experienced linux lurker helps out I'm afarid it's windows only.

James

SteveA

  • Guest
Re: BxbAsm
« Reply #112 on: April 15, 2012, 03:08:21 PM »
Maybe it would be easier to port if there was a working version on whatever platform.

Maybe...,.
This version does work, as long as you don't expect more than linear, console mode apps.

There was a small learning (more like remembering) curve, at the start, but, once I revisited my old source code and understood it (again) I was able to get a handle on Jwasm. I pretty much think I have a better understanding of Jwasm (or rather, the collection of utilities which I refer to as the "Jwasm package", since they are designed to work together). So far, Jwasm does not appear to be especially buggie, altho' it does have a few (minor) problems that I think I can live with. Even Masm has a number of known bugs that require work-arounds.

Quote
Once it works, the fun begins when the hard core ASM guys feel the need to tweak it just a bit more.

There are a few things I would change (tweak),  pretty much right off the bat. They just aren't too important to me at the moment.

SteveA

  • Guest
Re: BxbAsm
« Reply #113 on: April 15, 2012, 03:47:20 PM »
Quote from: steve
There is no way to write one single piece of code that is going to compile on both a Win32 and Linux system.

I did it with ubx with just one CONSTANT (#define).

Okay, I should have been more clear.
I never was writing a strictly console mode app.
Much of Bxbasic (interpreter) is built upon a blend of C Library (console) and win32 console mode utilities and functions.
I took the same approach in designing Bxbasm: "I used from all available parts".

I pretty much figured that if the Win32 API has a function called "foo.api" and I use it for its intended purpose, (for simplicity, let's say to clear the screen, for instance), then Linux must have a corresponding function, maybe its called: koo.??, or poo.??, or boo.??, or ???.??, that clears the screen.
Simple..., you do a one for one switch.
I must be in error.
I must have assumed too much.

Quote
There are big differences in console/terminal manipulation code( pos,locate,color...) as Linux uses escape sequences (ala old dos)
 where with windows you do need the winapi.

From what I'm gathering, I may have to approach Linux programming more like programming MS-DOS.
Does Linux use an API, or do you call interrupts and ANSI.SYS functions, like DOS ?

Quote
I have the code if you want it when you reach that stage but first I think you need to create code that only uses the standard "c" libraries.
Well, (in my opinion), to change Bxbasm to the point that: "you need to create code that only uses the standard "c" libraries", would seriously be a step backwards.
Now, that said, what I can do is to make a modified version, specifically for a Linux port, that "only uses the standard "c" libraries".
It will be devoid of some existing functionality.
I already know what some of that will be, as I used win32 API functions to create that functionality.

I'll see what I can do and what we end up with.
Let you know, soon.

SteveA

  • Guest
Re: BxbAsm
« Reply #114 on: April 15, 2012, 08:13:14 PM »
Okay,
here it is.
Totally untested, but, it compiles without errors.
This is, as far as I can tell, using no win32 functions.
C runtime library only.

Let me know if it compiles under GCC and if it produces working assembly code.
Thanks.

edit:
I deleted this attachment, as it was full of glitches.
« Last Edit: April 16, 2012, 07:09:10 PM by SteveA »

jcfuller

  • Guest
Re: BxbAsm
« Reply #115 on: April 16, 2012, 03:21:58 AM »
Steve,
  Same results on linux. Compiles fine but hangs when translating basic source to asm.
 Need ctrl-c to return to terminal prompt.

I doctored up the previous version with numerous printf's to see if I could find out why but it failed in different places depending
on the source being translated. I am not proficient enough in "c" debugging to help much more than that.

James

 

jcfuller

  • Guest
Re: BxbAsm
« Reply #116 on: April 16, 2012, 04:28:03 AM »
Steve,
  This is a sample of the output with printf's added by me on two samples;Sub1 and ucase
James

Sub1:
Code: [Select]
james@magic-micro ~/bxbasmx/examples $ ../Bxbasm Sub1
Copyright: Blunt_Axe_Basic, BxbAsm, Bxbasic (c) sarbayo, 2004-2012
Alpha Release: 1.06.3, Bxbasm Compiler

** stripped down version for Linux

before init_fldbffrs()
back from init_fldbffrs()
back from load_src
back from loader_1
In loader_2 nrows = 28
temp_byte[ndx] = 56
temp_byte[ndx] = 56
temp_byte[ndx] = 56
temp_byte[ndx] = 56
temp_byte[ndx] = 46
temp_byte[ndx] = 46
temp_byte[ndx] = 46
temp_byte[ndx] = 59
temp_byte[ndx] = 59
temp_byte[ndx] = 59
temp_byte[ndx] = 59
temp_byte[ndx] = -1
temp_byte[ndx] = 8
temp_byte[ndx] = 57
temp_byte[ndx] = 4
temp_byte[ndx] = 58
temp_byte[ndx] = 57
temp_byte[ndx] = 4
^C

ucase:

Code: [Select]
james@magic-micro ~/bxbasmx/examples $ ../Bxbasm ucase
Copyright: Blunt_Axe_Basic, BxbAsm, Bxbasic (c) sarbayo, 2004-2012
Alpha Release: 1.06.3, Bxbasm Compiler

** stripped down version for Linux

before init_fldbffrs()
back from init_fldbffrs()
back from load_src
back from loader_1
In loader_2 nrows = 10
temp_byte[ndx] = 46
temp_byte[ndx] = 1
temp_byte[ndx] = 4
temp_byte[ndx] = 4
temp_byte[ndx] = 1
temp_byte[ndx] = 4
temp_byte[ndx] = 1
temp_byte[ndx] = 4
temp_byte[ndx] = -1
temp_byte[ndx] = 8
after loop nrows = 10
back from loader_2
back from line_cnt
Destination file: ucase.asm
^C
james@magic-micro ~/bxbasmx/examples $


jcfuller

  • Guest
Re: BxbAsm
« Reply #117 on: April 16, 2012, 04:53:11 AM »
Steve,
  Also note there is no CR (13) in linux text files. All lines end with just a LF (10).
gcc on linux will handle both I believe but if you are checking for CR anywhere it will probably fail.

James

SteveA

  • Guest
Re: BxbAsm
« Reply #118 on: April 16, 2012, 05:50:56 AM »
Also note there is no CR (13) in linux text files. All lines end with just a LF (10).
gcc on linux will handle both I believe but if you are checking for CR anywhere it will probably fail.

Yes, I am testing for CR, in a number of places.
That is a major development !

Ok, let me look at it and see if I can find them.

jcfuller

  • Guest
Re: BxbAsm
« Reply #119 on: April 16, 2012, 06:29:56 AM »
Steve,
  I traced the Sub1 hang to an endless loop in str_func2.

James