• Please review our updated Terms and Rules here

Super PC/XT Bios BUG for 5150

Retro Canada

Experienced Member
Joined
Aug 23, 2012
Messages
280
Location
Vancouver, BC
I noticed the Super PC/XT Bios didn't work for my 5150 especially when activating the IBM_PC=1 flag or using the PC/XT version with mono card.

It turns out it reads the SW1 wrong, there is the fix:


ifdef IBM_PC ; Read 5150 switch config
mov al, 0CCh
out dx, al ; Reset keyboard
in al, 60h ; Read config switches
shr al, 4
mov ah, al

The flags on 5150 are in the upper nibble, the PC/XT gets them from a lower nibble in other port, That's the mistake.

Now it works with any display and boots correctly from floppy.
 
Why do you consider this a bug?
Because of differences between PC-class motherboards and XT-class motherboards, normally a motherboard BIOS is written for either, not both.
 
Why do you consider this a bug?
Because of differences between PC-class motherboards and XT-class motherboards, normally a motherboard BIOS is written for either, not both.

Because the source code says for the IBM_PC flag:


;---------------------------------------------------------------------------------------------------
; BIOS Configuration Definitions
;---------------------------------------------------------------------------------------------------
IBM_PC = 1 ; Define if using with original IBM PC (5150) or exact clone
; This will read the 5150 config switches correctly
; and set the BIOS computer type to FFh (PC) rather than FEh (XT).
; You should also disable the TURBO_ENABLED, TURBO_BOOT, and
; SLOW_FLOPPY definitions if using with an original PC.


and the source repository says:

"The Super PC/Turbo XT BIOS is heavily modified version of the widely-distributed "(c) Anonymous Generic Turbo XT" BIOS. It is a drop-in replacement for the IBM 5150/5155/5160 BIOS and most XT clones, including 8/10 MHz turbo systems."

Do you need more evidences to call this a bug ? :)
 
You should let Plasma know about this "bug". He is a member here and is the programmer for the Super PC/XT Bios.
 
shr al, 4

I must have awakened in an alternate reality. "SHR AL,4" isn't an 8088/8086 instruction--it belongs to the 80186+ category. A V20 can execute it, but not an 8088/8086. "SHR AL,1" is the only valid immediate variety of this instruction.
 
I must have awakened in an alternate reality. "SHR AL,4" isn't an 8088/8086 instruction--it belongs to the 80186+ category. A V20 can execute it, but not an 8088/8086. "SHR AL,1" is the only valid immediate variety of this instruction.

You are right ! But TASM expanded it to 4 SHR's:

741 E1DF D0 E8 D0 E8 D0 E8 D0+ shr al, 4
Turbo Assembler Version 4.1 10/21/17 14:11:37 Page 14
PCXTBIOS.ASM
742 E8

I should just use instead:

mov cl,4
shr al,cl
 
You should let Plasma know about this "bug". He is a member here and is the programmer for the Super PC/XT Bios.

Yes, that would have made sense. Instead of hoping I find this thread by chance? My email is in the readme and on my website.

No. Odd that such a basic flaw exists. Sounds like it wasn't tested. I wonder what other surprises await you.

Sounds like a stupid assumption. It was tested by myself and others with 5150s. It's also been distributed with the MTM PC-Retro 5150 kit for the past 5 years.

This is the first I've heard of this bug, but it's possible it's only a problem with certain configurations. So I will take a look at it.
 
Yes, that would have made sense. Instead of hoping I find this thread by chance? My email is in the readme and on my website.



Sounds like a stupid assumption. It was tested by myself and others with 5150s. It's also been distributed with the MTM PC-Retro 5150 kit for the past 5 years.

This is the first I've heard of this bug, but it's possible it's only a problem with certain configurations. So I will take a look at it.

I think it worked by accident. Depends what it returned in the port 060h it worked for some configs. If it helps, my config:

8088 and 8087 Intel
SixPakPlus 384K + 256K on mobo, jumpers set to 640K in total
XT-IDE
Floppy Interface - 2 drives
SB 2.0
Mono

SW1: Off Off Off Off Off Off Off On
SW2: On Off On On Off Off Off Off

Originally If i built with IBM_PC flag it never worked, no matter the settings. Then I got with the IBM_PC flag commented out and found out it worked with CGA but no Mono, it would hang.

After shifting the flags (IBM_PC=1 active) it works now with CGA, Mono or EGA (jumping the video correctly of course)

In the technical reference manual, the 5150 will return on port 060h:

0: SW 1 - 1
1: SW 1 - 2
2: SW 1 - 3
3: SW 1 - 4
4: SW 1 - 5
5: SW 1 - 6
6: SW 1 - 7
7: SW 1 - 8

And the IBM 5160 will return on port 062h:

0: SW - 5
1: SW - 6
2: SW - 7
3: SW - 8
4-7: ???
 
In the technical reference manual, the 5150 will return on port 060h:

0: SW 1 - 1
1: SW 1 - 2
2: SW 1 - 3
3: SW 1 - 4
4: SW 1 - 5
5: SW 1 - 6
6: SW 1 - 7
7: SW 1 - 8

And the IBM 5160 will return on port 062h:

0: SW - 5
1: SW - 6
2: SW - 7
3: SW - 8
4-7: ???

See the port 60h/61h/62h description at [here].
 
You are right ! But TASM expanded it to 4 SHR's:

741 E1DF D0 E8 D0 E8 D0 E8 D0+ shr al, 4
Turbo Assembler Version 4.1 10/21/17 14:11:37 Page 14
PCXTBIOS.ASM
742 E8

I should just use instead:

mov cl,4
shr al,cl

Can you turn off this gratuitous expansion in TASM? I can see where getting 8 bytes of code when one expected only 3 might be a problem (C0 E8 04 on a 186+)
 
Can you turn off this gratuitous expansion in TASM? I can see where getting 8 bytes of code when one expected only 3 might be a problem (C0 E8 04 on a 186+)

I would hope that TASM would make the necessary adjustment based on the processor specified.
 
But that's the problem--I don't want an assembler doing my thinking for me. If I want a "macro" for a shift, I'll write one myself.

Gadzooks, I have enough problems with x86 assembler not being isomorphic.
 
But that's the problem--I don't want an assembler doing my thinking for me. If I want a "macro" for a shift, I'll write one myself.

Gadzooks, I have enough problems with x86 assembler not being isomorphic.

Ok Chuck, I'm sure I would not be able to win an argument with you on this subject. However, I have one question. Do you drive a stick or automatic?
 
I noticed the Super PC/XT Bios didn't work for my 5150 especially when activating the IBM_PC=1 flag or using the PC/XT version with mono card.

It turns out it reads the SW1 wrong, there is the fix:


ifdef IBM_PC ; Read 5150 switch config
mov al, 0CCh
out dx, al ; Reset keyboard
in al, 60h ; Read config switches
shr al, 4
mov ah, al

The flags on 5150 are in the upper nibble, the PC/XT gets them from a lower nibble in other port, That's the mistake.

Now it works with any display and boots correctly from floppy.

I looked at this, and there is a bug. The flags are read correctly, but they are trashed afterwards by overlapping 5160 code. This only becomes apparent when using a CGA and/or FPU. Which unfortunately is why it was not caught during testing, because my 5150 doesn't have an 8087 and I didn't have a real CGA until recently. So thanks for bringing this to my attention.

A new version is here. Here is how it is implemented now:

Code:
ifdef	IBM_PC					; Read 5150 switch config
	mov	al, 0CCh
	out	dx, al				; Reset keyboard
	in	al, 60h				; Read config switches

else						; Read 5160 switch config
	in	al, 62h 			; Get memory size (64K bytes)
	and	al, 00001111b			;   in bits 2,3 low nibble
	mov	ah, al				; Save memory size nibble
	mov	al, 10101101b
	out	dx, al
	in	al, 62h 			; Get number of floppies (0-3)
	mov	cl, 4				;   and init video mode
	shl	al, cl				;   shift in hi nibble
	or	al, ah
endif
	mov	ah, 0

	mov	[ds:10h], ax			; Start building Equipment Flag

And yes, it's been tested on a real 5150 with combinations of MDA, Hercules, CGA, EGA, and VGA cards.
 
Yes, although it will prompt for a floppy once before booting ROM BASIC (unless you press space after the memory test).
 
Back
Top