Skip to content

Instantly share code, notes, and snippets.

@thosakwe
Created April 19, 2018 17:59
Show Gist options
  • Save thosakwe/a95cb75e1d0bab8799bc3de85adc4100 to your computer and use it in GitHub Desktop.
Save thosakwe/a95cb75e1d0bab8799bc3de85adc4100 to your computer and use it in GitHub Desktop.
μasm

What?

An ASM-inspired language that uses some familiar constructs to make building ASM easier.

It's basically ASM, but labels are given a function syntax. There also exists the concept of pointers, which are converted into address literals.

Declaring external functions is also supported, which makes it possible to verify the syntax of calls at compile time.

All in all, the compiler will be written in C++, and should in theory be quite fast, because in reality it is just a simple transpiler.

The compiler should output one master ASM file containing all includes.

Lastly, all symbols will be namespaced, and prefixed with underscores. If the expose modifier is present, then a non-namespaced symbol will be generated that points to the namespaced symbol. Naturally, these can/should not conflict.

All "statements" are:

  • ASM calls
  • while loops
  • Functions (can be nested! Hooray scopes)
include "foo.muasm"
include "bar.asm" ; Non-μasm files will just be included as-is.
raw {
.section multiboot
.align 4
.long MAGIC
.long FLAGS
.long CHECKSUM
}
var myInt: dw = 0x16;
expose function _start() {
var ch = 'a'
}
function timesTwo(a) {
// `a` is automatically popped from the stack
mov eax, a
times eax
ret
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment