changes to put api

This commit is contained in:
2023-08-05 20:08:47 +02:00
parent fc56815f74
commit 6963440e9f
2 changed files with 20 additions and 2 deletions

View File

@@ -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() {

View File

@@ -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++) {