\ 1802io

needs toolkit
needs 1802regs

hex

variable (EF1)   0 (EF1) !
: EF1  ( -- flag )  (EF1) @ ;
: raise-EF1  ( -- )   -1 (EF1) ! ;
: lower-EF1  ( -- )   0 (EF1) ! ;

variable (EF2/3)   0 (EF2/3) !
variable (strobe2/3)   
0 (strobe2/3) !
: EF2/3  ( -- flag ) 
    (EF2/3) @   (strobe2/3) @  or
    0 (strobe2/3) ! ;
: raise-EF2/3  ( -- )   -1 (EF2/3) ! ;
: lower-EF2/3  ( -- )   0 (EF2/3) ! ;
: strobe-EF2/3  ( -- )   
   -1 (strobe2/3) ! ;

\ variable (EF3)   0 (EF3) !
\ variable (strobe3)   0 (strobe3) !
\ : EF3  ( -- flag ) 
\   (EF3) @   (strobe3) @  or
\   0 (strobe3) ! ;

variable (EF4)   0 (EF4) !
variable (strobe4)   0 (strobe4) !
: EF4  ( -- flag )  
    (EF4) @   (strobe4) @  or
    0 (strobe4) ! ;
: raise-EF4  ( -- )   -1 (EF4) ! ;
: lower-EF4  ( -- )   0 (EF4) ! ;
: strobe-EF4  ( -- )    -1 (strobe4) ! ;

variable (start-1861)
: placeholder  ( -- )   ;
' placeholder (start-1861)  !

\ Don't directly use these arrays
\ outside this file; use the access
\ functions below instead.
8 array input-port
8 array output-port

\ Port number is 1 to 7. Except
\ perhaps for a debugger, only the
\ 1802 OUT opcode should call this
\ word.
: output!  ( byte port# -- )
    dup
    01 = if    
        \ Change from version 1.0 ---
        \ now only port 1 starts the 1861
        \ running. Used to be any odd
        \ numbered port.
        (start-1861) @ execute
    then
    output-port c! ;

\ This word is used by virtual devices
\ connected to the 1802 to read the
\ data it's outputting. Port# must be
\ 1 to 7; no parameter checking is
\ performed.
: output@  ( port# -- byte )
    output-port c@ ;

\ Port number is 1 to 7. Except
\ perhaps for a debugger, only the
\ 1802 IN opcode should call this
\ word.
: input@  ( port# -- byte )
    dup
    01 = if    
        \ Change from version 1.0 ---
        \ now only port 1 starts the 1861
        \ running. Used to be any odd
        \ numbered port.
        (start-1861) @ execute
    then
    input-port c@ ;

\ Used by virtual external devices to
\ connect to the 1802's input port
\ and feed it data. Port# must be 1
\ to 7; no parameter checking is
\ performed.
: input!  ( byte port# -- )
    input-port c! ;

: Q@  ( -- qstate )
    Q @ ;

: Q!  ( qstate -- )
    0= 0=  Q ! ;

