algebraic syntax assembly
Tuesday, 2. May 2006, 07:00:24
We really need a free software algebraic syntax assembler, I've recently discovered a proprietaty language called terse that you'll love if you ever need to use assembly language in any of your projects.
terse is a free-form assembly language that makes assembly code more structured and recognisable, and also frees you from the annoying task of inventing new labels every 5 lines (my pet hate). I'm currently getting familiar with terse, but it's a pleasure to write compared to any standard assembly syntax, without sacrificing any of the power. Here's a hello world in terse:
And an example of a loop:
And here's a quick example of an insertion sort I wrote just to demonstrate the syntax:
Unfortunately the compiler isnt free, so I've been considering designing my own algebraic assembly, perhaps using bison. Although I'd take some inspiration from terse, I think I would prefer a more c-like syntax where that's possible.
terse is a free-form assembly language that makes assembly code more structured and recognisable, and also frees you from the annoying task of inventing new labels every 5 lines (my pet hate). I'm currently getting familiar with terse, but it's a pleasure to write compared to any standard assembly syntax, without sacrificing any of the power. Here's a hello world in terse:
segment .data;
'msg = ("hello world",0ah);
segment .text;
global _start;
_start:
eax = 4;
ebx = 1;
ecx = $msg;
edx = 12; !80h;
&eax+; &ebx; !80h;
$ terse hello.t
ÄÄÄÄÄÄÄ The terse (tm) Compiler, Version 2.20 ÄÄÄÄÄÄÄ
Copyright (C) Jim Neil 1989-1997, All Rights Reserved
12 Lines In.
14 Lines Out.
$ nasm -f elf -o hello.o hello.asm
$ ld -o hello hello.o
$ ./hello
hello world
And an example of a loop:
section .data;
'msg = ("loop #x", 0ah);
section .text;
global _start;
_start:
ecx = 9;
ebx = 1;
edx = 12;
edi === [$msg + 6];
{ =ecx;
ecx + '0';
[edi] = cl;
eax = 4; ecx = $msg; !80h;
ecx=;
}-<>;
&ebx; &eax+; !80h;
And here's a quick example of an insertion sort I wrote just to demonstrate the syntax:
section .data;
'msg = ("arr[%d] = %d", 0ah, 00h);
'arr = (34, 126, 42, 9, 124, 64, 24, 76, 98, 121);
section .text;
global _start;
extern printf;
_start:
ebx = ecx = edx = eax = 0; eax+;
{ bl = [arr+eax];
cl = al; cl-;
{ ecx ? --;
dl = [arr+ecx];
dl - bl ? > {
[+ecx+arr] = dl;
ecx--;
}, { . };
}.;
[+ecx+arr] = bl;
eax+;
eax - 10 ?;
}<>;
ecx = 9;
{ &eax;
al = [ecx+arr];
=eax; =ecx; =msg; =.printf;
ecx=; ecx=; eax=; ecx-;
}++;
&eax+; &ebx; !80h;
Unfortunately the compiler isnt free, so I've been considering designing my own algebraic assembly, perhaps using bison. Although I'd take some inspiration from terse, I think I would prefer a more c-like syntax where that's possible.







