;
;  ASKGUS-Routine v2.0
;
;  Public Release!!!!
;
;  brought to you by Capella of Escape
;
;  Use this way of locating the GUS-settings instead of hardware-testing!!!!
;
;  cap/esc
;


ideal
model small
p386n
stack 256

assume cs:coding

segment  coding

gusport         dw 0

start:          mov ax,[es:2ch]
                mov es,ax
                
                mov ax,0003h
                int 10h

                mov ax,data1
                mov ds,ax
                assume ds:data1

                call askgus
                cmp [cs:gus],1
                je warte1
                mov ah,09h
                mov dx,offset gus2
                int 21h
                jmp warte

warte1:         mov ah,09h
                mov dx,offset gus1
                int 21h
                
                call askport
                
                mov dx,0b800h
                mov es,dx
                assume es:0b800h

                mov [es:0000],al
                mov [es:0002],ah
                mov [byte es:0004],"0"

warte:          in al,60h
                cmp al,01h
                jne warte

                mov ax,4c00h
                int 21h

gus             db 0
askgus:         xor si,si
                
newcheck:       mov al,[es:si]
                cmp al,"U"
                jne checknext
                mov al,[es:si+1]
                cmp al,"L"
                jne checknext
                mov al,[es:si+2]
                cmp al,"T"
                jne checknext
                mov al,[es:si+3]
                cmp al,"R"
                jne checknext
                mov al,[es:si+4]
                cmp al,"A"
                jne checknext
                mov al,[es:si+5]
                cmp al,"S"
                jne checknext
                mov al,[es:si+6]
                cmp al,"N"
                jne checknext
                mov al,[es:si+7]
                cmp al,"D"
                jne checknext
                mov al,[es:si+8]
                cmp al,"="
                jne checknext

                mov [cs:gus],1
                ret

checknext:      inc si
                cmp si,2000
                jne newcheck
                ret

askport:        mov bx,210h
                mov ax,[es:si+9]
                cmp ax,"21"
                je portfound
                add bx,10h
                cmp ax,"22"
                je portfound
                add bx,10h
                cmp ax,"23"
                je portfound
                add bx,10h
                cmp ax,"24"
                je portfound
                add bx,10h
                cmp ax,"25"
                je portfound
                add bx,10h
                cmp ax,"26"
                je portfound
                mov [cs:gus],0
                ret

portfound:      mov [cs:gus],1
                mov [cs:gusport],bx
                ret

ends  coding

segment  data1

gus1            db 13,10,"GUS found!$"
gus2            db 13,10,"GUS not found!$"

ends  data1

end start



