Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include "subleq.h"
- int32 subleqmemory[] =
- {
- //program
- 0, 0, 0,
- 0, 0, 0,
- 0, 0, 0,
- 0, 0, 0,
- //display
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
- }
- uint32 subleq_main(void)
- {
- kvideo_print("SUBLEQ OISC EMULATOR\n");
- kvideo_print("EXECUTING PROGRAM.\n");
- uint16 inpbuf_x = _kvideo_print_x;
- uint16 inpbuf_y = _kvideo_print_y;
- int32 pc = 0, a = 0, b = 0, c = 0;
- while ((pc >= 0) && (pc < (sizeof(subleqmemory) - 1 - (16 * 4))))
- {
- //execute instruction
- a = subleqmemory[pc];
- b = subleqmemory[pc + 1];
- c = subleqmemory[pc + 2];
- if ((a < 0) || (b < 0))
- {
- pc = -1;
- }
- else
- {
- subleqmemory[b] = subleqmemory[b] - subleqmemory[a];
- if (subleqmemory[b] > 0) pc += 3; else pc = c;
- }
- //print display
- kvideo_movecursor(inpbuf_x, inpbuf_y);
- uint32 szary = sizeof(subleqmemory) - 1;
- szary -= (16 * 4);
- kvideo_print(subleqmemory[szary]);
- }
- kvideo_print("EXECUTION FINISHED.\n");
- //return no error
- _term_exit:;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement