490 likes | 569 Views
WHYP -- An Extensible Language. Chapter 4. WHYP--An Extensible Language. A Closer Look at WHYP Defining New WHYP Words Variables Constants EEPROM. A Closer Look at WHYP. WHYP--An Extensible Language. A Closer Look at WHYP Defining New WHYP Words Variables Constants EEPROM.
E N D
WHYP-- An Extensible Language Chapter 4
WHYP--An Extensible Language • A Closer Look at WHYP • Defining New WHYP Words • Variables • Constants • EEPROM
WHYP--An Extensible Language • A Closer Look at WHYP • Defining New WHYP Words • Variables • Constants • EEPROM
Colon Definitions : <name> --- --- --- --- ; : squared ( n -- n2 ) DUP * ; 16 4104 JSR DUP 16 4337 JSR * 3D RTS
SEE and SHOW see squared squared DUP * ; ok show squared squared 16 41 4 16 43 37 3D ok see cubed cubed DUP squared * ; ok show cubed cubed 16 41 4 16 50 0 16 43 37 3D ok
Single Stepping ok 5 step squared squared DUP * ; S:[1] 5 R:[0] DUP S:[2] 5 5 R:[0] * S:[1] 19 R:[0] Exit single step ok . 25 ok
Single Stepping ok 5 step cubed cubed DUP squared * ; S:[1] 5 R:[0] DUP S:[2] 5 5 R:[0] squared S:[2] 5 19 R:[0] * S:[1] 7D R:[0] Exit single step ok . 125 ok
Loading WHYP words from a file square.whp
CR and ." : bar ( -- ) \ print a bar CR ." ******" ; : post ( -- ) \ print a post CR ." *" CR ." *" CR ." *" ;
CR and ." : C ( -- ) \ print a C bar post bar cr ; : E ( -- ) \ print an E bar post bar post bar cr;
WHYP--An Extensible Language • A Closer Look at WHYP • Defining New WHYP Words • Variables • Constants • EEPROM
Variables VARIABLE my.name Stores the following code at tdp.my.name executes this code. 16 451E JSR (LIT) 0800 0800 3D RTS my.name . 800 ok
Variables Variables are stored in memory at address vdp. The value of vdp can be changed by pressing F8. VHERE puts the current value of vdp on the data stack.
Examples of @ and ! C:\WHYP\WHYP12>whyp12 Using WHYP12.HED Communicating with COM1 68HC12 WHYP12 - Version 4.6 Press <Esc> or type BYE to exit ok VARIABLE my.name ok hex ok my.name . 800 ok 7 my.name! ok 800 10 dump 0 1 2 3 4 5 6 7 8 9 A B C D E F 0800 00 07 86 80 52 00 80 02 09 00 28 18 90 00 83 00 ..R . ( . . ok my.name @ . 7 ok 12 my.name c! ok 34 my.name 1+ c! ok 800 10 dump 0 1 2 3 4 5 6 7 8 9 A B C D E F 0800 12 34 86 80 52 00 80 02 09 00 28 18 90 00 83 00 4..R . ( . . ok my.name c@ . 12 ok my.name 1+ c@ . 34 ok
Plus-store 1 my.name +!
Arrays VARIABLE my.array 8 VALLOT my.array 3 2* + @ . will print the value of my.array[3]
Arrays VARIABLE my.array 8 VALLOT my.array 3 2* + @ . : A@ ( ix addr -- n ) SWAP 2* + @ ; 3 my.array A@ . will print the value of my.array[3] Chap 13: 3 my.array @ . 1234 3 my.array !
WHYP--An Extensible Language • A Closer Look at WHYP • Defining New WHYP Words • Variables • Constants • EEPROM
Constants 25 CONSTANT quarter Stores the following code at tdp.quarter executes this code. 16 451E JSR (LIT) 0019 0019 3D RTS quarter . will print the value 25 on the screen.
Tables CREATE table
HEX CREATE table 5 , 8 , 23 ,
HEX CREATE table 5 C, 8 C, 23 C,
EEPROM • MC68HC812A4 • 4 Kbytes of EEPROM • $1000 - 1FFF • MC68HC912B32 • 768 bytes of EEPROM • $0D00 - $0FFF
MC68HC912B32 EEPROMBlock Protect Register In WHYP12: CLR EEPROT