Hello world/Line printer: Difference between revisions

Content added Content deleted
Line 275: Line 275:
<lang Forth>\ No operating system, embedded device, printer output example
<lang Forth>\ No operating system, embedded device, printer output example


defer emit \ emit is created as a place holder
defer emit \ deferred words in Forth are like virtual functions but easier to use


: type ( addr count -- ) \ type a string uses emit
: type ( addr count -- ) \ type a string uses emit
bounds ?do i c@ emit loop ; \ type is used by ." (see usage examples below)
bounds ?do i c@ emit loop ; \ type is used by ." (see usage examples below)


HEX
: CR ( -- ) 0A emit 0D emit ; \ send a carriage return, linefeed pair with emit
: CR ( -- ) 0A emit 0D emit ; \ send a carriage return, linefeed pair with emit


\ memory mapped I/O addresses for the printer port
\ memory mapped I/O addresses for the printer port
HEX
B02E constant scsr \ serial control status register
B02E constant scsr \ serial control status register
B02F constant scdr \ serial control data register
B02F constant scdr \ serial control data register