is there a way to get segment value in C code? #1147
Replies: 1 comment 1 reply
-
If you search equivalent of Turbo C predefined segments then it is in OW described here
it is not pointers it is segment names that you need translate to segment value.
Next you need to combine segment value with offset to pointer. Example for pointer to "MySEG" segment by both methods (including initialization).
If you have variable which hold the segment value then the construct should looks like
But if you need to define variables to be in some segment outside default _DATA segment then you can use construct like.
It add variable "thing" into segment "MySEG". Take into account that only default "_DATA" data segment is near and all your other data segments are far therefore you need to use far pointers to access variables in these segments ( based pointers or true far pointers ). there are other possibility to manipulate with default segment names, see compiler -n.. options in OW documentation There are also appropriate #pragma variants which can be used selectively (see OW documentation). |
Beta Was this translation helpful? Give feedback.
-
i try to replace a reverse engineered data-segment (old DOS game exe) with a 100% equal C equivalent
and i've got variables that contain segment,offset values like in this simple example
are there some extensions, macros in Watcom C available to get the same values in C variables - when im combining assembler obj and C obj files?
im aware of __segname and __segment, __based and that stuff but i don't know how to combine them to get the result
Turbo C got something like that (http://bitsavers.informatik.uni-stuttgart.de/pdf/borland/turbo_c/Turbo_C_Users_Guide_1987.pdf page 249)
so something like
char segmentof("my_code_seg0") *test_seg1;
Beta Was this translation helpful? Give feedback.
All reactions