Giter Club home page Giter Club logo

b0's Introduction

B0

Copyright © 2000-2008, Darran Kartaschew

Introduction

The B0 language and compiler came about during an effort to create my own Operating System. The main problem faced, was the C was too high level, and coding in assembler was a pain (even though 80% of my code is pure asm, and the other 20% is PHP for work).

Being soley an assembler programmer for many years gave me a pure unrestricted environment to play in, rather than being locked down to a particular environment. Which always left a bad taste in my mouth, whenever I worked with many of the HLLs out there, (ever tried a bitwise rotate in C?). I wanted the freedom that assembler gave me, but have a HLL programming style.

I looked Randall Hyde's HLA, and while the syntax is more HLL programmer friendly, it still didn't gel with me. Plus I was limited to a particular OS (Windows or Linux), becuase of the standard library it used. (Which by the way is a great library, just doesn't suit my needs as it stands).

At first B0, may look like C, but once you get down and dirty, you quickly realise that it's not a bastardised C clone, but something else. The best way I would describe it, is a HLL designed to be machine dependent based a 64bit architecture.

A quick word on licensing: The B0 language and this implementation are released under a BSD license.

System Requirements

Either a IA-32 w/EM64T or AMD64 based processor, for 64bit Operation.
Minimum 512MB of RAM (The compiler requires approximately 140MB when compiling applications).
64bit OS. (Any with a C compiler, and somewhat basic libc support).
FASM v1.67.27+ (used as a backend assembler - Hi Tomasz).
Text Editor supporting UTF-8 (Unicode Output).
Code Example

//Program 'Hello World';
lib 'stdlib.b0';
proc main(){ 
    r0 = &'Hello World™\n'; 
    echo(r0); //echo() prints the string pointed to by r0 to stdout 
    exit(r0);
}; 
The always present 'Hello World™' example.

Unfortunately, this little example doesn't give away that much...

As you can see, it looks a lot like C and quite a few other languages. But the make up of each statement is very simple, and in most cases match the assembler output nearly 1:1.

Hopefully some of the other code snippets will highlight this.

What makes it different from other languages

Nothing really, except that it's very minimalist and you get to play with the CPU registers within the acutal code itself. (The code focuses around the registers).

Is it Assembler or a High Level Language, or both?

Well that depends on your view of things. It's assembler, since it provides near 1:1 correspondance to actual machine instructions, but it's HLL since the code is constructed as a HLL.

It's a debate that I don't want to get into, but you may even want to call it a HLA (High Level Assembler), but I wouldn't go that far. Personally I believe it's a hybrid, or a machine dependant HLL. On the generation scale, eg 1GL (straight hex), 2GL (assembler), 3GL (HLL), 4GL (VHLL/Natural), I would place it about 2.9GL.

What's Supported

Here is a quick list of the current programetic support:

variable declarations (any location within code).
array declarations.
procedures, with inline parameter passing.
if-then, if-then-else and while-do C style constructs.
Inclusion of other files. (lib keyword).
pointer assignment, and global pointer access. (both simple and complex pointers).
unsigned integer and bitwise operations (add, sub, mul, div, mod, and, not, xor, or, shifts, rotates, neg).
signed integer operations (mul, div, mod).
floating point math operations. (add, sub, mul, div, neg).
vector operations (integer and floating point).
inline assembler. (Pass through to backend assembler).
direct calling of OS API (via syscall keyword).
symbol definitions (equates) and conditional compilation support.
Support for structures.
Basic macro support.
Spinlock and Mutex support.
What's NOT supported (and most likely never will)

Here is a quick list of stuff is isn't currently supported, and most likely never will be:

Compound operations.
Logical boolean operations.
Direct variable -> variable operations.
These are simple too high level...


B0 Compiler Package
(c) Darran Kartaschew 2000-2008

Released under a BSD licence.

This package contains the b0 compiler and basic libraries needed
to produce GNU\Linux 64bit (x86_64), FreeBSD 64bit, Solaris 11 x64
or Windows x64 based applications. The compiler must be compiled 
from source code before it can be used.

(A 32bit version for i386 systems can also be built, by either
running 'make b0-ia32', 'build i386' or uncommenting '#define i386'
in ./src/b0.c).

Pre-requisites:
b0 only requires gcc 3.x, glibc (Development packages) and FASM. Most
GNU/Linux distro's have these installed by default. GNU Make is 
also needed to compile the compilers source, but you can build
it manually if you so desire.

For Windows XP x64 or Windows Vista x64, you'll need VC++ 2003,
VC++ 2008 or VC++ 2005 Express Edn and FASM. Both VC++ 2003, 
VC++ 2008 and VC++ 2005 Express Edn are available at no cost from 
MS for non-commercial purposes. When obtaining VC++ 2005 Express Edn, 
be sure to also download the latest Windows SDK to obtain the latest 
API documentation.

To install (GNU/Linux, FreeBSD, Solaris):
>$ make linux 
>$ gmake solaris
>$ gmake freebsd
>$ su -c "make install"
>$ make clean

To install (Windows):
> build
> build install
> build clean

Then add the environment variable B0_INCLUDE=/usr/local/include/b0
eg.
>$ SET B0_INCLUDE=/usr/local/include/b0

or alternatively within ~/.profile add:

export B0_INCLUDE="/usr/local/include/b0"

and for Windows:
1. Right-click 'My Computer' and select 'Properties'
2. Select 'Advanced' Tab and 'Environment Variables'
3. Add it in under 'User'.

To Uninstall (as root):
># make uninstall for Linux
># gmake uninstall for FreeBSD/Solaris
># build uninstall for Windows

Once installed, runtime configuration can be viewed by
>$ man b0

A pdf manual can be built, however requires html2ps and Ghostscript
to be installed, and therefore is not created by default. 
Note: The manual is provided as html by default, and is found in the
./doc directory. To make a pdf version of the user manual type
>$ make docs

The file 'b0.pdf' will be created, which can be viewed with any pdf 
viewer. 

Several examples for Linux, FreeBSD, Solaris and Windows x64 can be
found in the ./examples directory.

For further documentation see: ./doc/b0.html

b0's People

Contributors

8l avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.