;Display four hex digits of word in LED
; LED 2 8279
; ports: control 31 to select left entry (08) or right entry (18)
;        data    30 to output 7seg digit
;letters k m t w x hard...
    
                
Connect led79
                     
	JMP	Start                                                     
	;the 7seg codes for 0-F
	DB	3F,06,5B,4F,66,6D,7D,07,7F,67,77,7C,39,5E,79,71
		
Start:	MOV	BX,1003		;start of 7seg array
						
;select right entry (good for scrolling)
        MOV     AL,18	
        OUT     31,AL 	

	;blank all 16 digits of the LED
	MOV	CX,10		
	MOV	AL,0
ClrDgt:	OUT	30,AL
	LOOP	ClrDgt
	;hlt			;all blank if halt but...???

	MOV	DI,def0		;test number

	MOV	DX,DI		;original number
	AND	DX,f000		;mask all but first (leftmost) hex digit
	MOV	CL,0C		;SHR only uses CL for shift amount
	SHR	DX,CL		;right shift to lower 4 bits
	MOV	SI,DX
        MOV     AL,BPTR[BX+SI]	;array base + index
        OUT     30,AL  		;output to LED

	MOV	DX,DI		
	AND	DX,0f00		;mask all but second hex digit
	MOV	CL,08		;SHR only uses CL for shift amount
	SHR	DX,CL		;right shift to lower 4 bits
	MOV	SI,DX
        MOV     AL,BPTR[BX+SI]	;array base + index
        OUT     30,AL  		;output to LED

	MOV	DX,DI		
	AND	DX,00f0		;mask all but third hex digit
	MOV	CL,04		;SHR only uses CL for shift amount
	SHR	DX,CL		;right shift to lower 4 bits
	MOV	SI,DX
        MOV     AL,BPTR[BX+SI]	;array base + index
        OUT     30,AL  		;output to LED

	MOV	DX,DI		
	AND	DX,000f		;mask all but first hex digit
	MOV	SI,DX		;shifting not needed
        MOV     AL,BPTR[BX+SI]	;array base + index
        OUT     30,AL  		;output to LED

	HLT
   
