I want to write my own BIOS for an old IBM PC clone. I'm not starting
from scratch but wanted to use a source I found on the Web. I also
created a source using a disassembler on one of the ROMs I have.
I assembled the file found on Internet with MASM 4.0 and TASM 5.0,
linked the OBJs with LINK 3.05 /TLINK 7.1 and then used EXE2BIN. In
the first case I get "File cannot be converted", in the second case
"Fatal: No program entry point".
In the above case ORG was set to 0E000h. If I set it to 0, with MASM I
get the same result. But with TASM and TLINK I get a COM file that is
8192 bytes. But unusable because of the wrong offset.
How can I create the right BIN? (I don't mind using NASM if needed)
Thank you very much for any help!
Kind regards, Ruud Baltissen
www.Baltissen.org
You only need nasm, here is a very simple 4k skeleton
ORG 0F000h ; 4Kbyte ROM 0xFF000
COLD_START:
...
TIMES 01000h-16-($-$$) db 0 ; Top of ROM area, reset vector
DB 0EAh ; Jump to cold start
DW 0F000h
DW 0F000h
then assemble it using:
nasm -f bin -o xxx.bin -l xxx.lst xxx.asm
Regards,
Hans.
www.ht-lab.com
"Ruud" wrote in message
news:c3e66dc8-f019-4175...@gu8g2000vbb.googlegroups.com...
> Hallo allemaal,
>
> I want to write my own BIOS for an old IBM PC clone. I'm not starting
> from scratch but wanted to use a source I found on the Web.
Which source? The one I have here came from XTBIOS.ZIP and has the
following excerpt:
code SEGMENT
ORG 0E000h
BANNER db ' Generic Turbo XT Bios 1987',CR,LF
db ' for 8088 or V20 cpu',CR,LF
db ' (c)Anonymous',CR,LF
db LF,0
and is dated 18-jan-1988. This assembles fine using MASM 4.0 with one
warning:
;******************************************************************************
ENTRY 0FFF0h ; Hardware power reset entry *
PUBLIC POWER ; ...ic "8088" or "V20" *
FFF0 POWER: JMPF 0F000h,COLD ; ...begins here on power up *
;******************************************************************************
ENTRY 0FFF5h ; Release date, Yankee style
FFF5 30 38 2F 32 33 2F 38 db "08/23/87" ; ...MM/DD/YY (not logical)
37
ENTRY 0FFFEh
FFFE FE db 0FEh ; Computer type (XT)
; db ? ; Checksum byte
FFFF code ENDS
bios.ASM(3795) : error 102: Segment near (or at) 64K limit
;
END
which is not surprising given the context of a 64K file...
It links OK with MS LINK 3.65 (with the usual warning of no stack
segment) and the resulting bin file after trimming away the first
0xf000 (or was it 0x10000) bytes leaves a 0x2000 byte file that looks
like it contains viable code -- I haven't actually done anything with
it to confirm...
> I also
> created a source using a disassembler on one of the ROMs I have.
> I assembled the file found on Internet with MASM 4.0 and TASM 5.0,
> linked the OBJs with LINK 3.05 /TLINK 7.1 and then used EXE2BIN. In
> the first case I get "File cannot be converted", in the second case
> "Fatal: No program entry point".
>
> In the above case ORG was set to 0E000h. If I set it to 0, with MASM I
> get the same result. But with TASM and TLINK I get a COM file that is
> 8192 bytes. But unusable because of the wrong offset.
>
> How can I create the right BIN? (I don't mind using NASM if needed)
>
> Thank you very much for any help!
>
> Kind regards, Ruud Baltissen
> www.Baltissen.org
Maybe your problem is EXE2BIN-related? EXE2BIN is very DOS version
specific...
Pete
--
"We have not inherited the earth from our ancestors,
we have borrowed it from our descendants."
>Hallo allemaal,
>
>I want to write my own BIOS for an old IBM PC clone. I'm not starting
>from scratch but wanted to use a source I found on the Web. I also
>created a source using a disassembler on one of the ROMs I have.
Just out of curiosity, how would you go about using your
BIOS on an old PC, without actually burning it into a ROM
chip? (Or do you have access to old chips and burners?)
I don't think any PC clones had shadow RAM... not until AT
clones, as I recall.
So I'm guessing you will be loading it into ordinary RAM
with a custom boot loader. Maybe put it right at the top of
RAM, and then have it return a fake lower RAM top?
I seem to recall that ROM BIOS uses some fixed address
locations, which would need to be patched.
Interesting project!
Best regards,
Bob Masta
DAQARTA v6.01
Data AcQuisition And Real-Time Analysis
www.daqarta.com
Scope, Spectrum, Spectrogram, Sound Level Meter
Frequency Counter, FREE Signal Generator
Pitch Track, Pitch-to-MIDI
Science with your sound card!
That's the obvious way, I used to modify the BIOS of several machines
back around 1984/85/86, in order to support hard disks not included in
the original BIOS table.
On IBM there was a single BIOS checksum afair, but clone vendors were
more paranoid, in particular one brand which I know used to pirate their
supposedly "in-house developed" bios: They had 3 different, partially
overlapping, checksums, one of them specifically covered the hard disk
table.
> I don't think any PC clones had shadow RAM... not until AT
> clones, as I recall.
>
> So I'm guessing you will be loading it into ordinary RAM
> with a custom boot loader. Maybe put it right at the top of
> RAM, and then have it return a fake lower RAM top?
>
> I seem to recall that ROM BIOS uses some fixed address
> locations, which would need to be patched.
The original BIOS did indeed use a bunch of fixed addresses, both at the
top of the range: 0FFFFh:0 is of course the 808x reset start vector,
later modified by Intel to be the equivalent 0F000h:0FFF0h which would
theoretically obviate the need for an initial far jump to get a usefully
large code segment available, but bios code still tended to make that
initial far jump.
>
> Interesting project!
--
- <Terje.Mathisen at tmsw.no>
"almost all programming can be viewed as an exercise in caching"
I just assumed he was burning a PROM or EEPROM. An old XT or AT should use
something small like 8KB, 16KB, 32KB, or 64KB chips, maybe even 4KB! He'd
need a schematic or the circuit board to confirm via chip numbers. I'd
think some of those chips should still be available for use with various
embedded cpu's and use in industrial machines.
> So I'm guessing you will be loading it into ordinary RAM
> with a custom boot loader. Maybe put it right at the top of
> RAM, and then have it return a fake lower RAM top?
>
Can the PC, XT, or AT switch out ROM for RAM via software? I know the old
C64 could... I'd be a bit surprised if an IBM or clone could. The purpose
of that in the C64, AIR, was to allow cartridge games to use all available
RAM.
> I seem to recall that ROM BIOS uses some fixed address
> locations, which would need to be patched.
>
If he had had an old AT clone instead of a PC clone, he could've looked at
the Boch's BIOS for most of them:
http://bochs.sourceforge.net/cgi-bin/lxr/source/bios/rombios.c?v=2.4.5
Unfortunately, IIRC, RBIL only has the AT values too. The MESS project
(MAME based) uses the original ROM images their computer emulations. It
might be or might not be worth a look to see if one could the extract info
from MESS somehow.
Rod Pemberton
...
> I just assumed he was burning a PROM or EEPROM.
FWIW, Nasm has (fairly) recently added "-f ith" (Intel hex format) and
"-f srec" (Motorola s-record) output formats to its collection of output
formats. I believe they're used for such purposes... Not too well
"advertised" so I thought I'd mention it, in case it's of use to anybody.
Best,
Frank
Hi Ruud,
If you have the opportunity, try to find an old Hewlett Packard clone. They had a built-in BIOS feature where you press Ctrl+Alt+Insert (I believe), and it would trap to a built-in BIOS debugger like DOS's debug.com program. From there, you could examine all kinds of things, and execute "ret" to return to normal mode from the prompt. I only got to use it a few times, but it was very slick.
BIOS from those days is tricky because it is built in a lot of assembly, a lot of hacking, a lot of non-standard data formats, etc.
See if you can't find an open source IBM XT clone emulator, or use Bochs (which is i386 and later core support, but boots up in real mode), and modify that code to allow you to single-step through it from your external app, and you can debug everything there.
Seeing everything in an emulator will let you see exactly what's happening at all steps, especially if the emulator is known to work properly with the code you're trying to debug.
Hope this helps.
- Rick C. Hodgin
> You only need nasm, here is a very simple 4k skeleton
This works fine for you example but not for the sources I already
have: dozens of error messages :(
But anyway many thanks because I see this very usefull for other
things!
Groetjes, Ruud Baltissen
www.Baltissen.org
> Maybe your problem is EXE2BIN-related? EXE2BIN is very DOS version specific...
Yes, you're right; EXE2BIN is causing the trouble.
Groetjes, Ruud Baltissen
www.Baltissen.org
> Just out of curiosity, how would you go about using your
> BIOS on an old PC, without actually burning it into a ROM
> chip? (Or do you have access to old chips and burners?)
What gave you the idea that I wouldn't burn it?
But I do have several programmers, one even for the Commodore 64 :),
and loads of various EPROMs. But during the test phase I will use
EEPROMs.
Groetjes, Ruud Baltissen
www.Baltissen.org
> That's the obvious way, I used to modify the BIOS of several machines
> back around 1984/85/86, in order to support hard disks not included in
> the original BIOS table.
Could you tell me how to find this table? I have several old AT
compatibles with brooken hard disks. I have enough drives but not
those supported by these machines. I have some tricks in my sleeve but
I prefer altering this table above the rest.
Many thanks in advance!
Groetjes, Ruud Baltissen
www.Baltissen.org
The easiest is probably to look for the cyl/head/sector counts of one of
the original disks, but the table is actually quite visually obvious if
you just scroll down in a hex dump.:-)
Terje
Just to let you know what's going on....
I won't use NASM. As said before I already had some sources I wanted
to use and NASM didn't accept them. That is, many many errors where
TASM didn't see them. Still I took the time to make a disassembled IBM
XT ROM up in NASM style only to find out at the end that NASM
assembled the file using other codes then the original ROM had. Using
TASM I got exactly the same code at the end.
Reaching this "end" is another story. I found out that TASM has this /
t directive to turn a source immediatly into a COM. The problem: the
ROM starts at 0E000h. I solved this problem by adding 0DF00h bytes at
the start and deleting them again in the created COM file. The very
last byte is also a trouble shooter. When using it, TASM complains
about exceeding the 64K limit. To create the original IBM ROM I add it
by hand. And I won't need it for my self created ROMs; I intend to
drop the checksum to create space for my own routines.
For who is interested, the generated/commented/created sources are
freeware.
Groetjes, Ruud Baltissen
www.Baltissen.org
Unfortunately, you can't reliably assemble Tasm code with Nasm. If you
use the "-t" switch, and include scitech.mac (in the misc/ directory of
the source), Nasm will allegedly assemble some subset of Tasm code. I've
never figured out just which subset that is. In any case, ".model tiny"
is not supported (for some reason), so it's pretty hopeless...
> Still I took the time to make a disassembled IBM
> XT ROM up in NASM style only to find out at the end that NASM
> assembled the file using other codes then the original ROM had.
Interesting... just alternative encodings, or do you feel that Nasm was
doing something "wrong"?
> Using
> TASM I got exactly the same code at the end.
>
> Reaching this "end" is another story. I found out that TASM has this /
> t directive to turn a source immediatly into a COM. The problem: the
> ROM starts at 0E000h. I solved this problem by adding 0DF00h bytes at
> the start and deleting them again in the created COM file. The very
> last byte is also a trouble shooter. When using it, TASM complains
> about exceeding the 64K limit. To create the original IBM ROM I add it
> by hand.
Well, that's one way to get "exactly the same code". :)
> And I won't need it for my self created ROMs; I intend to
> drop the checksum to create space for my own routines.
>
> For who is interested, the generated/commented/created sources are
> freeware.
I wouldn't mind seeing the "Nasm version" that didn't come out the same,
just to look at it. fbko...@myfairpoint.net if you feel like mailing it
to me. I probably won't do anything with it...
> Groetjes, Ruud Baltissen
> www.Baltissen.org
That's very cool!!!
Best,
Frank