uint CMND_PTR = 0; uint BPTR_PTR = 0; uint SIZE_PTR = 0; uint RSLT_PTR = 0; int buffer_ptr; int buffer_size; int index; int ival; int command; int result_value; real rval; real increment; real real_ampl; void asmmain() { while (true) { do command = GBYTE[CMND_PTR]; while (command == 0); buffer_ptr = GWORD[BPTR_PTR]; buffer_size = GWORD[SIZE_PTR]; switch (command) { case 1: // RMS RMS_Calc(); break; } GLONG[RSLT_PTR] = result_value; GBYTE[CMND_PTR] = 0; } } void RMS_Calc() { int v; result_value = 0; for (index = buffer_size) { v = GBYTE[buffer_ptr] - 128; ++buffer_ptr; v = ABS(v); v = v * v; result_value += v; } result_value = result_value / buffer_size; result_value = ISQRT(result_value); }