Color, Errors and Bell

Mecrisp-Across uploads source so fast that errors are easily missed as they are not highlighted and do not ring the terminal bell.

These Words can replace the default error messages to highlight the error in RED text and ring the terminal bell.

I also wanted a GREEN coloured “ok” prompt in TARGET mode.

New Terminal Colours

The light blue prompt comes from recompiling mecrisp-across-0.9a-experimental/helpers/mecrisp-stellaris-stm32f407.bin by enabling

.equ color, 1

in mecrisp-stellaris-2.6.1/mecrisp-stellaris-source/stm32f407-ra/mecrisp-stellaris-stm32f407.s.

This is what you are using before switching to target mode.

_images/colour-mecrisp-across.jpg

Source File

All color additions listed below are in this one file.

mecrisp-across-0.9a-experimental/mecrisp-across-source/01 dictionary_und_compiler.txt

Note

Unix spaces are illegal in filenames, so I replace all spaces with underlines. This doesn’t affect the “mecrisp-across-0.9a-experimental/release” command as it just sorts the files based on name.

Warning

Don’t forget to run “mecrisp-across-0.9a-experimental/release” FIRST before “release”. A easy way to make sure it worked (because Thumbulator is very limited) is to check the timestamp of the generated “mecrisp-stellaris-stm32f407-with-mecrisp-across.bin” has changed to the current time. Then just flash it to the F4 Disco Host.

ANSII Colors

reset     [0m
black     [30m
red       [31m
green     [32m
yellow    [33m
blue      [34m
magenta   [35m
cyan      [36m
white     [37m

Implementing Colored Errors and Bell

Support Words

: esc $1B emit ;     \ tp 22 feb 2022
: bell 7 emit ;

Replacement RED Error Message

bell esc ." [31m <original error message>" esc ." [0m"

Example

\  token 2dup 2>r t-find 0= if space 2r> type ."  not found." cr quit else rdrop rdrop then

Replace with:

token 2dup 2>r t-find 0= if space 2r>  bell esc ." [31m not found" esc ." [0m"  cr quit else rdrop rdrop then

Finding V0.9a Source Error Messages

This finds MOST of them. The directory to search is : mecrisp-across-0.9a-experimental/mecrisp-across-source

grep quit *.txt

Note: to find them ALL grep as below. There is a LOT more output.

grep '\."' *.txt

List of Source Quits

There are five files containing error messages:

01 dictionary_und_compiler.txt
04a1 target-speicherkarte.txt
04a2 registerverwaltung.txt
04a4 cross-registerallokator.txt
05 disassembler.txt

error messages

01_dictionary_und_compiler.txt:  token ?dup if t-header else ."  t: needs name." cr quit then
01_dictionary_und_compiler.txt:  token 2dup 2>r t-find 0= if space 2r> type ."  not found." cr quit else rdrop rdrop then
01_dictionary_und_compiler.txt:    space 2r> type ."  not found." cr quit
01_dictionary_und_compiler.txt:        2dup 2>r number16 0= if space 2r> type ."  not found." cr quit else rdrop rdrop then \ Leave the literal(s) on the stack
04a1_target-speicherkarte.txt:  org @ vectortable u>= if ." Flash full." cr quit then
04a2_registerverwaltung.txt:  ." No free registers available. This should not happen, please report bug." quit
04a4_cross-registerallokator.txt:  dup hostonly> t@ if t-name. ."  is available on host only." cr quit then
04a4_cross-registerallokator.txt:  ." No pure machine language primitives possible anymore. This should not happen, please report bug." cr quit
04a4_cross-registerallokator.txt:  variablenpointer @ stackarea u>= if ." Ram full." cr quit then
05_disassembler.txt:  jtag? @ not if ." JTAG-Connection required." cr quit then

TARGET Mode GREEN Prompt

Original Code

begin
  query
  \ ts-interpret
  ice-interpret
  ." ok."  cr
again
;

Green

begin
  query
  \ ts-interpret
  ice-interpret
  esc ." [32m ok."  esc ." [0m" cr      \ green
again
;

Across-colour uploading the Timertest.fs source

_images/across-color-loading-timertest.jpg