Gameboy Development Forum

Discussion about software development for the old-school Gameboys, ranging from the "Gray brick" to Gameboy Color
(Launched in 2008)

You are not logged in.

Ads

#1 2017-01-11 13:40:58

boombuler
New member
Registered: 2017-01-11
Posts: 2

Custom Language + Compiler

Hi everyone,

since C is driving me crazy and I don't like to write large programs in assembler, I'm thinking about writing an own language just for gameboy development.
For now I'm planning a mixup of go, c and a little bit pascal. It should provide "inline assembler" so that you could write some parts of a function in assembler or even the whole function body. I'm also planning a easy way to decide if a function call should be inlined while compiling or be "called" (it can be set either on invocation of the function or within the signature)

Please tell me what you guys think and if any of you has an idea for a great feature let me know.

Offline

 

#2 2017-01-11 21:43:13

npzman
Banned
From:
Registered: 2014-11-19
Posts: 197

Re: Custom Language + Compiler

Do Visual Basic .Net


Twitter : @Sfeedman please follow
Join : sfeed.club my website please join

Offline

 

#3 2017-01-12 11:04:07

d.bop
Member
From: Duluth, MN
Registered: 2016-03-22
Posts: 14

Re: Custom Language + Compiler

Great minds think alike smile

I've been working on my own assembler in my free time and hope to eventually make a new Gameboy-focused language (+ compiler and IDE)

I'm looking forward to seeing what you come up with!

Offline

 

#4 2017-01-12 12:00:12

boombuler
New member
Registered: 2017-01-11
Posts: 2

Re: Custom Language + Compiler

Since I started with Lexer / Parser (and currently working on some AST reduction) I can share what I currently plan. The source should look like this:

Code:

type Pos word; // declare Pos to be 16 unsigned int
 
type Point struct {
    X Pos;
    Y Pos; 
}

type Player struct {
    Position Point;
    Health byte;
}

func _add(x byte; y byte) byte { // the underscore set "add" to always inline if possible
    return x + y
}

func _haltNop() { 
    asm { // Inline Assembler
        halt
        nop
    }
}

func moveRight(pt *Point) {
    pt.X += add(7, 0x03);
}

var player Player;

program {
    while true {
        _moveRight(@player.Position); // the underscore set "moveRight" to be inlined
        haltNop();
    }
}

Offline

 

Board footer

Powered by PunBB
© Copyright 2002–2005 Rickard Andersson