view s-code-print.c @ 24:aecd80408312 default tip

...
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Wed, 26 Oct 2022 17:37:18 +0900
parents 6bf66c125dbc
children
line wrap: on
line source

/*
    Very Simple Code Generator for Reverse Polish Notation
	$Id$
 */

#include "s-compile.h"

char *comments = "#####";

void
emit_push()
{
}

void
emit_compare() 
{
    printf("> ");
}

void
emit_store(assign)
int assign;
{
    printf("->%c ",assign+'a');
}


char *opcode[] = {
    "",
    "-",
    "+",
    "*",   
    "/",
    "",
    "",
    "",
    "",
    "-(r)",
    "/(r)",
};

void
emit_calc(enum opcode op)
{
    printf("%s ",opcode[op]);
}

void
emit_value(d) 
int d;
{
    printf("%d ",d);
}

void
emit_load(d)
int d;
{
    printf("%c\n",d+'a');
}

void
emit_comment()
{
}

void
emit_print()
{
    printf("print\n");
}


void
emit_intro()
{
}

void
emit_ending()
{
}


/* end */