Compaq's efforts were possible because IBM had used mostly off-the-shelf parts for the PC and published full technical documentation for it, and because Microsoft had kept the right to license MS-DOS to other computer manufacturers.
The only difficulty was the BIOS, because it contained IBM's copyrighted code.
Compaq solved this problem by producing a clean room workalike that performed all documented functions of the IBM PC BIOS, but was completely written from scratch.

Although numerous other companies soon also began selling PC compatibles, few matched Compaq's remarkable achievement of essentially-complete software compatibility with the IBM PC (typically reaching "95% compatibility" at best) until Phoenix Technologies and others began selling similarly reverse-engineered BIOSs on the open market.

The first Portables used Compaq DOS 1.10, essentially identical to PC DOS 1.10 except for having a standalone BASIC that did not require the IBM PC's ROM Cassette BASIC, but this was superseded in a few months by DOS 2.00 which added hard disk support and other advanced features.

Aside from using DOS 1.x, the initial Portables are similar to the 16k-64k models of the IBM PC in that the BIOS was limited to 544k of RAM and did not support expansion ROMs, thus making them unable to use EGA/VGA cards, hard disks, or similar hardware.
After DOS 2.x and the IBM XT came out, Compaq upgraded the BIOS.
Although the Portable was not offered with a factory hard disk, users commonly installed them.
Starting in 1984, Compaq began offering a hard disk-equipped version, the Portable Plus, which also featured a single half-height floppy drive.
The hard disk offered would be 10 to 21 megabytes, although bad sectors often reduced the space available for use.

In 1985, Compaq introduced the Portable 286, but it was replaced by the more compact Portable II in a redesigned case within a few months.
The Portable 286 featured a full height hard disk, and the options of one half-height floppy drive, two half-height floppy drives, or a half-height floppy drive and a tape backup drive.
Compaq's efforts were possible because IBM had used mostly off-the-shelf parts for the PC and published full technical documentation for it, and because Microsoft had kept the right to license MS-DOS to other computer manufacturers. The only difficulty was the BIOS, because it contained IBM's copyrighted code. Compaq solved this problem by producing a clean room workalike that performed all documented functions of the IBM PC BIOS, but was completely written from scratch.
Although numerous other companies soon also began selling PC compatibles, few matched Compaq's remarkable achievement of essentially-complete software compatibility with the IBM PC (typically reaching "95% compatibility" at best) until Phoenix Technologies and others began selling similarly reverse-engineered BIOSs on the open market.
The first Portables used Compaq DOS 1.10, essentially identical to PC DOS 1.10 except for having a standalone BASIC that did not require the IBM PC's ROM Cassette BASIC, but this was superseded in a few months by DOS 2.00 which added hard disk support and other advanced features.
Aside from using DOS 1.x, the initial Portables are similar to the 16k-64k models of the IBM PC in that the BIOS was limited to 544k of RAM and did not support expansion ROMs, thus making them unable to use EGA/VGA cards, hard disks, or similar hardware. After DOS 2.x and the IBM XT came out, Compaq upgraded the BIOS. Although the Portable was not offered with a factory hard disk, users commonly installed them. Starting in 1984, Compaq began offering a hard disk-equipped version, the Portable Plus, which also featured a single half-height floppy drive. The hard disk offered would be 10 to 21 megabytes, although bad sectors often reduced the space available for use.
In 1985, Compaq introduced the Portable 286, but it was replaced by the more compact Portable II in a redesigned case within a few months. The Portable 286 featured a full height hard disk, and the options of one half-height floppy drive, two half-height floppy drives, or a half-height floppy drive and a tape backup drive.
Compaq Portable