char title[]="kcc example";
char string[]="Hello, world!";
char bstring[]="Exit";
void StartRedraw() {
    asm("mcall 12, 1");
}
void EndRedraw() {
    asm("mcall 12, 2");
}
void DrawWindow(int x1, int y1, int x2, int y2) {
    StartRedraw();
    asm("mcall 0, %0, %1, 0x33888888, , title"::"b"(x1*65536+x2-x1),"d"(y1*65536+y2-y1));
    EndRedraw();
}
int WaitEvent() {
    int i;
    asm("mcall 10\n\t"
	"movl %%eax, %0":"=b"(i));
    return(i);
}
void Exit() {
    asm("mcall -1");
}
void DisplayText(int x, int y) {
    asm("mcall 4, %0, 0x80000000, string"::"b"(x*65536+y));
}
void CreateButton(int x, int y) {
    asm("mcall 8, %0, %1, 0x00000077, 0x00555555\n\t"::"b"(x*65536+40),"d"(y*65536+20));
    asm("mcall 4, %0, 0x80000000, bstring"::"b"((x+8)*65536+y+8));
}
void DrawAll() {
    DrawWindow(400, 300, 550, 450);
    DisplayText(40, 20);
    CreateButton(55, 60);
}
int main() {
    DrawAll();
    while(1) {
    int i=WaitEvent();
	switch( i ) {
	    case 1: DrawAll(); break;
	    case 3: Exit();
	}
    }
}