_my_ds() & co. not usable

DOS specific questions.
Post Reply
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

_my_ds() & co. not usable

Post by mjs »

Hi,

the _my_ds(), _my_cs(), and _my_ss() functions aren't usable.

This is the disassemble:

Code: Select all

Dump of assembler code for function _MY_DS:
0x00017bd0 <_MY_DS+0>:  push   %ebp
0x00017bd1 <_MY_DS+1>:  mov    %esp,%ebp
0x00017bd3 <_MY_DS+3>:  sub    $0x4,%esp
0x00017bd6 <_MY_DS+6>:  push   %ebx
0x00017bd7 <_MY_DS+7>:  push   %esi
0x00017bd8 <_MY_DS+8>:  push   %edi
0x00017bd9 <_MY_DS+9>:  movl   $0x0,0xfffffffc(%ebp)
0x00017be0 <_MY_DS+16>: movl   %ds,0x17ba0
0x00017be6 <_MY_DS+22>: mov    0xfffffffc(%ebp),%eax
0x00017be9 <_MY_DS+25>: pop    %edi
0x00017bea <_MY_DS+26>: pop    %esi
0x00017beb <_MY_DS+27>: pop    %ebx
0x00017bec <_MY_DS+28>: mov    %ebp,%esp
0x00017bee <_MY_DS+30>: pop    %ebp
0x00017bef <_MY_DS+31>: ret    $0x0
End of assembler dump.
As you can see, the "push %ebp" will be overwritten with whatever value "%ds" has. The problem is that in the header file dos/sys/segments.bi s/o used:

Code: Select all

private function _my_ds ( ) as integer
	asm
		mov [_MY_CS], ds
	end asm
end function
I fixed this [_MY_CS] to [ebp-4]. This fixes the problem but it doesn't "look good". Any idea how to reference this hidden local variable by name?

Regards,
Mark
DrV
Site Admin
Posts: 2116
Joined: May 27, 2005 18:39
Location: Midwestern USA
Contact:

Post by DrV »

Oops, my mistake, forgot that the function name becomes the address of the function, not the return value.

Use "mov [FUNCTION], ds"
mjs
Site Admin
Posts: 842
Joined: Jun 16, 2005 19:50
Location: Germany

Post by mjs »

Fixed.
Post Reply