I am doing Linux assembly and I understand that is has a flat memory model. What I am confused about is NEAR and FAR JMPs.
NEAR is in the same segment while FAR is anot
NEAR is in the same segment while FAR is another segment.
A near jump jumps to a location within the current code segment (pointed to by cs
). A far jump is normally used to jump to a location within a different code segment, but it can jump to a location within the current segment as well, if the segment selector in the far address coincides with the value in cs
.
From what I understand there are no segments in linux virtual memory?
I wouldn't be surprised to find Linux ports to CPUs using some kind of segmented memory. So, I'd say it depends. You're unlikely to see Linux use segments on the x86 platform, though. But again, you or someone else could make a small Linux running in real mode and using segments.
Also how do we know if my program's code is laid out in multiple segments?
You check the CPU and OS. Naturally, if you write portable C code, this should be of no concern to you.