by Alexander F Rødseth
Different take on assembly, with the goal of creating tiny executables.

Battlestar is:

  • A work in progress.
  • Created for fun and for the educational process.
  • A programming language specifically for 64-bit x86 Linux, 32-bit x86 Linux, 32-bit x86 OS X and 16-bit x86 DOS.
  • Subset of assembly with different syntax and support for inline C.
  • The indended purpose is for writing 4k and 64k demoscene demos.

Features:

  • The resulting executables are tiny!
  • "hello world" is only 129 bytes on 32-bit Linux (when using sstrip from elfkickers).
  • It's possible to write an operating system with only one source file.
  • Full support for inline C (by utilizing an external compiler like gcc or tcc).
  • C and Battlestar code can exist in the same source file and calls can be made both ways.
  • Battlestar programs compile almost instantly.
  • Programs can be run like scripts by including this line at the top: #!/usr/bin/bts
  • Interrupts can be called with the same syntax for both 32-bit and 64-bit x86 on Linux.
  • Also supports 16-bit x86 with DosBox.
  • The intermediate assembly is fully commented.

See more examples at rosettacode and samples that comes with the project.

// Fibonacci sequence, recursive version
fun fibb
    loop
        a = funparam[0]
        break (a < 2)
 
        a--
 
        // Save "a" while calling fibb
        a -> stack
 
        // Set the parameter and call fibb
        funparam[0] = a
        call fibb
 
        // Handle the return value and restore "a"
        b = funparam[0]
        stack -> a
 
        // Save "b" while calling fibb again
        b -> stack
 
        a--
 
        // Set the parameter and call fibb
        funparam[0] = a
        call fibb
 
        // Handle the return value and restore "b"
        c = funparam[0]
        stack -> b
 
        // Sum the results
        b += c
        a = b
 
        funparam[0] = a
 
        break
    end
end
 
// vim: set syntax=c ts=4 sw=4 et:
Information updated 04/04/16
View Comments