Advertisement
captmicro

OISC for SidonX86 Network Attack System

Apr 19th, 2013
359
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.15 KB | None | 0 0
  1. #include "subleq.h"
  2.  
  3. int32 subleqmemory[] =
  4. {
  5.     //program
  6.     0, 0, 0,
  7.     0, 0, 0,
  8.     0, 0, 0,
  9.     0, 0, 0,
  10.     //display
  11.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  12.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  13.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  14.     0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
  15. }
  16.    
  17.  
  18. uint32 subleq_main(void)
  19. {
  20.     kvideo_print("SUBLEQ OISC EMULATOR\n");
  21.     kvideo_print("EXECUTING PROGRAM.\n");
  22.    
  23.     uint16 inpbuf_x = _kvideo_print_x;
  24.     uint16 inpbuf_y = _kvideo_print_y;
  25.    
  26.     int32 pc = 0, a = 0, b = 0, c = 0;
  27.    
  28.     while ((pc >= 0) && (pc < (sizeof(subleqmemory) - 1 - (16 * 4))))
  29.     {  
  30.         //execute instruction
  31.         a = subleqmemory[pc];
  32.         b = subleqmemory[pc + 1];
  33.         c = subleqmemory[pc + 2];
  34.         if ((a < 0) || (b < 0))
  35.         {
  36.             pc = -1;
  37.         }
  38.         else
  39.         {
  40.             subleqmemory[b] = subleqmemory[b] - subleqmemory[a];
  41.             if (subleqmemory[b] > 0) pc += 3; else pc = c;
  42.         }
  43.        
  44.         //print display
  45.         kvideo_movecursor(inpbuf_x, inpbuf_y);
  46.         uint32 szary = sizeof(subleqmemory) - 1;
  47.         szary -= (16 * 4);
  48.         kvideo_print(subleqmemory[szary]);
  49.     }
  50.    
  51.     kvideo_print("EXECUTION FINISHED.\n");
  52.    
  53.     //return no error
  54. _term_exit:;
  55.     return 0;
  56. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement