www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/02/03/21:36:10

Xref: news2.mv.net comp.os.msdos.djgpp:762
From: dave AT davemac DOT demon DOT co DOT uk (Dave McNeill)
Newsgroups: comp.os.msdos.djgpp
Subject: masm's coff output
Date: Sat, 03 Feb 1996 16:14:44 GMT
Lines: 95
Message-ID: <311381ff.355150@news>
Reply-To: dave AT davemac DOT demon DOT co DOT uk
NNTP-Posting-Host: davemac.demon.co.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

according to faq 17.2:

           * Obtain a copy of Microsoft MASM 6.11. It has ``-coff'' option
             to generate object code in COFF format which can be submitted
             to gcc, [etc, etc].

i've been playing with this some and i've had a degree of success.  i can
link masm and gcc generated coffs.  i can even share static data between the
two.  when it comes to calling routines in libc from my masm code, however, 
things start to get fubar.

here's a trivial piece of code to fill the mode 03h screen.
first the source, then the disassembled coff.

----------------------------------------------------------
..386
..model flat

..code

__go32_conventional_mem_selector proto
_fill_screen proto

_fill_screen proc

        call __go32_conventional_mem_selector
        mov es,ax
        mov edi,0B8000h
        mov ecx,80*25
        mov eax,0730h
        rep stosw
        ret

_fill_screen endp

end
----------------------------------------------------------
_fill_screen():
00001528: e8db080000     call    __go32_conventional_mem_selector+5
0000152d: 668ec0         mov     es,ax
00001530: bf00800b00     mov     edi,0xb8000
00001535: b9d0070000     mov     ecx,0x7d0
0000153a: b830070000     mov     eax,0x730
0000153f: f366ab         rep(e)  stosw   es:[edi],ax
00001542: c3             ret
----------------------------------------------------------

as you'd expect, this crashes.

when compling with as, on the other hand i get the following:

----------------------------------------------------------
..text

..globl _fill_screen

_fill_screen:
        call __go32_conventional_mem_selector
        movw %ax,%es
        movl $0xB8000,%edi
        movl $80*25,%ecx
        movl $0x0730,%eax
        rep
        stosw
        ret
----------------------------------------------------------
_fill_screen()
00001528: e8d6080000     call    __go32_conventional_mem_selector
0000152d: 668ec0         mov     es,ax
00001530: bf00800b00     mov     edi,0xb8000
00001535: b9d0070000     mov     ecx,0x7d0
0000153a: b830070000     mov     eax,0x730
0000153f: f366ab         rep(e)  stosw   es:[edi],ax
00001542: c3             ret
----------------------------------------------------------

which works like a charm.

i guess the problem occurs during the link stage.  if it's down
to some incompatibility between as's coff format and the win32
coff format, maybe the faq list should be updated to reflect
this (i'm sure this is not the case, since it's supposed to be
a _common_ object file format!).  if it's me missing something
completely (most likely :), can anyone tell me what i'm doing wrong?

btw, i'm using masm 6.1 and gcc/as/ld from djgpp v2beta4.

ta

-- 
dave mcneill

'donuts!  is there anything they can't do?' - homer j. simpson

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019