Also what's the minimum space that a program can occupy in memory?
I know that every register in 8086 have a maximum capacity of 16 bits
CodePudding user response:
8086 had a 20-bit linear / physical address space, so 1MiB of RAM ROM device memory.
The only mode available on 8086 was what later CPUs call "real mode", where seg:off logical addresses of two 16-bit halves map to linear addresses as (seg<<4) off
. That calculation can go slightly past 1MiB, and on later CPUs / systems, wrapping to 20 bits could be disabled (A20 gate), although that was mostly useful for other modes that set a segment base differently, allowing access to much more memory.
Michael Petch comments that some add-in cards provided a 64K window onto a large amount of physical memory, like up to 32MiB. So that's like "bank switching". To access different parts of that space, programs would have to do an I/O operation like perhaps an out
instruction. Logically it's a bit like paging to a hard drive or SSD, except that stores go directly to the extra memory, so you can switch away from a modified bank without a write-back first. And of course performance is very different, latency to switch banks is vastly lower than writing reading 64K on a rotational hard-drive. But it's not transparent to software so it doesn't work like having lots of RAM for running a program that doesn't already know about this add-in memory expansion card.
Minimum program size depends on the OS. Under DOS, a 1 byte .com
file containing C3
(ret
) will execute cleanly, returning to an exit system-call the DOS puts into its memory image. I don't know how much space different versions of DOS require to be available to actually load it; presumably at least a 512 byte disk sector plus space for the PSP (program segment prefix).
On bare metal, a 2-byte ROM with an infinite loop (jmp $
, i.e. jmp rel8=-2
) could potentially execute, although you'd only know it by watching the address lines as it re-fetched the code, since of course it couldn't do anything. (You might possibly need a cli
, although probably the CPU boots with interrupts disabled.)
If it's all that's hooked up an 8088, it would only have to decode the low bit of the address line to supply each byte separately on the 8-bit bus. If hooked up to an 8086, it wouldn't have to decode anything any address lines, just a clock and read signal, as the 16-bit but would be fetching both bytes in parallel. Or maybe you could just hard-wire those 16 pins of the 8086 to power and ground.
CodePudding user response:
The 8086 processor can address 1MB of memory using a segmented memory model. A memory segment can contain code or data (or both), and a given segment can be up to 64K.
In practice, some of the memory space is occupied by an interrupt vector table, BIOS, and by devices such as the memory buffer for graphics cards. The exact amount of addressable RAM depends on the hardware configuration.
While 1MB is the limit of memory directly addressable by the 8086 (or in real mode of later processors), additional memory can be mapped into windows of that address space using the bank switching technique.
With MS-DOS, the first standard implementation of bank switching was called LIM (for Lotus, Intel, Microsoft). It allowed switching the physical memory mapped to each of the 4 highest 16KB blocks of memory in the address space, which was referred to as the Upper Memory Area (UMA).
A later specification eXtended Memory Specification (XMS) allowed extended physical memory to be mapped anywhere into the available address space.
Game consoles of the time used similar techniques.