The MASM Forum Archive 2004 to 2012

General Forums => The Workshop => Topic started by: netmadman54 on June 08, 2005, 03:37:13 AM

Title: Trouble compiling Quake1 source *.s files
Post by: netmadman54 on June 08, 2005, 03:37:13 AM
I'm trying to compile the freely distributed Quake1 source code from John Carmack (copyright ID Software) using Microsoft Visual C++ 6.0. The readme said MASM is also required. I don't have MASM, but I downloaded a free MASM lookalike which seems to be doing something, however: the source code contains all of it's assembly code in *.s format files, but the compiler keeps saying "Bad Command or File Name" whenever one of these *.s files comes up on the run list. Then it looks for the *.asm of the same name but can't find it because it isn't there. It appears to me that the only thing not working is a conversion from *.s to *.asm format. Anybody out there manage to do this yet? Is there something I'm missing or not knowing? Does the real MASM do this any better? The readme also says I could change a #define to allow the VC++ compiler to do the assembly but it slows the code down a lot. I haven't tried that option yet, and it seems like VC++ would also want to find *.asm files, not *.s files. How can I convert all these millions of *.s files to *.asm's? that might do it.

====
FYI
Just found out that by first compiling GAS2MASM in DEBUG form, it works nicely with the compiler and the whole thing compiles with only two minor warnings. But when I run it, it tells me it can't find gfx.wad. Guess I need to go either buy the released or download the demo version of Quake1 to get that wad file. Thanks for your help, guys!
Title: Re: Trouble compiling Quake1 source *.s files
Post by: hutch-- on June 08, 2005, 06:19:51 AM
If its MASM code you should use MASM which DOES handle files without the ASM extension. If they are 32 bit files which is what I would expect for a late version of QUAKE, you use the command line for EACH file of,


ml /c /coff asmfile.s


If you need to rename the files, why do it the hard way ?


ren *.s *.asm
Title: Re: Trouble compiling Quake1 source *.s files
Post by: Jeff on June 08, 2005, 07:11:18 AM
yeah, i was looking at the code about a year ago (before i learned asm while studying abstract data types) but heres a question:
now im not completely knowledgable when it comes to MASM's capabilities but does masm support C/C++ preprocessor directives?  when i look at the code, it reminds me of inline assembler seeing the preprocessor directives (along with C/C++ style comments).  for example:

math.s
#define GLQUAKE 1 // don't include unneeded defs
#include "asm_i386.h"
#include "quakeasm.h"


#if id386

.data

.align 4
Ljmptab: .long Lcase0, Lcase1, Lcase2, Lcase3
.long Lcase4, Lcase5, Lcase6, Lcase7

.text

// TODO: rounding needed?
// stack parameter offset
#define val 4

.globl C(Invert24To16)
C(Invert24To16):

movl val(%esp),%ecx
movl $0x100,%edx // 0x10000000000 as dividend
cmpl %edx,%ecx
jle LOutOfRange

then other than that, the syntax with the instruction mnemonics and registers look alien to me.  is this really standard MASM code or some heavily modified version.  i notice that they include "gas2masm" to the package but all that seems to do is to write instructions using "gas" syntax and it converts it to the MASM syntax.  is that the case?
Title: Re: Trouble compiling Quake1 source *.s files
Post by: roticv on June 08, 2005, 11:59:42 AM
The code you pasted is GAS code (yucks).

I don't know, you would have to try it.
Title: Re: Trouble compiling Quake1 source *.s files
Post by: Tedd on June 08, 2005, 12:10:02 PM
I think you'll have multiple problems trying to compile it with anything other than the gnu compilers.
C/C++ are 'supposed' to be portable, but in practice it's not so straightforward.
Title: Re: Trouble compiling Quake1 source *.s files
Post by: MichaelW on June 08, 2005, 05:28:54 PM
GAS? Interesting. The Q2 source included what appear to be MASM modules.

.386P
.model FLAT
;
; d_scana.s
; x86 assembly-language turbulent texture mapping code
;

include qasm.inc
include d_if.inc

if id386

_DATA SEGMENT

_DATA ENDS
_TEXT SEGMENT

;----------------------------------------------------------------------
; turbulent texture mapping code
;----------------------------------------------------------------------

align 4
public _D_DrawTurbulent8Span
_D_DrawTurbulent8Span:
push ebp ; preserve caller's stack frame pointer
push esi ; preserve register variables
push edi
push ebx

mov esi,ds:dword ptr[_r_turb_s]
mov ecx,ds:dword ptr[_r_turb_t]
mov edi,ds:dword ptr[_r_turb_pdest]
mov ebx,ds:dword ptr[_r_turb_spancount]

Llp:
mov eax,ecx
mov edx,esi
sar eax,16
mov ebp,ds:dword ptr[_r_turb_turb]
sar edx,16
and eax,offset CYCLE-1
and edx,offset CYCLE-1
mov eax,ds:dword ptr[ebp+eax*4]
mov edx,ds:dword ptr[ebp+edx*4]
add eax,esi
sar eax,16
add edx,ecx
sar edx,16
and eax,offset TURB_TEX_SIZE-1
and edx,offset TURB_TEX_SIZE-1
shl edx,6
mov ebp,ds:dword ptr[_r_turb_pbase]
add edx,eax
inc edi
add esi,ds:dword ptr[_r_turb_sstep]
add ecx,ds:dword ptr[_r_turb_tstep]
mov dl,ds:byte ptr[ebp+edx*1]
dec ebx
mov ds:byte ptr[-1+edi],dl
jnz Llp

mov ds:dword ptr[_r_turb_pdest],edi

pop ebx ; restore register variables
pop edi
pop esi
pop ebp ; restore caller's stack frame pointer
ret


_TEXT ENDS
endif ;id386
END

Title: Re: Trouble compiling Quake1 source *.s files
Post by: Jeff on June 08, 2005, 05:48:58 PM
funny you should mention that, Q2 source has a mix of both MASM code and what appears to be GAS code.
Title: Re: Trouble compiling Quake1 source *.s files
Post by: netmadman54 on June 08, 2005, 11:23:09 PM
Quote from: hutch-- on June 08, 2005, 06:19:51 AM
If its MASM code you should use MASM which DOES handle files without the ASM extension. If they are 32 bit files which is what I would expect for a late version of QUAKE, you use the command line for EACH file of,


ml /c /coff asmfile.s


If you need to rename the files, why do it the hard way ?


ren *.s *.asm


Hutch, thanx for re:,  I tried renaming. Doesn't work. But maybe the command line for ml will work. If I can translate each file oneatatime  that's better. I'll try it. See what happends. I have ml.exe in another masm thing I downloaded.
Title: Re: Trouble compiling Quake1 source *.s files
Post by: Mark Jones on June 09, 2005, 01:27:00 AM
What version of ml.exe?
Title: Re: Trouble compiling Quake1 source *.s files
Post by: Phil on June 09, 2005, 01:35:17 AM
Best to look at each source file and make sure it's MASM syntax before you rename it to *.s ... The DJGPP at http://www.delorie.com/djgpp/ can be used to create object files which can then be linked with the object files produced by ML. Best to dig deep into your readme and installation files to see what the story behind the story is. Sounds like you've really got your work cut out for you with a very steep learning curve otherwise!