TIP: Click on subject to list as thread! ANSI
echo: os2prog
to: Russ Parks
from: Mike Bilow
date: 1996-01-28 18:19:16
subject: CSet++ and Asm

Russ Parks wrote in a message to Mike Bilow:

 RP>         TempCw  DW  0        ;Temp storage for use with the
 RP>         OldCw   DW  0        ;80x87 control word
 RP> DATA32  ENDS
 RP>         ASSUME CS:CODE32, DS:DATA32
 RP> CODE32  SEGMENT

 MB> Move the ASSUME to here, after SEGMENT.

 RP>  I just tried it. Same exception is raised.

What are you seeing in the debugger?  What is the real offset of
"OldCW" within the (flat) data segment?  What is the debugger
trying to access?  One simple trick is to initialize the memory with
something other than 0, such as 0xaa55aa55, in order to make it easy to
find in real memory.  What does the linker map file show?

 MB> You are being blown away by the linker, which is causing the
 MB> segment grouping to compute funny addresses.

 RP>  I have to agree with you there...though all my asm on PC's
 RP> has been under DOS -- until now 

 MB> Since you are linking with C generated code, the linker has to
 MB> realize that the offset within your local segment (DATA32) is
 MB> different from that with the group of all segments sharing the
 MB> combine class ('DATA').  This is why you need GROUP and ASSUME
 MB> directives, since you cannot accept the assembler default.

 RP>   I've gotten around the problem for now, by using
 RP> ENTER/LEAVE with offsets from EBP as temp storage... not
 RP> pretty, but it'll work in the interim, or until I get over
 RP> the flu :-)

The only other thing I can think of is that you have broken the linker
combiner in some other module that I can't see.  For example, if you have
another module that declares a segment with "DATA" combine class
using smaller alignment, say DWORD, and then try to declare a segment in
this module with the same combine class but a more restrictive alignment,
say PARA, then whether this works or not will depend upon the coincidental
ordering of the segments as they go into the linker.  Properly, you need to
enforce identically restrictive alignments on all segment declarations, and
the exact restriction is dictated by the compiler.
 
-- Mike


--- 
* Origin: N1BEE BBS +1 401 944 8498 V.34/V.FC/V.32bis/HST16.8 (1:323/107)
SEEN-BY: 50/99 270/101 620/243 711/401 409 410 413 430 808 809 934 955
SEEN-BY: 712/407 515 517 628 713/888 800/1 7877/2809
@PATH: 323/107 170/400 396/1 270/101 712/515 711/808 809 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.