Giter VIP home page Giter VIP logo

Comments (3)

dongho-jung avatar dongho-jung commented on July 30, 2024 3

In this example, assume we wish to access virtual address 15KB,which
should map to physical address 27KB. Our virtual address, in binary
form, thus looks like this: 11 1100 0000 0000 (hex 0x3C00). The hardware
uses the top two bits (11) to designate the segment, but then we are
left with an offset of 3KB. To obtain the correct negative offset, we must
subtract the maximum segment size from 3KB: in this example, a segment can be 4KB, and thus the correct negative offset is 3KB minus 4KB
which equals -1KB. We simply add the negative offset (-1KB) to the base
(28KB) to arrive at the correct physical address: 27KB. The bounds check
can be calculated by ensuring the absolute value of the negative offset is
less than the segment’s size.

Hello, there! I tried to find the right contact point to report any bugs, typos, and suggestions, and decided to report it to GitHub and email. First trial is always good enough no matter what it is.

What do you think the above possible maximum segment size as 4KB? Shouldn't it be 2KB? I saw the limit as 2KB from 28KB to 26KB for stack in physical memory. If 4KB is still true, I wonder how the segment size was calculated in this example.

dang I got it... we have 14 bits for addressing right cuz 16K-1 is 11 1111 1111 1111 and the stack segment uses
two leftmost bits 11 as a segment identifier. so in VA we can reference address for the stack
from 11 0000 0000 0000 to 11 1111 1111 1111. how much size between them is? Unsurprisingly, it is 4KB (+1 is needed as we starts the index from zero).

Apart from that the stack segment size is 2KB, in VA we can have the maximum offset as 4KB for the stack wow.
and now it's clear that the negative offset should be 3KB - 4KB.

so due to the size of stack segment is 2K, we can reference address for the stack 14KB ~ 16KB even though
11 0000 0000 0000 is 12KB.

But, It would've been nice if only they mentioned this not just that a segment can be 4KB.
the segment size is really confusing with the maximum segment offset.

from ostep-code.

dongho-jung avatar dongho-jung commented on July 30, 2024

I don't understand this example too. I do understand that when I access 15KB in virtual address, according to segment registers, it would be offset 3KB (15KB -> 11 1100 0000 0000, two leftmost bits are used to identify which segment, remain bits as the offset which is 3KB) from the base of the stack segment.

However, why do I have to subtract 4KB from it? where the number came from?

from ostep-code.

Joeycho avatar Joeycho commented on July 30, 2024

@0xF4D3C0D3 Indeed, it seems reasonable! Thanks for figuring out!

from ostep-code.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.