News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

What does := mean?

Started by asymptote, January 11, 2008, 02:03:16 AM

Previous topic - Next topic

asymptote

I'm using the book: Assembly Language Programming for the IBM PC Family, William B. Jones, 1992, 0962423068.  Sometimes it uses the expression ":=".  For example, in Ch 4, page 70, at the bottom it talks about how variable sizes can be changed:

Prefixing a variable with WORD PTR forces it to be interpreted as a word and prefixing with BYTE PTR causes it to be interpreted as a byte.  This is called a type cast or a coercion.  Thus we could write
A    DW    14
B    DB    100
C    DB    'Hello'
      ...

     mov    ax, WORD PTR B;  sets al to 100, ah to 'H' = 72
     mov    al, BYTE PTR A;  sets al := 14


I just keep seeing it throughout the book and I have no idea what it means or if it is a typo or if it is any different than just using an equals sign.  Thanks!

zooba

It is a variable assignment in some other languages, so it probably depends on the background of the author. He may be emphasising that it is an assignment - he has used only an equals sign for "'H' = 72".

Slightly off-topic, it really bugs me when people write assembly language and put the semicolon (comment marker) at the end of every line. It isn't C, quit pretending that it is! :P

Cheers,

Zooba :U

asymptote

Quote from: zooba on January 11, 2008, 03:07:44 AM
It is a variable assignment in some other languages, so it probably depends on the background of the author. He may be emphasising that it is an assignment - he has used only an equals sign for "'H' = 72".

Slightly off-topic, it really bugs me when people write assembly language and put the semicolon (comment marker) at the end of every line. It isn't C, quit pretending that it is! :P

Cheers,

Zooba :U

I am a total newb and I'm just letting you know in the event you weren't clear on this but he doesn't put the semicolon at the end of every line - he included it just for those remarks. 

Also I do appreciate your reply and I think you're right.  Have you used NASM under a Linux distribution?

hutch--

zooba is right, the ":=" is the Pascal assignment operator.

The book you ae working from is very old and is dealing with out of date 16 bit DOS assembler, unless you are specifically writing legacy 16 bit dos applications, you are far beter off studying modern 32 bit software whch will give you a bridge to the coming 64 bit software.
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

ramguru

Just curious how old is masm32 documentation, as if it would be w/o sin  :dance:

  Syntax:   FOR parameter[:REQ|:=default], <argument [,argument]...>
              statements
            ENDM

  Description:

...

     :=default      Optional tag for <parameter> causing <parameter> to
                    be assigned <default> if given a blank argument.

Tedd

Yes, ":=" is the assignment operator (just "=" in many languages) to differentiate it from "=" which is used for comparison in those languages (whereas "==" is used in this case in 'other' languages.)

Quote from: asymptote on January 11, 2008, 03:32:52 AM
I am a total newb and I'm just letting you know in the event you weren't clear on this but he doesn't put the semicolon at the end of every line - he included it just for those remarks. 
In many other languages (namely C, C++, Java, Pascal..) it's necessary to indicate the end of each statement, since statements may span multiple lines, so in that case a semi-colon is required at the end of each statement. This isn't needed in asm because each statement only takes one line (though it is possible to span multiple lines for more complex statements.)
And in asm ';' has a different meaning anyway - to indicate the start of a line-comment, so anything after the semi-colon (up to the end of that line) is ignored.

Quote
Have you used NASM under a Linux distribution?
Yes ..?

Quote from: zooba on January 11, 2008, 03:07:44 AM
Slightly off-topic, it really bugs me when people write assembly language and put the semicolon (comment marker) at the end of every line. It isn't C, quit pretending that it is! :P
People just build up (bad?) habits. If you have the habit of adding ';' to the end of every line (in another language), and it causes no errors in asm.. no problem? (as far as they're concerned.)
No snowflake in an avalanche feels responsible.

asymptote

Quote from: hutch-- on January 11, 2008, 04:31:23 AM
zooba is right, the ":=" is the Pascal assignment operator.

The book you ae working from is very old and is dealing with out of date 16 bit DOS assembler, unless you are specifically writing legacy 16 bit dos applications, you are far beter off studying modern 32 bit software whch will give you a bridge to the coming 64 bit software.

I did get this book a while ago and yes it is old but it's so much more clearer than the one my instructor assigned for us to use.  If you have any suggestions for beginner assembly books, I welcome your advice.  However, I have found several assembly books frustrating because they give all this great information but little or no examples - no explanation of syntax (aka NASM documentation $#*!@).  You could make the argument that this simply motivates a reader to think harder, but I feel a lot of assembly documentation is a brick wall unless you have some examples from time to time to guide you.

This book explains each section of an assembly (.asm) file and although it gets into macros rather early, it provides great practise exercises.  The instructor had us use Assembly Language for Intel-Based Computers, Irvine, 978-0132383103.  I thought that book was absolutely horrible.  I found this one buried in a stack of my books and cracked it open and it turns everything into sense for me now.

Not only that, but the Irvine book used a different syntax than what is used in Masm 6.15 - even more frustration.

GregL

asymptote,

Is your instructor teaching assembly language for 16-bit DOS or 32-bit Windows? If he is teaching 16-bit then 'Assembly Language Programming for the IBM PC Family' would probably fit better with what he is teaching. Otherwise 'Assembly Language for Intel-Based Computers' is a much better book as it covers 32-bit Windows assembly programming.

Quotethe Irvine book used a different syntax than what is used in Masm 6.15

I totally disagree with that.

Maybe you are just used to 16-bit?


Jimg

The first time I saw that notation was in the language Algol.  Long before Pascal existed (1967 for me).  I always read it as "is replaced by".

asymptote

Quote from: Greg on January 11, 2008, 06:44:17 PM

I totally disagree with that.

Maybe you are just used to 16-bit?

It could very well be.  I believe my instructor was teaching 32-bit assembly.  I must say that the past fall semester was my first taste of assembly programming, so it is difficult for me to speak on your level.  I also took a digital electronics course which gave me a good understanding of an electrical standpoint of how a processor operates, but I've a long way to go.  I don't even really understand how to recognize 32-bit assembly source code versus 16-bit (but I'll google it soon enough).

I just didn't like the Irvine book because I just didn't find it very clear.  We never used the syntax from the book - it was just a reference.  I'll try and find some Irvine syntax - I think there was even an Irvine32 directive but we never used the syntax from the book.  You do ask a good question and it does stimulate my thinking.

GregL

asymptote,

I hope I didn't discourage you, what you said just didn't make sense. Hang in there, you'll be glad you did. MASM is a blast.

Forget the 16-bit and go with the 32-bit.


asymptote

It doesn't discourage me, just motivates me to learn more :)  You want discouragement - trying asking a *nix user for help. Godforbid you don't understand the *nix kernel or every function call written in C - it's like using the "ok" symbol in the middle east...

hutch--

 :bg

> trying asking a *nix user for help

And when you only know about the first 120 levels of assumptions there is something wrong with you.  :P How could you not know the quantum mechanics of each electron as it individually effects the "chmod" command ?
Download site for MASM32      New MASM Forum
https://masm32.com          https://masm32.com/board/index.php

asymptote

LoL - hopefully I have time to keep learning dig electronics so if civilization had to start over I could build a computer from the ground up.  Oh...but then I'd have to learn how to mine minerals and put them into a usable form to build capacitors, resistors, and such...ugh it never ends.

asymptote

Quote from: Greg on January 11, 2008, 06:44:17 PM

Quotethe Irvine book used a different syntax than what is used in Masm 6.15

I totally disagree with that.

Maybe you are just used to 16-bit?

I went to campus today and picked up the Irvine book.  We didn't use it much during the course - just as a reference.  On second look, it actually makes a lot more sense than it did initially.  I think I just saw the inclusion of macros and some other initializations - things that we had not discussed at all throughout the course - and that's what made it undesirable.  It looks pretty good now, and I see the difference in developing 16 and 32 bit apps.  Thanks for bringing this to my attention.