Input/Output operations
    Il "Quarto" fuso ] The 4th Time Zone ]   


 

Introduction
Input/Output operations
Mathematical Operators
Stack operators
Other operators
Colon definition
Control structures
Conditional branching
Constants and variables
Other Forth words
Using the editor
Error messages


                                   

[ Index ][ Back ][ Next ]

EMIT

This will take the number hold on the top of the stack and display it on the terminal, as its original ASCII character.

e.g.    HEX 41 EMIT <CR>

will instruct the Forth to move into hexadecimal mode, push 41H onto the stack and then take that number and display it on the terminal. In this example the character displayed will be an "A". The actual character displayed may be any of the recognizable ASCII character, a graphic character, or a control code depending on the value of the number on the stack

EMITC

As EMIT but control character are also dealt with.

KEY

This will poll keyboard, wait for a key to be pressed and push the ASCII code of this key onto the stack, without displaying it on the terminal.

e.g.      KEY <CR>

Press "A" on keyboard will instruct the computer to wait for a key to be pressed (press the "A") and then push the ASCII value of this key, in this case 41H onto the top of the stack. In order to display this character, try the following

            KEY EMIT <CR>

Now hit any key and its ASCII value will be printed followed by OK. So if you now type "A" it would print "AOK". 

CR

This will transmit a carriage return and line feed to the display.

.

Convert the number hold on the stack using the current BASE and print it on the screen with a trailing space. e.g. suppose the stack contains 16H and base is decimal (10), then will print 22 (this is 16 + 6), if base where hexadecimal (16) then would print 16. In order to see this working we will alter the base and push numbers onto the stack. Remember that just typing in a valid number will result in it being pushed onto the stack. There are two words to alter BASE:

HEX

Use hexadecimal base.

DECIMAL

Use decimal base.

Try

1)    HEX 1F7 . <CR>

This will print

1F7

 DECIMAL 2048 . <CR>

 This will print

2048

 DECIMAL 2048 HEX . <CR>

 Thiw will print

800

since this is the HEX equivalent of 2048. Remember that . will remove the number from the stack that it is printing.

U.

Prints the number held on the topo of the stack as an unsigned number.

e.g.      HEX C000 U. <CR>

will push C000H onto the stack and then print it. If whe use just . we will get a negative result

HEX C000 . <CR>

will print

-4000

?

Print the value contained at the address on top of the stack using the current BASE. Suppose the top of the stack contains FF40H, location FF40/41H contains 0014H and current BASE is 10 (DECIMAL), then ? will print 20 which is the decimal equivalent of 14H.

TYPE

This uses the top two numbers held on the stack and will print a selected number of characters starting at a specific address onto the screen. The top number on the stack is the character count and the second number is the address to start at.

e.g.      HEX 6100 20 TYPE

(note that 6100H is pushed onto the stack and 20H is pushed on top of it: 20H top, 6100H second. This will print 32 (20H) ASCII characters correpsonding to the data starting at address 6100H).

DUMP

This take the top number on the stack an prints out 80H bytes starting at this address.

."

This is used in the form ." character string" and will display the string contained within " " on the screen

 ." THIS IS A CHARACTHER STRING" <CR>

 will put

THIS IS A CHARACTER STRING

on the screen. Note that spaces between the string and the quotes.

SPACE

This will display a single blank/space on the screen.

SPACES

This will display n spaces on the screen, where n is the number on the top of the stack

e.g.            DECIMAL 10 SPACES <CR>

will print 10 spaces on the screen.

[ Index ][ Back ][ Next ]


Ultimo aggiornamento: 10-12-2002. Copyright (c) 2000-2002 Matteo Vitturi. 
Per problemi o domande relativamente a questo sito contattare il webmaster
Last update: 12.10.2002. Copyright (c) 2000-2002 Matteo Vitturi.
For problems or questions related to this web please contact the webmaster.
1