delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1996/09/19/01:39:01

From: alaric AT abwillms DOT demon DOT co DOT uk (Alaric B. Williams)
Newsgroups: comp.os.msdos.djgpp
Subject: Re: New to DJASM/AS: Doesn't Compile!
Date: Wed, 18 Sep 1996 20:06:20 GMT
Lines: 99
Message-ID: <843077140.28180.0@abwillms.demon.co.uk>
References: <51gjn9$j96 AT sjx-ixn2 DOT ix DOT netcom DOT com>
NNTP-Posting-Host: abwillms.demon.co.uk
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

takahiro AT ix DOT netcom DOT com(Takahiro Horie) wrote:

>Thanks for taking a look at my problem!
>When I compile this source, I get massive amounts of errors.
>I am using the command: 
>             
>                    as djhello.asm

>-[source]--------------------------------------------------------------

>    .model small
>    .stack
>    .code

>    start:
>    JMP begin
>    MyMessage db "Compiled with D.J. Delorie ASM.$"

>    begin:
>    MOVw OFFSET MyMessage, %dx
>    MOVw SEG MyMessage, %ax
>    MOVw %ax,%ds
>    MOVb $9,%ah
>    int 21h

>    MOVw $4c00h,%ax
>    int 21h
>    END start;

>-----------------------------------------------------------------------

Ah; nice to see you've sort of used AT&T syntax, so I can't blame you
for lack of effort, but you've come adrift on something that nobody
complains about much on the group.

AS uses very different pseudo-ops.

For a start, you can't directly use INT 21 and all that - all memory
addressing is different, things like SEG and OFFSET have little
meaning, and the values INT 21h expects have little meaning in
protected mode anyway.

There is no such thing as a model, either.

The best way of implementing that code is:

#include <stdio.h>
int main() {puts("Compiled with D.J. Delorie ASM.");}

Because the C runtime library takes care of all the problems of
communicating with DOS INT 21h!

Basically, use assembly only for fast stuff, unless you want to get
deep into DPMI and transfer buffers.

>I'm sorry about such a long message, but I wanted to get the best
>response to my query as possible.

It worked, it's very clear what went wrong. The response would have
been very different if you gave a one line posting of "There's a bug
in AS".

DJASM, by the way, is rarely used; it's for writing the stub and
little else. Ignore it unless you want to write a funny stub.

> I also understand this is very simple
>code, but as an intermediate programmer it puzzles me well. 

More information on the AS pseudo-ops can be found in Info, under
"AS". There's a menu option for pseudo-ops, go read it - and be proud
in the knowledge that those pseudo-ops are compatible with UNIX
machines worldwide!

They're much simpler than TASM ones. If you miss macros and all that,
look up GASP, the AS preprocessor. You can use the C preprocessor as
well (ie, #include and #define etc!)

>Thank you VERY much in advance,

<glow> :-)

>Takahiro Horie (takahiro AT ix DOT netcom DOT com)

Regards,


ABW


---

COMPUTER: We are in position over the Rebel homeworld.
VADAR: Engage the Death Star primary weapon, let those rebel worms die!
COMPUTER: Sorry, your evaluation version of Battle Computer 3.0 has expired. 
          Please send 2.6 billion dollars to the address in REGISTER.TXT

Alaric B. Williams Internet : alaric AT abwillms DOT demon DOT co DOT uk
<A HREF="http://www.abwillms.demon.co.uk/">Hello :-)</A>

- Raw text -


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