Skip to content

Commit 07155e6

Browse files
committed
fix bug#123, detect NEC V20/V30 as 186 instead of only 8086/8088, based on ecm-pushbx ldebug
see https://hg.pushbx.org/ecm/ldebug/file/7f3440d5824d/source/init.asm#l3071 (cherry picked from commit 5fdcc1d)
1 parent 431be02 commit 07155e6

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

kernel/cpu.asm

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,22 @@ CPU 386
4848
and ax, 0f000h
4949
cmp ax, 0f000h
5050
jnz is286 ; no the 4 msb stuck set to 1, so is a 808x or 8018x
51+
; NEC V20/V30 support 186 instructions but
52+
; do not mask the shift count like a 186.
53+
; based on https://hg.pushbx.org/ecm/ldebug/file/7f3440d5824d/source/init.asm#l3071
54+
; which is based on http://www.textfiles.com/hamradio/v20_bug.txt
55+
mov ax, sp ; we use stack to do test
56+
mov cx, 1 ; after pop still 1 if 8088/8086
57+
push cx
58+
dec cx ; after pop still 0 if NEC V20/V30
59+
; next instructions may lock system if breakpoint or trace flag set
60+
db 8Fh, 0C1h; pop r/m16 with operand cx on 808x, nop on NEC V20/V30
61+
mov sp, ax ; reset stack to known good state (pre push, optional pop)
62+
xor cx, cx ; cx is 1 if NEC, 0 if 808x
63+
jz is808x
64+
mov bx, cx
65+
jmp short cleanup
66+
is808x:
5167
mov ax,1 ; determine if 8086 or 186
5268
mov cl,64 ; try to shift further than size of ax
5369
shr ax,cl

0 commit comments

Comments
 (0)