La détection de materiel

 
IX- Page Ports COM
 
Les méandres du BIOS sont encore ici à notre secours. Il faut savoir qu'au démarrage du PC, le BIOS utitlise des variables qu'il stocke dans la RAM à l'adresse 0040:0000h. Leur lecture suffira ici amplement, il faut juste faire attention à la norme Little Endian qui range les octets à l'envers.
 
 
PagePorts: 
         call ModeTexte 
         mov dx,offset Ports_Init 
         call PutString 
         mov dx,offset Ports_Sad 
         call PutString 

         push es 
         mov ax,40h 
         mov es,ax 
         mov si,offset Ports_NbPorts 
         xor di,di 
PPb1: 
         mov ax,es:[di] 
         cmp ax,0 
         je PPb2 
         call PutHexaWord 
         mov dl,',' 
         call Putch 
         mov dl,' ' 
         call Putch 
         add di,2 
         inc byte ptr ds:[si] 
         cmp byte ptr ds:[si],4 
         je PPb2 
         jmp PPb1 
PPb2: 
         mov dx,offset Ports_Pad 
         call PutString 
         inc si 
         mov di,08h 
        PPb3: 
         mov ax,es:[di] 
         cmp ax,0 
         je PPb4 
         call PutHexaWord 
         mov dl,',' 
         call Putch 
         mov dl,' ' 
         call Putch 
         add di,2 
         inc byte ptr ds:[si] 
         cmp byte ptr ds:[si],4 
         je PPb4 
         jmp PPb3 
PPb4: 

         mov dx,offset Ports_STo 
         call PutString 
         mov si,offset Ports_NbPorts 
         mov cl,byte ptr ds:[si] 
         mov di,7ch 
PPb5: 
         cmp cl,0 
         je PPb6 
         xor ax,ax 
         mov al,es:[di] 
         call PutWord 
         mov dl,',' 
         call Putch 
         mov dl,' ' 
         call Putch 
         inc di 
         dec cl 
         jmp PPb5 
PPb6: 
         mov dx,offset Ports_PTo 
         call PutString 
         mov si,offset Ports_NbPorts 
         mov cl,byte ptr ds:[si+1] 
         mov di,78h 
PPb7: 
         cmp cl,0 
         je PPb8 
         xor ax,ax 
         mov al,es:[di] 
         call PutWord 
         mov dl,',' 
         call Putch 
         mov dl,' ' 
         call Putch 
         inc di 
         dec cl 
         jmp PPb7 
PPb8: 
         pop es 

EndPagePorts: 
         call Page_HitAnyKey 
         ret