36 lines
631 B
C
36 lines
631 B
C
|
#pragma once
|
||
|
#include <stdint.h>
|
||
|
#include <stdio.h>
|
||
|
|
||
|
#include "config.h"
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
char *name;
|
||
|
char *arg;
|
||
|
uint16_t data;
|
||
|
} Instruction;
|
||
|
|
||
|
typedef struct
|
||
|
{
|
||
|
Instruction program[PROGRAM_MAXSIZE];
|
||
|
uint16_t program_size, program_counter, stacksize;
|
||
|
int pointer;
|
||
|
int16_t labels[MAX_LABELS];
|
||
|
uint16_t memory[];
|
||
|
} Stack;
|
||
|
|
||
|
Stack *program_init(uint16_t stacksize);
|
||
|
|
||
|
void stack_push(Stack *stack, uint16_t data);
|
||
|
|
||
|
uint16_t stack_pop(Stack *stack);
|
||
|
|
||
|
uint16_t stack_peek(Stack *stack);
|
||
|
|
||
|
void kms(Stack *stack, const char *err);
|
||
|
|
||
|
void parse_and_process(Stack *stack, FILE *file);
|
||
|
|
||
|
void repl(Stack *stack);
|