Added single character output
This commit is contained in:
parent
027f16d72b
commit
80931f9b73
@ -4,7 +4,8 @@ Stack based virtual machine and assembly code compiler
|
|||||||
|
|
||||||
## Features
|
## Features
|
||||||
|
|
||||||
- Binary code execution (assembly language compilation coming soon)
|
- Assembly language compilation
|
||||||
|
- Binary code execution
|
||||||
- Assembly
|
- Assembly
|
||||||
- Stack operations (push & pop)
|
- Stack operations (push & pop)
|
||||||
- Arithmetics operations
|
- Arithmetics operations
|
||||||
@ -32,12 +33,13 @@ Stack based virtual machine and assembly code compiler
|
|||||||
Removes two top values in stack and pushes modulo
|
Removes two top values in stack and pushes modulo
|
||||||
- **IN**
|
- **IN**
|
||||||
Inputs string with C I/O operators
|
Inputs string with C I/O operators
|
||||||
- **OUT**
|
- **OUTS**
|
||||||
Outputs string with C I/O operators
|
Outputs string with C I/O operators
|
||||||
|
- **OUTC**
|
||||||
|
Outputs one stack element as char with I/O operators
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
|
|
||||||
- Assembly compiler
|
|
||||||
- Variables
|
- Variables
|
||||||
- Arithmetics operators
|
- Arithmetics operators
|
||||||
- Strings
|
- Strings
|
||||||
|
@ -10,7 +10,8 @@ cmd_desc_t cmd_desc[] = {
|
|||||||
{MOD, 0, "MOD"},
|
{MOD, 0, "MOD"},
|
||||||
#ifdef IO_OPERATIONS
|
#ifdef IO_OPERATIONS
|
||||||
{IN, 0, "IN"},
|
{IN, 0, "IN"},
|
||||||
{OUT, 0, "OUT"},
|
{OUTS, 0, "OUTS"},
|
||||||
|
{OUTC, 0, "OUTC"},
|
||||||
#endif
|
#endif
|
||||||
{NONE, 0, "NONE"}};
|
{NONE, 0, "NONE"}};
|
||||||
|
|
||||||
|
@ -16,7 +16,8 @@ enum command_e
|
|||||||
MOD,
|
MOD,
|
||||||
#ifdef IO_OPERATIONS
|
#ifdef IO_OPERATIONS
|
||||||
IN,
|
IN,
|
||||||
OUT,
|
OUTS,
|
||||||
|
OUTC,
|
||||||
#endif
|
#endif
|
||||||
NONE
|
NONE
|
||||||
};
|
};
|
||||||
|
14
src/run.c
14
src/run.c
@ -145,7 +145,7 @@ int exec(command_t cmd, stack_t *stack)
|
|||||||
/**
|
/**
|
||||||
* Outputs string with C I/O operators
|
* Outputs string with C I/O operators
|
||||||
*/
|
*/
|
||||||
case OUT:
|
case OUTS:
|
||||||
{
|
{
|
||||||
char ch = stack_pop(stack, res);
|
char ch = stack_pop(stack, res);
|
||||||
if (res != NULL)
|
if (res != NULL)
|
||||||
@ -160,6 +160,18 @@ int exec(command_t cmd, stack_t *stack)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
/**
|
||||||
|
* Outputs one stack element as char with I/O operators
|
||||||
|
*/
|
||||||
|
case OUTC:
|
||||||
|
{
|
||||||
|
char ch = stack_get(stack, stack->cursor, res);
|
||||||
|
if (res != NULL)
|
||||||
|
return *res;
|
||||||
|
|
||||||
|
putchar(ch);
|
||||||
|
}
|
||||||
|
break;
|
||||||
#endif
|
#endif
|
||||||
default:
|
default:
|
||||||
return 1;
|
return 1;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user