WinAsm Studio, The Assembly IDE - Free Downloads, Source Code
Sponsors
Articles
Programming Quick Start
32-bit Assembler is Easy
Porting Iczelion tutorials
What is FASM
Hard Drive Recovery
Wiring your own LAN
Personal menu
Welcome Guest
User:
Pass:
Register!
Resend Validation Email
 
Forum
Pages (5) [1] 2 3 4 5   ( Go to first unread post )

Segment Arithmatic, Need help on explaining shifting of 16 bit segment address.........

vulPeCula
Quote Post


Extremely Active Member
******

Group: Members
Posts: 190
Member No.: 16362
Joined: 16-December 08


Segment Arithmetic Problem:->

Here is how the
processor combines a 16-bit segment and a 16-bit offset to form a 20-bit linear
address. In effect, the segment selects a 64K region of memory, and the offset
selects the byte within that region. Here’s how it works:

1. The processor shifts the segment address to the left by four binary places,
producing a 20-bit address ending in four zeros. This operation has the effect
of multiplying the segment address by 16.

The processor shifts the segment address to left by four binary places,producing a 20-bit address ending in four zeros.

My question is that how a 16 bit address is converted to a 20 bit address and thus shifting results to (1) or (2)??

I have taken an example, that suppose our segment address is 5 in 16 bit binary it is 0000000000000101,and when we shift it four places
to left (5<<4),it becomes (1)00000000000001010000 this or (2)0000000001010000 this??.

According to my shifting (2) result will be there but if I am wrong then please
correct me.
I have shifted like this :->
1:-> 0000000000001010
2:-> 0000000000010100
3:-> 0000000000101000
4:-> 0000000001010000

Now I am not getting that how this becomes a 20 bit address??
Does the processor itself adds additional 4 bits to the address,in my case like this 00000000000001010000,before shifting the address??


Regards,
vulPeCula.
PMEmail PosterMSN
Top
EnFeR RoI
Quote Post


Member
**

Group: Members
Posts: 20
Member No.: 30972
Joined: 15-January 10


The segment address selects a region that can be up to 64KB. To create a 20-bit absolute address the processor effectively shifts the 16-bit segment address left by 4 bits, stores it in a 20-bit result, and then adds in the 16-bit offset address. To use a real example, the BIOS data area is stored at segment address 40h, and within that area the number of timer ticks since midnight is stored at offset 6Ch.
Code:
0000 0000 0100 0000 = 40h
0000 0000 0110 1100 = 6Ch

0000 0000 0100 0000 0000 = 400h
0000 0000 0000 0110 1100 = 6Ch
-------------------------------
0000 0000 0100 0110 1100 = 46Ch

Hope it help you!!!

Thanks in advance.
EnFeR RoI. cheers.gif
PMEmail Poster
Top
vulPeCula
Quote Post


Extremely Active Member
******

Group: Members
Posts: 190
Member No.: 16362
Joined: 16-December 08


QUOTE
To create a 20-bit absolute address the processor effectively shifts the 16-bit segment address left by 4 bits, stores it in a 20-bit result


My question is that how the address is shifted??,as I have given the example in my post (the example of address 5).
Does the processor is predefined to add additional four bits like this:->00000000000001010000 (at the end of the 16 bit number after shifting it to four places left)?

Or simple shifts the number like this:->0000000001010000 (and then puts additional four zeros in the beginning to make it a 20 bit number like this 00000000000001010000 ).

tongue.gif biggrin.gif

Regards,
vulPeCula.
PMEmail PosterMSN
Top
EnFeR RoI
Quote Post


Member
**

Group: Members
Posts: 20
Member No.: 30972
Joined: 15-January 10


put 4 zero bits at the end (low order end) of the segment value
put 4 zero bits ar the beginning (high order end) of the offset value
then, add the two values together

16-bit code can address 1 Mb of address space - this requires 20 bits
at any given time however, you can only address 64 Kb of address space with 16-bit values
the segment value defines the base of the 64 Kb segment as a "window" into the 1 Mb of memory

a good example of this is the video buffer
for most text modes, the buffer is at B8000h (20 bits) in the 1 Mb address space
a good way to access the video buffer is to put a segment value of B800h (16 bits) into the ES register
then, an address of ES:0000 is the base of the video buffer

Thanks in advance.
EnFeR RoI. cheers.gif
PMEmail Poster
Top
vulPeCula
Quote Post


Extremely Active Member
******

Group: Members
Posts: 190
Member No.: 16362
Joined: 16-December 08


I am not getting what are you trying to say,does it put it in the beginning or just in the end.?? huh.gif

Its hard to understand when you are saying:->
QUOTE
put 4 zero bits at the end (low order end) of the segment value
put 4 zero bits ar the beginning (high order end) of the offset value
then, add the two values together
unsure.gif

Moreover I think that offset value is not even changed while all the segment addressing process(under 16 bit real mode).

Regards,
vulPeCula.
PMEmail PosterMSN
Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

Topic Options Pages (5) [1] 2 3 4 5  Reply to this topicStart new topicStart Poll

 

Sponsors
Computer Science

Internet
C/C++
Hardware & PC maintenance

HiEditor

General Discussions
Suggestions/Bug Reports
WinAsm Studio

General Discussions
Suggestions/Bug Reports
WinAsm Studio FAQ
Multilingual User Interface
Add-Ins
Assembly Programming

Main
Newbies
Projects
Custom Controls
Snippets
Announcements & Rules

Announcements

General

Online Degrees - Distance Learning
The Heap
Russian
Google