flat assembler
Message board for the users of flat assembler.

Index > Linux > Basic to ASM compiler for Linux/BSD

Goto page 1, 2  Next
Author
Thread Post new topic Reply to topic
janick



Joined: 27 Aug 2004
Posts: 4
janick 27 Aug 2004, 11:21
I've searched for weeks for a BASM-like compiler for Linux/BSD.

It does NOT exist yet, is there anyone who can program such a thing ?


For those of you who do not know what BASM is, it's a Basic to ASM
compiler that creates extremely small .COM and .EXE files under DOS.

You can download the basmv650.zip here : http://xs1.com/basic2asm

There are lots of samples (source & compiled) included.

The intended use is large scale CGI development in BASIC, running
on the THTTPD webserver ( http://www.acme.com ).

Currently the THTTPD webserver serves a max of 2000 users at once.
PHP has a max of 80 scripts running at once, C does around 300.

ASM would do around 800, which makes it possible to create a great chatscript in BASIC without programming C or slowish PHP/Perl.

The BASM (Basic to ASM) sourcecode is included in the zip, this will certainly make it easier (and faster) to develop the compiler.

If anyone likes to collaberate, let me know !
Post 27 Aug 2004, 11:21
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 27 Aug 2004, 12:01
Why not just use macros? You can get pretty close to BASIC's syntax and commands with nothing but assembler macros...
Post 27 Aug 2004, 12:01
View user's profile Send private message Visit poster's website Reply with quote
janick



Joined: 27 Aug 2004
Posts: 4
janick 27 Aug 2004, 20:03
crc wrote:
Why not just use macros? You can get pretty close to BASIC's syntax and commands with nothing but assembler macros...

Do you have a good link for that, all I can find is mainframe stuff.

Check out the BASM link in my first post, try it, you'll love it.

Would be great to use that on linux !
Post 27 Aug 2004, 20:03
View user's profile Send private message Reply with quote
fasm9



Joined: 19 Jun 2003
Posts: 439
fasm9 27 Aug 2004, 23:31
http://www.purebasic.com

purebasic backend is FASM.
It is Available on windows, linux.

--
PS: Personally i prefer c, not basic.
Cheers
Post 27 Aug 2004, 23:31
View user's profile Send private message Reply with quote
janick



Joined: 27 Aug 2004
Posts: 4
janick 30 Aug 2004, 12:35
fasm9 wrote:
http://www.purebasic.com

purebasic backend is FASM.
It is Available on windows, linux.

PS: Personally i prefer c, not basic.


1. Linux ASM is not the same as FreeBSD ASM (unix). I don't want comp mode.
2. I like a simple commandline compiler.
3. PHP is very C-like. Basic is much easier for CGI development.


Anyone here capable of rewriting / adjusting BASM ?
Post 30 Aug 2004, 12:35
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 30 Aug 2004, 13:36
The problem here is that BASIC requires a pretty large library of functions. Implementing a parser/converter for the language isn't a problem. Writing the library code is.

You're right that FreeBSD and Linux are different from a programmer's perspective. But they aren't that different. It's easy to adapt an assembly program for Linux to run on FreeBSD. Look at asmutils (written in nasm, but the principle applies) which can be reassembled for various OSes with minor changes.
Post 30 Aug 2004, 13:36
View user's profile Send private message Visit poster's website Reply with quote
rob.rice



Joined: 20 Dec 2003
Posts: 54
rob.rice 13 Oct 2004, 18:56
crc wrote:
The problem here is that BASIC requires a pretty large library of functions. Implementing a parser/converter for the language isn't a problem. Writing the library code is.

You're right that FreeBSD and Linux are different from a programmer's perspective. But they aren't that different. It's easy to adapt an assembly program for Linux to run on FreeBSD. Look at asmutils (written in nasm, but the principle applies) which can be reassembled for various OSes with minor changes.


If you have gcc installed you already have the librarys installed you just have to adpt to them
there some examples of how to do this in the fasm package (but you can do better in asm than thay have ben done in C )
Post 13 Oct 2004, 18:56
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 14 Oct 2004, 01:26
You still run into translation problems: you'd have to convert BASIC into a subset of C, then call the C libraries. This is because C libraries are not compatible cleanly with the BASIC way of doing things.
Post 14 Oct 2004, 01:26
View user's profile Send private message Visit poster's website Reply with quote
penang



Joined: 01 Oct 2004
Posts: 59
penang 14 Oct 2004, 04:14
[quote="fasm9"]http://www.purebasic.com

purebasic backend is FASM.
It is Available on windows, linux.

--
PS: Personally i prefer c, not basic.
Cheers[/quote]


Actually, the backend is NASM. See www.purebasic.com/introduction_linux.php3
Post 14 Oct 2004, 04:14
View user's profile Send private message Reply with quote
Tomasz Grysztar



Joined: 16 Jun 2003
Posts: 8356
Location: Kraków, Poland
Tomasz Grysztar 14 Oct 2004, 08:33
It has switched from NASM to FASM since 3.50, see http://www.purebasic.com/news.php3
Post 14 Oct 2004, 08:33
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 14 Oct 2004, 11:08
purebasic doesn't work on FreeBSD without emulation mode, which the original poster doesn't want to use.
Post 14 Oct 2004, 11:08
View user's profile Send private message Visit poster's website Reply with quote
Crunch



Joined: 09 Dec 2003
Posts: 10
Crunch 14 Oct 2004, 18:02
Don't have any direct experience with XBASIC, but thought I'd mention it since it looks interesting from afar. It's open source GPL/LGPL.

Here's a quote from their FAQ:
"FAQ - XBasic implementation

What language is XBasic written in?
XBasic is written entirely in XBasic, except for 400KB of assembly language - most of that is comments. XBasic does not call any functions in any C function library. XBasic is self-contained - the only functions XBasic calls are operating-system API functions. Linux XBasic implements all its graphics and message processing by calling functions in the low-level XWindows xlib function library.

Is XBasic really a compiler, or does it interpret some intermediate language?
When you run programs in the XBasic program development environment, XBasic translates your XBasic source program directly into executable binary machine instructions in RAM memory, then executes it. When you have finished debugging an XBasic program, you can compile it into an assembly language file. XBasic also creates a makefile containing the steps required to assemble and link the assembly language file to create an executable - either an EXE or DLL."

I assume the core assembly is in MASM yet may give you many ideas.

http://xbasic.sourceforge.net/

Don't know whether or not it's FreeBSD friendly, but I found the following link which seems interesting and seems to imply that XBasic was used in creating FreeBSD LiveCD 1.2.4 (current version).

http://sourceforge.net/projects/livecd

Hope it's helpful and not annoying!

Rolling Eyes
Post 14 Oct 2004, 18:02
View user's profile Send private message Reply with quote
rob.rice



Joined: 20 Dec 2003
Posts: 54
rob.rice 18 Dec 2004, 17:35
crc wrote:
You still run into translation problems: you'd have to convert BASIC into a subset of C, then call the C libraries. This is because C libraries are not compatible cleanly with the BASIC way of doing things.


you do all the translation in the compiler from the point of view of there is
nothing but basic
the c libraries are so low levle that it dosen't matter what lanuage you use to call them
there are example of other lanuages that use them like pascal fortran java
other than being HILLs thay look nothing like C
as a short cut you could work on a front end to gcc and have gcc do most of the work for you
as a fact of the matter fortran is so close to basic that it woulden't tack much to change it's front end to compil basic
or learn fortran most of what you already know about basic applys to fortran
some of the key words differ but the style and syntax are the same

befor you tell me I'm wrong have a good look at some fortran source code
if you can read basic source you can read fortran source code
Post 18 Dec 2004, 17:35
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 18 Dec 2004, 18:32
Quote:
you do all the translation in the compiler from the point of view of there is
nothing but basic


The difficulty is in writing the compiler. I can write a subset of BASIC in Forth easily, but writing a complete set of library code that would be cleanly interfaced is a different story.

Quote:
the c libraries are so low level that it dosen't matter what lanuage you use to call them


Sure it does. I mostly use Forth, and there's quite a bit of translation to handle different calling conventions. (The same problems arise with libraries used by some versions of pascal). Once you start relying on the C libraries, you lose the advantage of having compact code. Yes you can optomize some things, but the external functions will seldom (if ever) be as fast as carefully written code.

Quote:
as a short cut you could work on a front end to gcc and have gcc do most of the work for you
as a fact of the matter fortran is so close to basic that it woulden't tack much to change it's front end to compile basic


Go ahead. I don't have the time or desire to even attempt to learn the GCC source well enough to wriite/adapt a new front end to it.

Quote:
or learn fortran most of what you already know about basic applys to fortran
some of the key words differ but the style and syntax are the same


True to a point. FORTRAN goes far beyond Basic in terms of language complexity. Basic was created to make it easier to teach FORTRAN later.
Post 18 Dec 2004, 18:32
View user's profile Send private message Visit poster's website Reply with quote
rob.rice



Joined: 20 Dec 2003
Posts: 54
rob.rice 25 Jan 2005, 06:50
fourth is about the olny major programming lanuage there is and there is even a
gnu version that uses the standard c libs
there is a BASIC thats uses the clibs and outputs assembly with gas as the back
end
about fortran you don't need to use the full complexity you can stick
to the subset you know from BASIC]]]
Post 25 Jan 2005, 06:50
View user's profile Send private message Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 25 Jan 2005, 11:21
Code:
C     Hello World in Fortran

      PROGRAM HELLO
      WRITE (*,100)
      STOP
  100 FORMAT (' Hello World! ' /)
      END
    


Code:
       PROGRAM HELLO
c
C      Hello World in Fortran IV (supposedly for a TR440)
c
       WRITE (6,'('' Hello World!'')')
       END    


Code:
C     Hello World in Fortran 77

      PROGRAM HELLO
      PRINT*, 'Hello World!'
      END    


Fortran has quite a bit more red tape than BASIC from what I've seen of it in the examples I looked at. Even simple things like "Hello World" involve more typing a bit more red tape than BASIC does.
Post 25 Jan 2005, 11:21
View user's profile Send private message Visit poster's website Reply with quote
crc



Joined: 21 Jun 2003
Posts: 637
Location: Penndel, PA [USA]
crc 25 Jan 2005, 11:26
Quote:
fourth is about the olny major programming lanuage there is and there is even a
gnu version that uses the standard c libs


At the same time, gForth is kind of bloated and a bit slower than it needs to be. My Forth is tiny (4-6k depending on compile-time options), and is faster than gForth, even with the optional C library support code. Dealing with external libs is a pain even in the best case though. I have to do a lot of internal work to mask the differences in register use, calling conventions, and so on. It isn't fun to code the backend for dealing with C libraries.
Post 25 Jan 2005, 11:26
View user's profile Send private message Visit poster's website Reply with quote
rob.rice



Joined: 20 Dec 2003
Posts: 54
rob.rice 08 Mar 2005, 06:54
GNU fortran is an ansi77 fortran so there's not that much red tape
I would love to learn forth the big problem I'm haveing is that there is no
forth system that matches any of the documentation I can find and who ever writes
a forth interpter dosen't do tutorials for there forth
Post 08 Mar 2005, 06:54
View user's profile Send private message Reply with quote
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware 08 Mar 2005, 16:33
rob.rice wrote:
GNU fortran is an ansi77 fortran so there's not that much red tape
I would love to learn forth the big problem I'm haveing is that there is no
forth system that matches any of the documentation I can find and who ever writes
a forth interpter dosen't do tutorials for there forth

Hi, Rob -

There are some good tutorials on Forth. A good system to download and play with is "pforth", which is written in C and can be compiled on Windows or Linux with equal ease.

The problem you are encountering is that there is a standard -- the "ANS Forth" standard -- which is more of a suggestion than anything else.
My system for instance is not ANS standard (by design) -- my goal is to only include what is needed for my purposes.

If you need more information or pointers on Forth, feel free to email me (via my website).
Post 08 Mar 2005, 16:33
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
ronware



Joined: 08 Jan 2004
Posts: 179
Location: Israel
ronware 08 Mar 2005, 18:36
crc wrote:
Code:
C     Hello World in Fortran

      PROGRAM HELLO
      WRITE (*,100)
      STOP
  100 FORMAT (' Hello World! ' /)
      END
    

...

Fortran has quite a bit more red tape than BASIC from what I've seen of it in the examples I looked at. Even simple things like "Hello World" involve more typing a bit more red tape than BASIC does.

Hi, Charles -

Why didn't you bring a RetroForth (or Reva) example?
Code:
| Hello world in Forth
." Hello world!" cr bye
    
Post 08 Mar 2005, 18:36
View user's profile Send private message Visit poster's website AIM Address Yahoo Messenger Reply with quote
Display posts from previous:
Post new topic Reply to topic

Jump to:  
Goto page 1, 2  Next

< Last Thread | Next Thread >
Forum Rules:
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum


Copyright © 1999-2024, Tomasz Grysztar. Also on GitHub, YouTube.

Website powered by rwasa.