Skip to content

Commit

Permalink
fixes #187 add basic IDLE feature
Browse files Browse the repository at this point in the history
  • Loading branch information
TG9541 committed Apr 8, 2018
1 parent 39f4bb3 commit f04d186
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 42 deletions.
51 changes: 19 additions & 32 deletions docs/words.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# STM8EF Words
```
; COLD ( -- )
; The hilevel cold start sequence.
; 'BOOT ( -- a )
; The application startup vector and NVM USR setting array
```

```
; 'BOOT ( -- a )
; The application startup vector and NVM USR setting array
; COLD ( -- )
; The hilevel cold start sequence.
```

```
Expand Down Expand Up @@ -80,7 +80,7 @@
```

```
; 2C! ( n b -- )
; 2C! ( n a -- )
; Store word C-wise to 16 bit HW registers "MSB first"
```

Expand All @@ -106,13 +106,13 @@
```

```
; C@ ( b -- c ) ( TOS STM8: -- A,Z,N )
; C@ ( a -- c ) ( TOS STM8: -- A,Z,N )
; Push byte in memory to stack.
; STM8: Z,N
```

```
; C! ( c b -- )
; C! ( c a -- )
; Pop data stack to byte memory.
```

Expand Down Expand Up @@ -1053,6 +1053,18 @@
; link action to words created by defining words
```

```
; A@ ( A:shortAddr -- n )
; push contents of A:shortAddr on stack
; HEADER AAT "A@"
```

```
; Y@ ( Y:Addr -- n )
; push contents of Y:Addr on stack
; HEADER YAT "Y@"
```

```
; CREATE ( -- ; <string> )
; Compile a new array
Expand Down Expand Up @@ -1125,31 +1137,6 @@
; Display names in vocabulary.
```

```
; E7S ( c -- )
; Convert char to 7-seg LED pattern, and insert it in display buffer
```

```
; P7S ( c -- )
; Right aligned 7S-LED pattern output, rotates LED group buffer
```

```
; ?KEYB ( -- c T | F ) ( TOS STM8: -- Y,Z,N )
; Return keyboard char and true, or false if no key pressed.
```

```
; ADC! ( c -- )
; Init ADC, select channel for conversion
```

```
; ADC@ ( -- w )
; start ADC conversion, read result
```

```
; SP! ( a -- )
; Set data stack pointer.
Expand Down
18 changes: 11 additions & 7 deletions forth.asm
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@
USREMIT = UPP+0 ; "'EMIT" execution vector of EMIT
USRQKEY = UPP+2 ; "'?KEY" execution vector of QKEY
USRBASE = UPP+4 ; "BASE" radix base for numeric I/O
USREVAL = UPP+6 ; "'EVAL" execution vector of EVAL
USRIDLE = UPP+6 ; "'IDLE" idle routine in KEY (default: RET)
USRPROMPT = UPP+8 ; "'PROMPT" point to prompt word (default .OK)
USRCP = UPP+10 ; "CP" point to top of dictionary
USRLAST = UPP+12 ; "LAST" currently last name in dictionary
Expand All @@ -254,12 +254,13 @@
USRVAR = UPP+18 ; "VAR" point to next free USR RAM location
NVMCONTEXT = UPP+20 ; point to top of dictionary in Non Volatile Memory
USRCONTEXT = UPP+22 ; "CONTEXT" start vocabulary search
USRHLD = UPP+24 ; "HLD" hold a pointer of output string
USREVAL = UPP+24 ; "'EVAL" execution vector of EVAL
USRNTIB = UPP+26 ; "#TIB" count in terminal input buffer
USR_IN = UPP+28 ; ">IN" hold parsing pointer
USRBUFFER = UPP+30 ; "BUFFER" address, defaults to TIBB

; temporary core variables
; More core variables in zero page (instead of assigning fixed addresses)
RamWord USRHLD ; "HLD" hold a pointer of output string
RamWord YTEMP ; extra working register for core words

;***********************
Expand Down Expand Up @@ -442,7 +443,7 @@ TBOOT:
.dw QRXP ; ?RXP as ?KEY vector
.endif
.dw BASEE ; BASE
.dw INTER ; 'EVAL
.dw RETIDLE ; 'IDLE
.dw DOTOK ; 'PROMPT
COLDCTOP = .
.dw CTOP ; CP in RAM
Expand All @@ -464,7 +465,7 @@ TBOOT:
.dw QRXP ; ?RXP as ?KEY vector
.endif
.dw BASEE ; BASE
.dw INTER ; 'EVAL
.dw RETIDLE ; 'IDLE
.dw DOTOK ; 'PROMPT
.dw CTOP ; CP in RAM
.dw LASTN ; CONTEXT pointer
Expand Down Expand Up @@ -2459,8 +2460,11 @@ DGTQ1: LD (1,X),A
HEADER KEY "KEY"
KEY:
KEY1: CALL [USRQKEY]
CALL QBRAN
.dw KEY1
CALL YFLAGS
JRNE RETIDLE
CALL [USRIDLE] ; IDLE must be fast (unless ?RX is buffered) and stack neutral
JRA KEY1
RETIDLE:
RET

.ifeq REMOVE_NUFQ
Expand Down
30 changes: 27 additions & 3 deletions tools/genconst.awk
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,39 @@ BEGIN {
}
}

$3!~/(LINK|RAMPOOL)/ && $4=="=" && $5~/(SPP|UPP|RAMPOOL)/ && $1~/^00/ {
# extract lines like:
# USRNTIB = UPP+26 ; "#TIB" count in terminal input buffer
$3!~/(LINK|RAMPOOL)/ && $4=="=" && $5~/(SPP|UPP)/ && $1~/^00/ {
if (split($0,b,"\"") == 3) {
symbol = b[2]
}
else {
symbol = $3
}
split($0,a,";");
split($0,a,";");
addr = "$" substr($1,3)
comment = " \\ " a[2]
print addr " CONSTANT " symbol comment > target symbol
print addr " CONSTANT " symbol comment > target symbol
next
}

# extract lines like:
# RamWord USREVAL ; "'EVAL" execution vector of EVAL
preLine~/RamWord/ && $3!~/RAMPOOL/ && $4=="=" && $5~/RAMPOOL/ {
if (split(preLine,b,"\"") == 3) {
symbol = b[2]
}
else {
symbol = $3
}
split(preLine,a,";");
addr = "$" substr($1,3)
comment = " \\ " a[2]
print addr " CONSTANT " symbol comment > target symbol
next
}

# keep the current (unprocessesed) line as the next "previous line"
{
preLine = $0
}

0 comments on commit f04d186

Please sign in to comment.