Subversion Repositories Kolibri OS

Rev

Rev 7563 | Go to most recent revision | Blame | Last modification | View Log | Download | RSS feed

  1.  
  2.  
  3. dword std_print(dword count, args)
  4. {
  5.         consoleInit();
  6.         count = 1;
  7.         WHILE(count)
  8.         {
  9.                 con_printf stdcall (DSDWORD[args]);
  10.                 args+=4;
  11.                 count--;
  12.         }
  13. }
  14.  
  15. :dword std_set(dword count, args)
  16. {
  17.         dword name = 0;
  18.         dword value = 0;
  19.         WHILE(count>0)
  20.         {
  21.                 name = DSDWORD[args];
  22.                 args += 4;
  23.                 value = DSDWORD[args];
  24.                 args += 4;
  25.                 variables.set(name, value);
  26.                 count-=2;
  27.         }
  28. }
  29.  
  30. :dword std_get(dword count, args)
  31. {
  32.         RETURN variables.get(DSDWORD[args]);
  33. }
  34.  
  35. :dword std_str(dword count, args)
  36. {
  37.         dword tmp = 0;
  38.         tmp = malloc(15);
  39.         itoa_(tmp,DSDWORD[args]);
  40.         RETURN tmp;
  41. }
  42.  
  43. :dword std_add(dword count, args)
  44. {
  45.         dword ret = 0;
  46.         WHILE(count)
  47.         {
  48.                 ret += DSDWORD[args];
  49.                 args+=4;
  50.                 count--;
  51.         }
  52.         RETURN ret;
  53. }
  54.  
  55. :dword std_sub(dword count, args)
  56. {
  57.         dword ret = 0;
  58.         IF(count)
  59.         {
  60.                 ret = DSDWORD[args];
  61.                 count--;
  62.                 args+=4;
  63.         }
  64.         WHILE(count)
  65.         {
  66.                 ret -= DSDWORD[args];
  67.                 args+=4;
  68.                 count--;
  69.         }
  70.         RETURN ret;
  71. }
  72.  
  73. void Init()
  74. {
  75.         functions.init(100);
  76.        
  77.         /* Console functions */
  78.        
  79.        
  80.         /* String functions */
  81.         functions.set("str", #std_str);
  82.        
  83.         /* System functions */
  84.         functions.set("exit", #ExitProcess);
  85.        
  86.         /* Math functions */
  87.         functions.set("+", #std_add);
  88.         functions.set("-", #std_sub);
  89.        
  90.         /* Lisp functions */
  91.         functions.set("set", #std_set);
  92.         functions.set("get", #std_get);
  93.        
  94.         variables.init(100);
  95. }
  96.  
  97. dword StdCall(dword count, name, args)
  98. {
  99.         dword tmp = 0;
  100.        
  101.         functions.get(name);
  102.         IF(EAX) RETURN EAX(count, args);
  103.         IF(!strcmp(name, "print"))
  104.         {
  105.                 consoleInit();
  106.                 count = 1;
  107.                 WHILE(count)
  108.                 {
  109.                         con_printf stdcall (DSDWORD[args]);
  110.                         args += 4;
  111.                         count--;
  112.                 }
  113.         }
  114.         RETURN 0;
  115. }
  116.  
  117.