Arduino-FVM
Byte Token Threaded Forth Virtual Machine (FVM) for Arduino
Yield.ino
Go to the documentation of this file.
1 
44 #include "FVM.h"
45 
46 #if 0
47 // : sketch ( -- ) halt ;
48 FVM_COLON(0, SKETCH, "sketch")
49  FVM_OP(HALT),
50  FVM_OP(EXIT)
51 };
52 #else
53 // : sketch ( -- ) begin yield again ;
54 FVM_COLON(0, SKETCH, "sketch")
55  FVM_OP(YIELD),
56  FVM_OP(BRANCH), -2,
57  FVM_OP(EXIT)
58 };
59 #endif
60 
61 // Sketch function table
62 const FVM::code_P FVM::fntab[] PROGMEM = {
64 };
65 
66 // Sketch symbol table
67 const str_P FVM::fnstr[] PROGMEM = {
69  0
70 };
71 
74 
75 void setup()
76 {
77  Serial.begin(57600);
78  while (!Serial);
79 }
80 
81 void loop()
82 {
83  int i = 1000;
84  uint32_t start = micros();
85  while (--i) fvm.resume(task);
86  uint32_t stop = micros();
87  float us = (stop-start) / 1000.0;
88  Serial.print(us);
89  Serial.println(F(" us"));
90  Serial.flush();
91  delay(100);
92 }
const FVM::code_t SKETCH_CODE[]
Definition: Demo.ino:31
static const code_P fntab[]
Definition: FVM.h:628
int resume(task_t &task)
Definition: FVM.cpp:143
Definition: FVM.h:339
FVM_OP(YIELD)
const char * str_P
Definition: FVM.h:32
const code_t * code_P
Definition: FVM.h:249
static const str_P fnstr[]
Definition: FVM.h:629
const char SKETCH_PSTR[]
Definition: Demo.ino:30
FVM::Task< 32, 16 > task(Serial, SKETCH_CODE)
void setup()
Definition: Yield.ino:75
#define FVM_COLON(id, var, name)
Definition: FVM.h:728
FVM fvm
Definition: Yield.ino:73
Definition: FVM.h:34
void loop()
Definition: Yield.ino:81