News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

Segment Arithmetic problem!!!!

Started by EnFeR RoI, January 19, 2010, 03:51:39 PM

Previous topic - Next topic

MichaelW

#15
QuoteMy question is that how the address is shifted?

Either I don't understand your question, or you are asking for information that I doubt anyone here can provide. If you want to know exactly how the processor works internally, you would need to ask the designers. Programmers work with a programming model of the processor, and since this particular feature is not directly programmable there is no reason to include the details of it in the model. Basically, the programming model provides only the information that the programmer needs, and in this case that is the end result of the address translation. This description is from a recent version of the Intel IA-32 Software Developer's Manual, Volume 3 System Programming Guide, under 16.1.1 Address Translation in Real-Address Mode:
Quote
In real-address mode, the processor does not interpret segment selectors as indexes into a descriptor table; instead, it uses them directly to form linear addresses as the 8086 processor does. It shifts the segment selector left by 4 bits to form a 20-bit base address (see Figure 16-1). The offset into a segment is added to the base address to create a linear address that maps directly to the physical address space.

And Figure 16-1 shows the operations as if they were being done in 20-bit registers. So here is a diagram of your segment address of 5 and an offset address of 17, both copied to 20-bit registers and processed from there:

Take your 16-bit segment address:
0000 0000 0000 0101
Copy it to a 20-bit register:
0000 0000 0000 0000 0101
Shift it left by 4 bits:
0000 0000 0000 0101 0000
Take a 16-bit offset address (of 17):
0000 0000 0001 0001
Copy it to a 20-bit register:
0000 0000 0000 0001 0001
And add the two together:
0000 0000 0000 0101 0000
0000 0000 0000 0001 0001
------------------------
0000 0000 0000 0110 0001


And here is a map of what the memory would look like, starting at segment address 0 offset address 0, and extending to segment address 6 offset address 0Fh, with the segment addresses in the leftmost column and all the values in hex, and with the value FFh shored in the addressed byte:

0000 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00
0001 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00
0002 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00
0003 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00
0004 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00
0005 00 00 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00
0006 00 FF 00 00 00 00 00 00 - 00 00 00 00 00 00 00 00

eschew obfuscation

EnFeR RoI

finally i got the answer as explained by you MichaelW Sir.... :U

Thanks for cooperating me!!
EnFeR RoI.

Magicle

C, in this case, stands for a 12.

6Ch = 6 12 = 0110 (6) 1100 (12) = 0110 1100 (binary) = 2^2+ 2^3 + 2^5 + 2^6 = 108 in decimal.

I hope this clarifies a bit. If not, I will try and make it more clear.