changes to put api
This commit is contained in:
20
src/api.c
20
src/api.c
@@ -1,12 +1,30 @@
|
||||
#include "api.h"
|
||||
#include "main.h"
|
||||
#include "instructions.h"
|
||||
|
||||
#ifdef _WIN32 //windows only apis
|
||||
#include <Windows.h>
|
||||
#endif
|
||||
|
||||
#define CHECK_STACK(X) \
|
||||
if (X < 0) return; \
|
||||
if (X > STACK_SIZE) return; \
|
||||
|
||||
void api_put() {
|
||||
printf("%c", stack[top--]);
|
||||
int mode = stack[top--]; // 1 for char, 2 for num
|
||||
if (mode != 1 && mode != 2) return;
|
||||
|
||||
CHECK_STACK(top);
|
||||
|
||||
if (mode == 1) {
|
||||
char c = stack[top--];
|
||||
if (c == '\0') c = ' ';
|
||||
|
||||
printf("%c", c);
|
||||
}
|
||||
else {
|
||||
printf("%d", stack[top--]);
|
||||
}
|
||||
}
|
||||
|
||||
void api_getasynckeystate() {
|
||||
|
||||
@@ -164,7 +164,7 @@ int main(int argc, char** argv) {
|
||||
free(args);
|
||||
fclose(fptr);
|
||||
|
||||
printf("Program finished, states :\n");
|
||||
printf("\n\nProgram finished, states :\n");
|
||||
|
||||
printf("Stack : ");
|
||||
for (int i = 0; i < STACK_SIZE; i++) {
|
||||
|
||||
Reference in New Issue
Block a user