I was reading the Intel Vol. 1 Basic Architecture and it said that most programs use the flat model, but you can also use the segmented model for reliability.
I don't think I have seen any assembly code using the segmented model.
I couldn't find any snippets.
Thanks,
Andy
I don't think I have seen any assembly code using the segmented model.
I couldn't find any snippets.
Thanks,
Andy
iirc from my comp.architecture classes, you simply use the segment registers, to allow for access to more virtual memory, but incoherency in designs limits the practical use. It's not used in neither windows nor linux. Reliability... I don't understand what they mean with it.
Intel says that placing a program's stack in a separate segment prevents the stack from growing into the code or data segment and overwriting instructions or data.
Proper coding and checking would probably do the same thing.
Proper coding and checking would probably do the same thing.
Intel says that placing a program's stack in a separate segment prevents the stack from growing into the code or data segment and overwriting instructions or data.
The same can, mostly, be prevented by keeping stack and code/data far apart, having 'guard pages' where the stack grows naturally, and a range of non-present pages to trap an over/underflow... and avoid the management overhead of segments.
Intel says that placing a program's stack in a separate segment prevents the stack from growing into the code or data segment and overwriting instructions or data.
The same can, mostly, be prevented by keeping stack and code/data far apart, having 'guard pages' where the stack grows naturally, and a range of non-present pages to trap an over/underflow... and avoid the management overhead of segments.
Do you have an example of some code showing that ?
Thanks.
You're pretty much in the realm of systems-level coding with your questions, so it's hard to come up with a little snippet that'll work under windows ;)
skywalker:
Unless you are dealing with 16-bit code; or perhaps you are developing your own OS (or anything else along those lines) there is no need to play around with segmented architecture. However, here is a very small snippet how to change to a different segment (defined by your code) within the 16-bit world
not sure if that is what you are looking for but I hope it helps.
BTW: One handy item to have while you dig through those books is the MASM manual, which you can obtain (in electronic format) either by doing a quick google search or you can PM with your email address and I can send it to you along with some real world examples (I don't have access to my dev system right now so I can not do it for a few days).
Have a great week
Unless you are dealing with 16-bit code; or perhaps you are developing your own OS (or anything else along those lines) there is no need to play around with segmented architecture. However, here is a very small snippet how to change to a different segment (defined by your code) within the 16-bit world
DSEG segment
Var1 DW ?
Var2 DB ?
DSEG ends
...
mov ax, dseg ;Loads ax with segment address of dseg
mov es, ax ;set es register to point to our defined data segment
xor ax, ax
mov es:Var1, ax ; Set Var1 to the value of 0
not sure if that is what you are looking for but I hope it helps.
BTW: One handy item to have while you dig through those books is the MASM manual, which you can obtain (in electronic format) either by doing a quick google search or you can PM with your email address and I can send it to you along with some real world examples (I don't have access to my dev system right now so I can not do it for a few days).
Have a great week
madprgmr: edited your post and added code tags, hope you won't mind :)
Thanks gentlemen for the help.
skywalker:
Your welcome.
f0dder:
I don't mind at all, in-fact I appreciate the correction!
Your welcome.
f0dder:
I don't mind at all, in-fact I appreciate the correction!