-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemxFORTH-core.cpp
More file actions
61 lines (56 loc) · 1.8 KB
/
memxFORTH-core.cpp
File metadata and controls
61 lines (56 loc) · 1.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/* vim: set noexpandtab fileencoding=utf-8 nomodified wrap textwidth=0 foldmethod=marker foldmarker={{{,}}} foldcolumn=4 ruler showcmd lcs=tab\:|- list: tabstop=8 linebreak showbreak=»\ ft=cpp */
// ,,g = gcc, exactly one space after "set"
#include <Arduino.h>
#include "version.h"
// µFORTH
// .equ RTS_PIN,PE2 - not on official board
// .equ CTS_PIN,PE3
#define RTS_PIN _BV(2)
//
extern "C" {
extern void my_setup();
extern void my_loop();
char read_char() {
uint8_t av=Serial.available();
if (av > SERIAL_RX_BUFFER_SIZE/2 ) {
PORTE |= RTS_PIN; // set flag
};
if (av<3) {
PORTE &= ~RTS_PIN; // clear flag
};
if (av>0) {
return Serial.read();
} else {
return 0;
}
}
void write_char(char c) {
Serial.write(c);
}
void write_charA(char c) {
Serial.write(c < ' ' ? '.' : c);
}
}
void setup(){
Serial.begin(115200); //
while (!Serial){;};
DDRE |= RTS_PIN;
Serial.println(F("1234567890."));
Serial.println(F(VERSION_STRING ));
Serial.println(F(" based on " VERSION_COMMIT " - " VERSION_MESSAGE ));
Serial.println(F("---- ==== #### FORTH #### ==== ----"));
Serial.println(F("Hint: 0 nodebug 0 noinfo 0 notrace LAST D@ 20 + dump "));
#if defined(__AVR_ATmega2560__)
Serial.print(F("Hint: hex ff DDRF !C aa PORTF !C ff DDRK !C aa PORTK !C : x ff PINF !C ff PINK !C ; x \r\n"));
Serial.print(F(": count- 0 BEGIN DUP c2C PORTF !C PORTK !C 1- DUP 0= UNTIL c2C PORTF !C PORTK !C ; \r\n"));
Serial.print(F(": count+ 0 BEGIN DUP c2C PORTF !C PORTK !C 1 + DUP 0= UNTIL c2C PORTF !C PORTK !C ; \r\n"));
Serial.print(F(": x DUP 0 PORTE C! DDRE C! PORTE C! PINE C@ FC AND . ; \r\n"));
#endif
Serial.print(F("Test: : xx 0BRANCH [ 0 0C , ] 0 ; : xxx IF 1111 ELSE 2222 FI 3333 + ; \r\n"));
my_setup();
Serial.println(F("Setup done"));
}
void loop(){
write_char(read_char());
my_loop();
}