
INPORT:  EQU    5
OUTPORT: EQU    016
		ORG	002#000
START:	LHI	003
		LLI	350
		LMI	001
		LLI	356
		LMI	000
		INL
		LMI	005
NEWONE:		LHI	004
		LLI	000
		CAL	MSG
		CAL	INPUT
		CPI	316
		JTZ	NOMORE
		CPI	331
		JFZ	NEWONE
		CAL	MOVTAB
		JMP	GUESS
NOMORE:	LHI	004
		LLI	025
		CAL	MSG
		HLT

GUESS:	LHI	004
		LLI	037
		CAL	MSG
		CAL	INPUT
		LCA

SCAN:	LBI	000
		LHI	003
		LLI	360

CKMTCH:	CPM
		JFZ	NOMTCH
		INB
		LAI	010
		ADL
		LLA
		LMC
		LAL
		SUI	010
		LLA

NOMTCH:	INL
		LAM
		NDA
		JTZ	EOWORD
		LAI	007
		NDL
		JTZ	EOWORD
		LAC
		JMP	CKMTCH

EOWORD:	INB
		DCB
		JTZ	HANGIT
		LHI	004
		LLI	074
		CAL	MSG
		LHI	003
		LLI	353
		LMI	000
		LLI	370

NOTEND:	LAM
		CPI	255
		JFZ	AHEAD2
		LEL
		LLI	353
		LBM
		INB
		LMB
		LLE

AHEAD2:	CAL	PRINT
		INL
		LAL
		SUI	010
		LLA
		LAM
		NDA
		JTZ	ENDAGN
		LAL
		NDI	007
		JTZ	ENDAGN
		LAI	010
		ADL
		LLA
		JMP	NOTEND

ENDAGN:	LLI	353
		LBM
		INB
		DCB
		JFZ	GUESS
		LHI	004
		LLI	120
		CAL	MSG
		JMP	NEWONE

HANGIT:	LHI	004
		LLI	062
		CAL	MSG
		LHI	003
		LLI	350
		LBM
		INB
		LMB
		INL
		LMB
		LAI	010
		SUB
		INL
		LMA	
		LEI 340

HANGMR:	LLE
		LAM
		CAL	PRINT
		INL
		LEL
		LLI	351
		LBM
		DCB
		LMB
		JFZ	HANGMR
		LLI	352
		LCM
		INC
		DCC
		JTZ	NEWONE
		LAI	255

MRDASH:	CAL	PRINT
		LCM
		DCC
		LMC
		JFZ	MRDASH
		JMP	GUESS

MOVTAB:	LHI	003
		LLI	350
		LBM
		LLI	370
		LCI	010
		LAI	255

DASHFL:	LMA
		INL
		DCC
		JFZ	DASHFL

NXWORD:	LLI	360
		LCI	010
		XRA

ZEROFL:	LMA
		INL
		DCC
		JFZ	ZEROFL
		LLI	356
		LAM
		INL
		LHM
		LLA
		XRA
		CPM
		JFZ	AHEAD3
		LHI	005
		LLI	000

AHEAD3:	LDI	003
		LEI	360

BUFFMR:	LAM
		NDA
		JTZ	NEXT
		CAL	SWITCH
		LMA
		INL
		CAL	SWITCH
		INL
		JFZ	NOHIGH
		INH

NOHIGH:	JMP	BUFFMR

NEXT:	INL
		JFZ	NOTHI
		INH

NOTHI:	CAL	SWITCH
		LLI	356
		LME
		INL	
		LMD
		DCB
		JFZ	NXWORD
		LLI	350
		LMI	000
		RET

SWITCH:	LCH
		LHD
		LDC
		LCL
		LLE
		LEC
		RET

MSG:		LAM
		NDA
		RTZ
		CAL	PRINT
		INL
		JFZ	MSG
		INH
		JMP	MSG

		ORG	003#340
		DATA	"HANGMAN!"
		DATA	000,000,000,000
		ORG	003#356
		DATA	000,000
		DATA	000,000,000,000,000,000,000,000
		DATA	255,255,255,255,255,255,255,255
		DATA	215,212,212
		DATA	"WANT A NEW WORD? "
		DATA	000,215,212
		DATA	"GOODBYE"
		DATA	000,215,212
		DATA "GUESS A LETTER: "
		DATA 000,215,212
		DATA	"NOPE!  "
		DATA 000,215,212
		DATA	"GOOD. YOU HAVE:  "
		DATA 000,215,212
		DATA "CONGRATULATIONS!"
		DATA 000

;
; HERE IS THE USER DEFINED CHARACTER INPUT TO READ FROM SERIAL PORT
; destroys C & D
; returns character in A
INPUT:
        INP INPORT
        NDA                     ; 5
        JTS INPUT               ; 9/11
; found - delay 1 1/2 bit times
        LCI     5               ; 8  209 decimal
        CAL     TIMER3          ; delay 1.5 bit times for start bit
        LDI     8               ; 8 data bits
;grab 8 bits
IN2:
        CAL     DATAIN          ; get bit
        DCD
        JFZ     IN2             ; repeat
; since we are echoing character, no need to
; wait for stop bit here
;
; result is in a, echo it
        JMP PRINT
;

;
; get 1 bit
; MSB of port contains input stream
; read and move to carry
; shift into MS bit position
; and maintain in B register
DATAIN:
        LCA                     ; 5
        INP INPORT              ; 8
        RAL                     ; 5
        LAC                     ; 5
        RAR                     ; 5
; delay 1 bit time (used by both input and output)
; destroys B
TIMER4:
        LCI     2               ; 8  2 decimal
TIMER3:                         ;
        DCC                     ; 5
        JFZ TIMER3              ; 9/11
        LAA
        RET

;
; HERE IS THE USER DEFINED PRINT ROUTINE FOR A SERIAL PORT
; input:A
; destroys C & D
;
PRINT:  NDA
        RAL
        OUT     OUTPORT         ; start bit
        RAR
        LCI     3
        CAL     TIMER3
        LDI     8               ; 8 data bits
OUT2:
        CAL     DATAOUT         ; next data bit
        DCD
        JFZ     OUT2

        LCA
        LAI     001             ; stop bit
        OUT     OUTPORT
        LAC
     JMP     TIMER4

DATAOUT: OUT    OUTPORT
        RRC
        CAL     TIMER4
        RET
		ORG	005#000
		DATA "HELLO"
		DATA	000
		DATA	"ARROW"
		DATA	000
		DATA	"COMPUTER"
		DATA	000
		DATA	"PREMIUM"
		DATA	000
		DATA	"NOTICE"
		DATA	000
		DATA	"FUN"
		DATA	000
		DATA	"HEAVY"
		DATA	000
		DATA	"RUBBER"
		DATA	000
		DATA	"RUSTLE"
		DATA	000
		DATA	"THWART"
		DATA	000
		DATA	"OYSTER"
		DATA	000
		DATA	"OXIDIZE"
		DATA	000
		DATA	"OSSIFY"
		DATA	000
		DATA	"OPINION"
		DATA	000
		DATA	"OOZY"
		DATA	000
		DATA	"ONEROUS"
		DATA	000
		DATA	"NOMAD"
		DATA	000
		DATA	"NOCTURNE"
		DATA	000
		DATA	"NOMINATE"
		DATA	000
		DATA	"NUMSKULL"
		DATA	000
		DATA	"DAFFODIL"
		DATA	000
		DATA "SIDEREAL"
		DATA	000
		DATA	"CRICKET"
		DATA	000
		DATA	"COURIER"
		DATA	000
		DATA	"COSMOS"
		DATA	000
		DATA	"CHEMIST"
		DATA	000
		DATA	"CHEMICAL"
		DATA	000
		DATA	"CHICORY"
		DATA	000
		DATA	"CHLORINE"
		DATA	000
		DATA	"CITIZEN"
		DATA	000
		DATA	"CITRUS"
		DATA	000
		DATA	"CLOSET"
		DATA	000
		DATA	"COGENT"
		DATA	000
		DATA	"BIRD"
		DATA	000
		DATA	"BEETLE"
		DATA	000
		DATA	"BELIEVE"
		DATA	000
		DATA	"BATHTUB"
		DATA	000
		DATA	"BASKET"
		DATA	000
		DATA	"BANQUET"
		DATA	000
		DATA	"BABBITT"
                DATA	000
		DATA	"BACKBONE"
		DATA	000
		DATA	"AUDIBLE"
		DATA	000
		DATA	"ASPIRIN"
		DATA	000
		DATA	"ASTEROID"
                DATA	000
		DATA	"APPROVAL"
                DATA	000
		DATA	"APOGEE"
		DATA	000
		DATA	"ANNUITY
                DATA	000
		DATA	"ANODIZE"
		DATA	000
		DATA	"ALUMINUM"
		DATA	000
		DATA	"AIR"
		DATA	000
		DATA	"AISLE"
		DATA	000
		DATA	"ADJOIN"
		DATA	000
		DATA	"ABYSS"
		DATA	000
		DATA	"ABOLISH"
		DATA	000
		DATA	"QUEUE"
		DATA	000
		DATA	"QUIVER"
		DATA	000
	DATA	"QUALM"
		DATA	000
		DATA	"QUITE"
		DATA	000
		DATA	"QUIXOTIC"
		DATA	000
		DATA	"QUOIN"
		DATA	000
	DATA	"QUOIT"
		DATA	000
		DATA	"QUOTIENT"
		DATA	000
		DATA	"RADIO"
		DATA	000
		DATA	"RAISIN"
		DATA	000
		DATA	"RAPT"
		DATA	000
		DATA	"RATIO"
		DATA	000
		DATA	"RAUCOUS"
		DATA	000
		DATA	"RAYON"
		DATA	000
		DATA	"RAZOR"
		DATA	000
		DATA	"REALM"
		DATA	000
		DATA	"REEK"
		DATA	000"
		DATA	"REGISTER"
		DATA	000
		DATA	"RIVET"
		DATA	000
		DATA	"SCHOONER"
		DATA	000
		DATA	"SAUNA"
		DATA	000
		DATA	"SATIN"
		DATA	000
		DATA	"SCEPTER"
		DATA	000
		DATA	"SCIENCE"
		DATA	000
		DATA	"SCRIBBLE"
		DATA	000
		DATA	"BEHIND"
		DATA	000
		DATA	"DIGNIFY"
		DATA	000
		DATA	"ELLIPTIC"
		DATA	000
		DATA	"ELOQUENT"
		DATA	000
		DATA	"ELUSIVE"
		DATA	000
		DATA	"FEATHER"
		DATA	000
		DATA	"GALLOWS"
		DATA	000
		DATA	"GARDEN"
		DATA	000
		DATA	"GAZELLE"
		DATA	000
		DATA	"MACABRE"
		DATA	000
		DATA	"VALIANT"
		DATA	000	
		DATA	"VENISON"
		DATA	000
		DATA	"VIVID"
		DATA	000
		DATA	"WEIGHT"
		DATA	000
		DATA	"WEIRD"
		DATA	000
		DATA	"WISE"
		DATA	000
		DATA	"ZERO"
		DATA	000
		DATA	"ZOOLOGY"
		DATA	000
		DATA	"ZENITH"
		DATA	000
		DATA	"YAWN"
		DATA	000
		DATA	"YOLK"
		DATA	000
		DATA	"YELLOW"
		DATA	000
		DATA	"YULE"
		DATA	000
		DATA	"TRICKLE"
		DATA	000	
		DATA	"END"
		DATA	000
		DATA	000
