From 41d6a33d31d348563a9c97b7cf25752e8e64f599 Mon Sep 17 00:00:00 2001 From: Jeffrey Armstrong Date: Wed, 13 Nov 2024 13:51:48 -0500 Subject: Added bus width detection that appears to work on an 8088. --- asm/386q.asm | 61 +++++++++++++++++++++++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 9 deletions(-) (limited to 'asm/386q.asm') diff --git a/asm/386q.asm b/asm/386q.asm index 4496d66..bf58033 100644 --- a/asm/386q.asm +++ b/asm/386q.asm @@ -1,3 +1,14 @@ + ; Results: + ; 0 - 8088 + ; 1 - 8086 + ; 2 - V20 + ; 3 - V30 + ; 4 - 80188 + ; 5 - 80186 + ; 6 - 80286 + ; 7 - 80386+ + + push bp mov bp, sp @@ -13,8 +24,8 @@ cmp ax, 0xf000 ;0f000h je lessthantwoeightsix - ; marked as 286 (2) - mov dl, 2 + ; marked as 286 (6) + mov dl, 6 mov ax, 0x7000 ;7000h push ax @@ -25,24 +36,25 @@ and ax, 0x7000 ;7000h jz alldone - ; mark as 386 (3) + ; mark as 386 (7) inc dl jmp alldone lessthantwoeightsix: - mov dl, 1 + ; Mark as 80188 (4) + mov dl, 4 mov al, 0xff ;0ffh mov cl, 0x21 ;21h shr al, cl ; if the shift leaves zero, it's a 8088 class cpu, else 80186/88 - jnz alldone + jnz buswidth - ; Lets see if we have a V20/V30 (V) - mov dl, 0x56 ;056h + ; Lets see if we have a V20/V30 (2) + mov dl, 2 sti push si @@ -55,11 +67,42 @@ lessthantwoeightsix: pop si or cx, cx - jz alldone + jz buswidth - ; mark as a 8088/8086 (0) + ; mark as a 8088/8086 (1) mov dl, 0 +buswidth: + + ; we are destroying es now, must be restored later + push cs + pop es + std + + ; The 99 _must_ be replaced with the true offset of qqend + mov di, 99 ; OFFSET qqend ;99 + + ;set up al and cx: 0xfb is the 'sti' instruction + mov al, 0xfb + mov cx, 3 + + ; disable interrupts + cli + rep stosb + + cld + nop + nop + nop + inc dx + nop +qqend: + sti + + ; ES must be restored + push ds + pop es + alldone: ; store in ax xor dh, dh -- cgit v1.2.3