I'm building an x86 app and I'd like to create and use my own memory segments. I've done a good bit of this with the SEGMENT keyword, but even though I (think) I've defined the segment, I'm not able to get the data out of it. =\ I'm hoping someone can tell me how to do this.
So, if I do this (note that the data is arbitrary just for example)
.FARDATA
SEGMENT MyData
someData DB 0
DB 1
DB ... LOTS MORE DATA
DB 9999 ; LAST ONE
otherData DB 9999
DB 9998
DB 9997 ETC LOTS MORE...
...
DB 1
ENDS
How do I access someData or otherData? I figured this would do it...
PUSH SEGMENT MyData ; move the segment address into ES
POP ES
MOV SI, OFFSET someData; now where in that segment address?
MOV AX, [ES:SI] ; move first byte into AX...
but this doesn't work. And I tried MOVing 0 *and* OFFSET MyData into SI, and I got the *exact* same result every time...the result being that I seem to start looking at my data midway in.
Does *anybody* remember this stuff?
I've been scouring the web with google and I've yet to find any documentation that really clarifies how this works.