Image Map Image Map
Results 1 to 3 of 3

Thread: IBM PC BIOS ROM Replacement: Segment Organization

  1. #1
    Join Date
    Sep 2011
    Location
    Michigan, USA
    Posts
    166

    Default IBM PC BIOS ROM Replacement: Segment Organization

    Hi, I have been working on a chunk of 8K code to replace the BIOS ROM in an IBM 5150 PC. I'm writing and compiling using MASM 2.0 So far, I have the computer booting with a welcome message on the MDA monitor, beeping the speaker and reading and displaying keys from the keyboard. These activites are accomplished with primitives that work directly with the hardware.

    What I have been struggling with is a good model for organizing and creating my segments. My CS (Code Segments) starts at the beginning of the ROM. (I manually put a jump at the starting seek location of the 8088 CPU.) My ES (Extra Segment) starts at the beginning of the SRAM on the MDA board. (B000:0000H). My SS (Stack Segment) is near the end of the SRAM, and the contents of the stack show up on the monitor as gibberish. The way that I am defining these segments is by hard coding all the Base Addresses and pointers within my code segment. I think this is probably a pretty poor way to be creating segments. BTW: Now I want to also create a Data Segment and am debating where to locate it in ROM.

    I see that MASM has at "AT" directive to locate segments. That seems like it would be useful. Although I have many books about 86X assembly, I have yet to find a really good description or example of how to create and organize assembly code for ROM. I'm wondering if anyone has seen one, or may have a good example? Thanks! Michael

  2. #2
    Join Date
    Aug 2006
    Location
    Chicagoland, Illinois, USA
    Posts
    5,405
    Blog Entries
    1

    Default

    The best way, IMO, is to go back to the source of the original BIOSes. This site has reconstructed sources of the PC, PC/XT, PC AT, and PC XT/286 BIOSes: https://sites.google.com/site/pcdosretro/ibmpcbios

    Some of the earlier files are a single source file because of limitations in Intel's assembler, but the later ones are broken up and appear to assemble with MASM.
    Offering a bounty for:
    - The software "Overhead Express" (doesn't have to be original, can be a copy)
    - A working Sanyo MBC-775, Olivetti M24, or Logabax 1600
    - Documentation and original disks for: Panasonic Sr. Partner, Zenith Z-160 series
    - Music Construction Set, IBM Music Feature edition (has red sticker on front stating IBM Music Feature)

  3. #3
    Join Date
    Jan 2007
    Location
    Pacific Northwest, USA
    Posts
    28,500
    Blog Entries
    20

    Default

    The segment "AT" modifier in MASM is useful only in the sense that it allows you to define offsets and types within a segment. Static data is not allowed within an absolute segment. Remember that MASM is an assembler with strong data typing, so that MASM remembers not only the segment of the variable, but also its type.

    Consider the following code:

    Code:
                                            .8086
    
     0000                           FOOF    SEGMENT AT 1000H
     0400                                   ORG     400H
     0400  00                       FEEF    DB      (?)
     0401                           FOOF    ENDS
    
     0000                           CODE    SEGMENT
                                            ASSUME  CS:CODE
    
     0000  B8 ---- R                        MOV     AX,SEG FOOF
     0003  8E C0                            MOV     ES,AX
                                            ASSUME  ES:FOOF
     0005  26: A0 0400 R                    MOV     AL,FEEF
    
     0009                           CODE    ENDS
                                            END
    (I'm using MASM 5.10 here, but you can use any version that fancies your tickle).


    MASM now has several bits of information from the segment content: The first is that "FEEF" is the location of a byte quantity; the second is that FEEF resides at an offset of 400H locations into the segment "FOOF", which is an absolute reference to a segment beginning at byte address 00010000h.

    So, if you load ES with the base of the segment FOOF and tell MASM about it (via the ASSUME directive), it will automatically generate the proper instruction, complete with the correct segment override.

    If you ensure that your ASSUME directives accurate track the contents of your segment registers, you don't need to worry about explicit segment overrides most of the time--and you'll get an error if you forget to load a segment register (and declare it with ASSUME) and reference a variable within that segment.

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •