\ ports 98.12.27 9:57 pm EJB
\ dump top of stack in hex
: 2hex ( u --)
base @ swap hex 0 <# # #s #>
type space base ! ;
\ these are the data addresses
\ for the MC68328 processor's ten
\ I/O ports; { A B C D E F G J K M }
\ the data direction register is just
\ below each - e.g. PADIR = 400h
hex
create PortData 401 , 409 , 411 ,
419 , 421 , 429 , 431 , 439 ,
441 , 449
ffff.f000 2constant reg
decimal
\ shows 8-bit register contents
: show ( regoffset -- )
0 reg d+ c@a 2hex ;
\ toggles mask bits on specified port
: bit ( mask portnum -- )
cells PortData + @ 0 reg d+ 2dup
c@a 3 roll
xor rot rot c!a ;
\ shows all ten I/O port contents
: showports ( -- )
10 0 do
i cells PortData + @ show
loop cr ;
\ shows all ten I/O data dir regs
: showdirs ( -- )
10 0 do
i cells PortData + @ 1- show
loop cr ;
\ shows data dir and port contents
: sd ( -- )
cr showdirs showports ;