Preface
80,861 Total 20 address lines, addressing the physical address with a 16bit segment address + 4bit offset.
The same physical address can represent a test program with multiple logical addresses (different segment addresses + offsets)
Testcase1.cpp:Defines the entry point for the console application. #include "stdafx.h" #include <stdlib.h> #include <stdio.h> #include <assert.h>//Physical address based on segment and offset long
GET8086PHADDR (/*in*/int isegment,/*in*/int ioffset);
Get the Segment address int get8086segment (/*in*/long lphaddr,/*in*/int ioffset) According to the physical address and offset;
Get offset int Get8086offset (/*in*/long lphaddr,/*in*/int isegment) According to physical address and segment address;
int main (int argc, char* argv[]) {long ltmp = 0;
Long lphaddr = 0;
int isegment = 0;
int ioffset = 0;
-D 123:456 lphaddr = Get8086phaddr (0x123, 0x456);
printf ("0x%X = 123:456\n", lphaddr); -d?
: 186 isegment = Get8086segment (lphaddr, 0x186);
Ltmp = Get8086phaddr (isegment, 0x186);
ASSERT (lphaddr = = ltmp);
printf ("0x%X =%x:186\n", ltmp, isegment);
-D 105:?
Ioffset = Get8086offset (lphaddr, 0x105);
Ltmp = Get8086phaddr (0x105, Ioffset);
ASSERT (lphaddr = = ltmp);
printf ("0x%X = 105:%x\n", ltmp, Ioffset); /* Run result 0x1686 = 123:456 0x1686 = 150:186 0x1686 = 105:636 Press any key to continue ... With debug authentication, the memory results are the same in the following way, indicating that a physical address can be represented by multiple logical addresses------123:456-d 150:186-d 105:636-d 0:1686 */System ("p
Ause ");
return 0;
} long get8086phaddr (/*in*/int isegment,/*in*/int ioffset) {return ((long) isegment << 4) + Ioffset;}
int get8086segment (/*in*/long lphaddr,/*in*/int ioffset) {return ((Lphaddr-ioffset) >> 4);}
int Get8086offset (/*in*/long lphaddr,/*in*/int isegment) {return lphaddr-((Long) isegment << 4);}
Validation