;****** BIOS entry INT 17h *************************************

PrnTab: dw	P1ChrOut,PInit,P1Status

Int17:  cmp	ah,MaxI17+1
	jc	Int17A
	jmp	NoInt

Int17A:	mov     word ptr cs:[reg_ds],ds
        mov     word ptr cs:[reg_bx],bx 
	mov     bx,cs
	mov	ds,bx			;no further cs: prefix
	mov     word ptr [reg_sp],sp 	;entry stack
        mov     word ptr [reg_ss],ss
	mov	ss,bx			;local stack segment
        lea     bx,cs:PrnTab            ;ptr to func0
        jmp     bios

;****** BIOS entry INT 10h *************************************

CrtTab: dw      Dummy,Fail,Int102,Int103,Fail,Fail,Int106,Int107
        dw      Int108,Int109,Int10A,Fail,Fail,Fail,Int10E,Int10F
        dw      Fail,Fail,Fail,Fail,Fail,Fail


Int10:  cmp	ah,MaxI10+1
	jnc	NoInt

        mov     word ptr cs:[reg_ds],ds
        mov     word ptr cs:[reg_bx],bx 
	mov     bx,cs
	mov	ds,bx			;no further cs: prefix
	mov     word ptr [reg_sp],sp 	;entry stack
        mov     word ptr [reg_ss],ss
	mov	ss,bx			;local stack segment
        lea     bx,cs:CrtTab            ;ptr to func0

;****** BIOS common overhead ***********************************

BIOS:   sal     ah,1                    ;call subfunction:
        add	bl,ah			;offset 16bit
        adc     bh,0			;
	sar	ah,1			;restore ah
        lea     bx,cs:bx		;bx -> addr of subfunction
        lea     sp,cs:mystack		;local stack offset
	mov     word ptr [reg_cx],cx	;loop count, XY etc
        mov     word ptr [reg_dx],dx	;XY etc
        mov     word ptr [reg_ax],ax	;pars & subfunction
        call    [bx]                   	;bx destroyed

ExBIOS: mov     ax,word ptr [reg_ax]	;restore/return parameters
	mov     bx,word ptr [reg_bx]
        mov     cx,word ptr [reg_cx]
        mov     dx,word ptr [reg_dx]
	mov     sp,word ptr [reg_sp]	;entry stack offset &
        mov     ss,word ptr [reg_ss]	;segment
        mov	ds,word ptr [reg_ds]	;entry data segment
NoInt:  iret

;------ Testroutines --------------------------------------------


fail:   mov     ah,byte ptr cs:[Reg_Ax+1]
        cmp     ah,10
        jc      cipher
        add     ah,'A'-10               ;'A..?'
        jmp     ExMiss
cipher: add     ah,'0'                  ;'0..9'
ExMiss: mov     al,ah
        call    int10e
        call    ring
dummy:	ret
