GOVMC(1) GOVMC(1)
NAME
govmc - Government Compiler
SYNOPSIS
Use the web interface
DESCRIPTION
govmc is the government compiler.
This is a brief description of govmc, which can be used to generate
govm bytecode from a modified version of the ADL/ADeLa language.
We supply
a) this description;
b) the source code for the byte code used on the vulnimages;
c) access to the compiler through a webinterface
to all teams that do not have the govhost service running.
During the contest, you are not permitted to share
a) this document;
b) any information acquired through the usage of this document;
c) the password for the compiler webinterface
with teams that have the govhost service running.
ACCESS TO THE COMPILER
From within the VPN:
http://10.0.14.23/
Password to access the web interface is b3hUiFE25dayk
We reserve the right to store all submitted source code and to publish
it in modified and/or unmodified form after the contest. You may add
your name / team’s name as comments to the source file if you like.
SHORT LANGUAGE DESCRIPTION
Use indentation as in python. Only the ’tab’ character may be used for
indentation.
Those of you who played at da-op3n 2008 will be vaguely familiar with
the syntax; however, there are some important differences.
The main function must be the first function declared; main does not
take any arguments.
FUNCTION CALLS: Functions and syscalls have the same invocation syntax.
The following syscalls exist:
putc(c:uint)
Where c is the character to output; Write a character by calling
the supplied python callback function
getc():uint
Read a character by calling a python function which must return
the character.
open(fn:uint, mode:uint):uint
Open a file
fputc(fh:uint, char:uint)
Write a character to a file
fgetc(fh:uint):uint
Read a characted from a file
close(fh:uint)
Close a file
pokeb(pos:uint, byte:uint)
Store a byte at pos in the data segment
peekb(pos:uint):uint
Return the byte stored at pos in the data segment
halt() Finish execution
Only getc, read, peekb and open return a value. You *MUST* assign that
value to a variable, or you’ll fill up the stack.
If a user-defined function returns a value, that value must be assigned
to a variable by the caller. Only 16 bit unsigned integers may be
returned. You must pass the correct number of parameters to functions,
or you’ll get into trouble. (The compiler does not check that for you)
VARIABLES
Local variables must be declared; declaration goes before code. Global
variables do exist, but the syntax to define them is undefined.
DECLARATION SYNTAX: [1]
local $(VARNAME):$(TYPE)
The two valid types are:
uint 16 bit unsigned integer
byte[SIZE]
Array. A ’byte’ is 16 bit long. Yes, that’s counter-intuitive.
CONDITIONAL STATEMENTS:
while $(CONDITION):
statement()
statement2()
if $(CONDITION):
statement()
Note that you may not use the elif of else keywords. They are there,
but they do not currently generate valid bytecode but instead mess up
your code. [2]
OPERATORS:
+ - / * & | < > <= >= << >> == ()
Evaluation is left to right; no precedence is currently implemented.
Use brackets to specify the evaluation order.
ACCESSING ARRAY ELEMENTS:
array[$(STATEMENT)]
No array bounds checking is done ;-) All arrays reside on the stack.
Arrays may not be passed as function parameters.
STRING CONSTANTS:
String constants are stored in the data segment. When used, they
"return" the starting address of the String. Thus, the following two
code excerpts are identical:
puts("Hi")
puts("Ho")
- and -
"Hi"
"Ho"
puts(0)
puts(3)
Except that the latter example pushes two variables on the stack that
are never popped.
MISCELLANEOUS
Please do not ask questions about the language in the IRC channel.
Send a PRIVMSG to hcesperer instead.
IMPLEMENTATION DETAILS
You don’t wanna know ;-)
AUTHOR
Hans-Christian Esperer
UNIMPORTANT FACTS
1) The local keyword is inspired by UnrealScript; the var:type syntax
is taken from a. flash
2) The language was just modified to generate govm bytecode. (s/modi‐
fied/hacked/)
July 2009 GOVMC(1)