Re: Помогите новичку
Posted: Mon Jan 09, 2012 8:08 pm
Для MSVC #pragma pack(push, 1) перед объявлением структур и #pragma pack(pop) после или /Zp
Code: Select all
extern bool bIsEmuTOS;
extern Uint16 TosVersion;
extern Uint32 TosAddress, TosSize;
extern bool bTosImageLoaded;
extern bool bRamTosImage;
extern unsigned int ConnectedDriveMask;
extern int nNumDrives;
extern void TOS_MemorySnapShot_Capture(bool bSave);
extern void TOS_AutoStart(const char *prgname);
extern FILE *TOS_AutoStartOpen(const char *filename);
extern bool TOS_AutoStartClose(FILE *fp);
extern int TOS_LoadImage(void);
Code: Select all
bool bIsEmuTOS;
Uint16 TosVersion; /* eg. 0x0100, 0x0102 */
Uint32 TosAddress, TosSize; /* Address in ST memory and size of TOS image */
bool bTosImageLoaded = false; /* Successfully loaded a TOS image? */
bool bRamTosImage; /* true if we loaded a RAM TOS image */
unsigned int ConnectedDriveMask = 0x03; /* Bit mask of connected drives, eg 0x7 is A,B,C */
int nNumDrives = 2; /* Number of drives, default is 2 for A: and B: - Strictly, this is the highest mapped drive letter, in-between drives may not be allocated */
Code: Select all
int TOS_LoadImage(void)
{
__menuet__debug_out ("in loadimg\n");
Uint8 *pTosFile = NULL;
long nFileSize;
__menuet__debug_out ("in loadimg2\n");
bTosImageLoaded = false;
__menuet__debug_out ("in loadimg3\n");
/* Load TOS image into memory so that we can check its version */
TosVersion = 0;
__menuet__debug_out ("in loadimg4\n");
И сразу сегфолт. Чем такое может быть вызвано? Почему тот же код работает в Linux?in loadimg
in loadimg2
in loadimg3
Code: Select all
.LC1:
.string "in loadimg\n"
.LC2:
.string "in loadimg2\n"
.LC3:
.string "in loadimg3\n"
.LC4:
.string "in loadimg4\n"
.globl TOS_LoadImage
.type TOS_LoadImage, @function
TOS_LoadImage:
pushl %ebp
movl %esp, %ebp
pushl %edi
pushl %esi
pushl %ebx
subl $56, %esp
pushl $.LC1
call __menuet__debug_out
movl $.LC2, (%esp)
call __menuet__debug_out
movl $.LC3, (%esp)
movl $0, bTosImageLoaded
call __menuet__debug_out
movl $.LC4, (%esp)
movw $0, TosVersion
call __menuet__debug_out
....
.globl bTosImageLoaded
.bss
.align 4
.type bTosImageLoaded, @object
.size bTosImageLoaded, 4
bTosImageLoaded:
.zero 4
Code: Select all
bRamTosImage = false;
Code: Select all
mov word, [13676B4h], 0
Code: Select all
COMMON 0x00000000013676b4 0x14 tos.o
0x00000000013676b4 TosVersion
0x00000000013676b8 TosSize
0x00000000013676bc bIsEmuTOS
0x00000000013676c0 TosAddress
0x00000000013676c4 bRamTosImageCode: Select all
.bss 0x0000000000296228 0x24 tos.o
0x0000000000296228 bTosImageLoadedCode: Select all
__menuet__debug_out("scrinit\n");
__menuet__debug_out("yeah\n");
Screen_Init();
__menuet__debug_out("ttl\n");
Code: Select all
movl $.LC20, (%esp)
call __menuet__debug_out
movl $.LC21, (%esp)
call __menuet__debug_out
call Screen_Init
movl $.LC22, (%esp)
call __menuet__debug_out
Code: Select all
void Screen_Init(void)
{
__menuet__debug_out("lool\n");
__menuet__debug_out("yeah\n");
int i;
Code: Select all
.globl Screen_Init
.type Screen_Init, @function
Screen_Init:
pushl %ebp
movl %esp, %ebp
pushl %ebx
subl $288, %esp
pushl $.LC10
call __menuet__debug_out
movl $.LC11, (%esp)
call __menuet__debug_out
и крэш, который даже отладчик не может пойматьscrinit
И так же крэш. Где мой лоол?scrinit
yeah
yeah