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. --- gwfetch.bas | 182 +++++++++++++++++++++++++++++++++++------------------------- 1 file changed, 106 insertions(+), 76 deletions(-) (limited to 'gwfetch.bas') diff --git a/gwfetch.bas b/gwfetch.bas index b7b509d..4512e6d 100644 --- a/gwfetch.bas +++ b/gwfetch.bas @@ -63,89 +63,119 @@ 12001 DIM Q%(400) 12005 DEF SEG=VARSEG(Q%(0)) 12006 OS%=VARPTR(Q%(0)) -12010 FOR I = 1 TO 76 +12007 BWOFFSET = -1: LASTBYTE = 0 +12010 FOR I = 1 TO 99 12020 READ JC:POKE I+OS%, JC +12021 REM Detect where we need to insert an offset for bus width detection +12022 IF LASTBYTE=99 AND JC=0 THEN BWOFFSET = I+OS% - 1: PRINT "BW ";BWOFFSET +12023 LASTBYTE = JC 12025 print i, peek(i+OS%) 12030 NEXT I -12040 CPUQ = 1 + OS% -12041 print "Calling!" -12045 CALL CPUQ(CPUID%) -12047 DEF SEG - -12048 REM CPUID% = PEEK(3) - -12050 DATA &H55 : REM push bp -12051 DATA &H89, &HE5 : REM mov bp, sp -12052 REM ; push zero onto the stack and pop it into flags. -12053 REM ; some bits won't change -12054 DATA &H31, &HC0 : REM xor ax,ax -12055 DATA &H50 : REM push ax -12056 DATA &H9D : REM popf -12057 DATA &H9C : REM pushf -12058 DATA &H58 : REM pop ax -12059 DATA &H25, &H00, &HF0 : REM and ax, 0xf000 ;0f000h -12060 DATA &H3D, &H00, &HF0 : REM cmp ax, 0xf000 ;0f000h -12061 DATA &H74, &H13 : REM je lessthantwoeightsix -12062 REM ; marked as 286 (2) -12063 DATA &HB2, &H02 : REM mov dl, 2 -12064 DATA &HB8, &H00, &H70 : REM mov ax, 0x7000 ;7000h -12065 DATA &H50 : REM push ax -12066 DATA &H9D : REM popf -12067 DATA &H9C : REM pushf -12068 DATA &H58 : REM pop ax -12069 DATA &H25, &H00, &H70 : REM and ax, 0x7000 ;7000h -12070 DATA &H74, &H22 : REM jz alldone -12071 REM ; mark as 386 (3) -12072 DATA &HFE, &HC2 : REM inc dl -12073 DATA &HE9, &H1D, &H00 : REM jmp alldone -12074 REM lessthantwoeightsix: -12075 DATA &HB2, &H01 : REM mov dl, 1 -12076 DATA &HB0, &HFF : REM mov al, 0xff ;0ffh -12077 DATA &HB1, &H21 : REM mov cl, 0x21 ;21h -12078 DATA &HD2, &HE8 : REM shr al, cl -12079 REM ; if the shift leaves zero, it's a 8088 class cpu, else 8018 -12080 DATA &H75, &H13 : REM jnz alldone -12081 REM ; Lets see if we have a V2 -12082 DATA &HB2, &H56 : REM mov dl, 0x56 ;056h -12083 DATA &HFB : REM sti -12084 DATA &H56 : REM push si -12085 DATA &HBE, &H00, &H00 : REM mov si, 0 -12086 DATA &HB9, &HFF, &HFF : REM mov cx, 0xffff ;0ffffh -12087 REM ;rep lods [BYTE PTR es:si] -12088 DATA &HF2, &HAC : REM rep lodsb -12089 DATA &H5E : REM pop si -12090 DATA &H09, &HC9 : REM or cx, cx -12091 DATA &H74, &H02 : REM jz alldone -12092 REM ; mark as a 808 -12093 DATA &HB2, &H00 : REM mov dl, 0 -12094 REM alldone: -12095 REM ; store in ax -12096 DATA &H30, &HF6 : REM xor dh, dh -12097 DATA &H8B, &H7E, &H06 : REM mov di, [bp]+6 -12098 DATA &H89, &H15 : REM mov [di], dx -12099 DATA &H5D : REM pop bp -12100 DATA &HCA, &H02, &H00 : REM ); { retf 2} -12101 REM Total Bytes in Data: 76 - - +12039 REM Need to set the offset for bus width +12040 TGTOFFSET = BWOFFSET + 16 +12045 print BWOFFSET, peek(BWOFFSET) +12046 print TGTOFFSET, peek(TGTOFFSET) + +12050 POKE BWOFFSET, (TGTOFFSET MOD 256) +12060 POKE BWOFFSET+1, INT(TGTOFFSET / 256) +12065 print BWOFFSET, peek(BWOFFSET) +12070 return + +12080 CPUQ = 1 + OS% +12090 print "Calling!" +12095 CALL CPUQ(CPUID%) +12097 DEF SEG + +12100 REM ; Results: +12101 REM ; 0 - 8088 +12102 REM ; 1 - 8086 +12103 REM ; 2 - V20 +12104 REM ; 3 - V30 +12105 REM ; 4 - 80188 +12106 REM ; 5 - 80186 +12107 REM ; 6 - 80286 +12108 REM ; 7 - 80386+ +12109 DATA &H55 : REM push bp +12110 DATA &H89, &HE5 : REM mov bp, sp +12111 REM ; push zero onto the stack and pop it into flags. +12112 REM ; some bits won't change +12113 DATA &H31, &HC0 : REM xor ax,ax +12114 DATA &H50 : REM push ax +12115 DATA &H9D : REM popf +12116 DATA &H9C : REM pushf +12117 DATA &H58 : REM pop ax +12118 DATA &H25, &H00, &HF0 : REM and ax, 0xf000 ;0f000h +12119 DATA &H3D, &H00, &HF0 : REM cmp ax, 0xf000 ;0f000h +12120 DATA &H74, &H13 : REM je lessthantwoeightsix +12121 REM ; marked as 286 (6) +12122 DATA &HB2, &H06 : REM mov dl, 6 +12123 DATA &HB8, &H00, &H70 : REM mov ax, 0x7000 ;7000h +12124 DATA &H50 : REM push ax +12125 DATA &H9D : REM popf +12126 DATA &H9C : REM pushf +12127 DATA &H58 : REM pop ax +12128 DATA &H25, &H00, &H70 : REM and ax, 0x7000 ;7000h +12129 DATA &H74, &H39 : REM jz alldone +12130 REM ; mark as 386 (7) +12131 DATA &HFE, &HC2 : REM inc dl +12132 DATA &HE9, &H34, &H00 : REM jmp alldone +12133 REM lessthantwoeightsix: +12134 REM ; Mark as 80188 (4) +12135 DATA &HB2, &H04 : REM mov dl, 4 +12136 DATA &HB0, &HFF : REM mov al, 0xff ;0ffh +12137 DATA &HB1, &H21 : REM mov cl, 0x21 ;21h +12138 DATA &HD2, &HE8 : REM shr al, cl +12139 REM ; if the shift leaves zero, it's a 8088 class cpu, else 8018 +12140 DATA &H75, &H13 : REM jnz buswidth +12141 REM ; Lets see if we have a V2 +12142 DATA &HB2, &H02 : REM mov dl, 2 +12143 DATA &HFB : REM sti +12144 DATA &H56 : REM push si +12145 DATA &HBE, &H00, &H00 : REM mov si, 0 +12146 DATA &HB9, &HFF, &HFF : REM mov cx, 0xffff ;0ffffh +12147 REM ;rep lods [BYTE PTR es:si] +12148 DATA &HF2, &HAC : REM rep lodsb +12149 DATA &H5E : REM pop si +12150 DATA &H09, &HC9 : REM or cx, cx +12151 DATA &H74, &H02 : REM jz buswidth +12152 REM ; mark as a 808 +12153 DATA &HB2, &H00 : REM mov dl, 0 +12154 REM buswidth: +12155 REM ; we are destroying es now, must be restored later +12156 DATA &H0E : REM push cs +12157 DATA &H07 : REM pop es +12158 DATA &HFD : REM std +12159 REM ; The 99 _must_ be replaced with the true offset of qqend +12160 DATA &HBF, &H63, &H00 : REM mov di, 99 ; OFFSET qqend ;99 +12161 REM ;set up al and cx: 0xfb is the 'sti' instruction +12162 DATA &HB0, &HFB : REM mov al, 0xfb +12163 DATA &HB9, &H03, &H00 : REM mov cx, 3 +12164 REM ; disable interrupts +12165 DATA &HFA : REM cli +12166 DATA &HF2, &HAA : REM rep stosb +12167 DATA &HFC : REM cld +12168 DATA &H90 : REM nop +12169 DATA &H90 : REM nop +12170 DATA &H90 : REM nop +12171 DATA &H42 : REM inc dx +12172 DATA &H90 : REM nop +12173 REM qqend: +12174 DATA &HFB : REM sti +12175 REM ; ES must be restored +12176 DATA &H1E : REM push ds +12177 DATA &H07 : REM pop es +12178 REM alldone: +12179 REM ; store in ax +12180 DATA &H30, &HF6 : REM xor dh, dh +12181 DATA &H8B, &H7E, &H06 : REM mov di, [bp]+6 +12182 DATA &H89, &H15 : REM mov [di], dx +12183 DATA &H5D : REM pop bp +12184 DATA &HCA, &H02, &H00 : REM ); { retf 2} +12185 REM Total Bytes in Data: 99 12200 RETURN - -13000 REM CPU Identity via dim -13010 dim A%(37) -13030 FOR I = 0 TO 14-1 -13040 READ JC:PRINT JC:POKE (VARPTR(A%(1))+I), JC -13045 PRINT I -13050 NEXT I -13060 CPUQ = VARPTR(A%(1)) - -13080 RETURN - - - - 30000 REM String Trim Function 30010 REM input/output: TOTRIM$ 30020 FOR IDX = 1 TO LEN(TOTRIM$):IF MID$(TOTRIM$, IDX, 1) <> " " THEN GOTO 30030:NEXT IDX -- cgit v1.2.3