News:

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

Question for the Masters......

Started by Sultan, July 27, 2006, 10:47:43 PM

Previous topic - Next topic

Sultan

Well, I open this thread with the main idea of unload any kind of questions throughout the book reading.

By the way, You know that we don´t have a teacher beside us when we are devoloping the reading and some questions arise always, so that´s why I open this space to ask the Masters about doubts that suddenly appear.

# 1

At page 422 on Chapter two, I compile the prgram StrDemo, and  everything was fine in the assembling process................. But, a doubt sudenlly merge, and is in the moves that  program relates like:

             mov( theString, ebx);              // Get the pointer to the string ( UNDERSTOOD )
   
             mov( [ebx-4], eax );                // Get current length               ( I DON´T KNOW WHY, -4 ???)
             mov( [ebx-8], ecx );                // Get maximum length            ( Same situation here Why -8 ?)

If String length is 19, I don´t understand this movement, may you explain me  more especifically.

Thanks in advance for your kind of attention.

Best regards

Sevag.K

Well, I'm not a "Master", but I know my around HLA well enough to answer this.

If you read a little further, you are advised not to use direct offsets as in the example, but to use the str.strvar type instead.
Generally, an HLA string variable is a pointer to character data.  The length and max length are stored at negative offsets to the character data.

Taking a look at the strRec structure:
type
      strRec:   record := -8;

               MaxStrLen:   dword;
               length:      dword;
               strData:   char[12];

            endrecord;

If you take notice, the record offset begins at -8.  A string variable would point to the strData field.  So to access the length field, you would take an offset of -4 from the address of strData.

The correct way to do so:


     mov (theString, ebx);                                            // Get the pointer of the string
     mov ( (type str.strRec [ebx]).length, eax);            // Get current length
     mov ( (type str.strRec [ebx]).MaxStrLen, ecx);     // Get maximum length


Using the strRec type, HLA will substitute the correct offsets to get the values you want.


Sultan

Understood !!!!!!!!!!!!!!!!!!!

Thanks a lot.

And noooooooooooooooooooo!!!!!!!!!!!!! Don´t tell me that Sevag.K because............................

YOU ARE A MASTER !!!!!!!!!!!!!!!!!!!!!!!!!!!!

HEHEHEHEHEHEHEHEHE !

Thanks again .

Sultan

Sultan

Hehehehehehe................. :U

Well I´ve got another one..............Sorry if I bother all of you, but, I need to understand what I´m doing.

Compiling the last programs of Chapter Three arround pages 440 to 460, I found some kind of repetitive syntaxis that make me jump once on awhile because I don´t understand why the writter repeat the procedure with different values of the dwords [], [4], [8] and [12]

This one,  could be a great example of what I´m referring and need to clarify:

You can find it at page 456 of the reading book

begin csIntersection;

    mov( (type dword csetSrc1), eax );              <==
    and( (type dword csetSrc2), eax );
    mov( eax, (type dword csetDest) );

    mov( (type dword csetSrc1 [4]), eax );          <==
    and( (type dword csetSrc2 [4]), eax );
    mov( eax, (type dword csetDest [4]) );

    mov( (type dword csetSrc1 [8]), eax );          <==
    and( (type dword csetSrc2 [8]), eax );
    mov( eax, (type dword csetDest [8]) );

    mov( (type dword csetSrc1 [12]), eax );         <==
    and( (type dword csetSrc2 [12]), eax );
    mov( eax, (type dword csetDest [12]) );


I don´t know why ( for example ) or the reazon why the writter have to repeat as a syntaxis mechanism the same procedure for []  right after for [4], [8] and for last [12].

Randy, Sevag or anybody else would like to clraify my doubt doing a wide explanation of this particular concept please ?

Thanks in advance for your kind of attention

Sultan




Sevag.K

A character set is 128 bits

Since we are using 32 bit reigsters, we divide this into 4 dword-sized chunks:

[bytes 0-3]  [bytes 4-7]  [bytes 8-11]  [bytes 12-15]
  dword 1       dword 2       dword 3        dword 4

Notice the offsets of the dwords are at 0, 4, 8 and 12.

The code you posted produces the intersection of 2 character sets, which is basically an AND operation:
csetSource1 AND csetSource2 = csetDest

This is like extended precision arithmatic (you probably didn't get that far yet).
Each of the 4 parts in the source performs a 32-bit chunk of the operation.



    mov( (type dword csetSrc1), eax );             // AND the 1st dword of the 2 sources together and copy to dest.
    and( (type dword csetSrc2), eax );
    mov( eax, (type dword csetDest) );

    mov( (type dword csetSrc1 [4]), eax );         // AND the 2nd dword of the 2 sources together and copy to dest.
    and( (type dword csetSrc2 [4]), eax );
    mov( eax, (type dword csetDest [4]) );

    mov( (type dword csetSrc1 [8]), eax );         // AND the 3rd dword of the 2 sources together and copy to dest.
    and( (type dword csetSrc2 [8]), eax );
    mov( eax, (type dword csetDest [8]) );

    mov( (type dword csetSrc1 [12]), eax );        // AND the last dword of the 2 sources together and copy to dest.
    and( (type dword csetSrc2 [12]), eax );
    mov( eax, (type dword csetDest [12]) );


csetSrc1:  [dword 1]   [dword 2]   [dword 3]   [dword 4]
                 AND             AND           AND          AND
csetSrc2:  [dword 1]   [dword 2]   [dword 3]   [dword 4]
                    =                =              =              =
csetDest:  [dword 1]   [dword 2]   [dword 3]   [dword 4]

It's also possible to have a loop repeat 4 times, but that way is more inefficient.


Sultan

Ohhhh !!!!!!!!!!! MAN !!!!!!!!!!!!!!!!

What a piece of explanation Sevag !

Thanks a lot.

I wish you the best.

Regards.

Sultan  :cheekygreen: :clap: :U

Sultan

Well, I have some more here, between pages 523 and 527, especifically in programs ( SimpleFileOutput, SimpleFileInput, SimppleFileInput2, AppendDemo & EolnDemo ).

For instance, there is writted the following code:

fileio.open( "myfile.txt", fileio.rw ); >>>>>>>>>>> myfile.txt never opened anywhere

Also a banner  with an alert displays: HLA Exception (7)..............File open failure, this happen in all the above mentioned files.

May I know why this kind of behavior is appearing ?

Another doubt merge, when I saw  the AppendDemo & EolnDemo files, particulary in the "While´s" section
the punctuation mark  ( ! ) before fileio.eof( fileHandle ). Can you explain me the reazon of such coding ?

fileio.rewind( fileHandle );
    while( !fileio.eof( fileHandle ) ) do   >>>>>>>>> !

Like always, Thanks in advance for your kind of attention.


Best regards.


Sultan  :green2


Sevag.K


fileio.open opens an existing file.  The exception likely indicates that the file was not found.
Use fileio.openNew to create a new file.  See the SimpleFileOutput program pg. 511 to see how this is done.  This program also creates the myfile.txt that the other programs use.

Sultan

Quote from: Sevag.K on October 01, 2006, 06:55:51 PM

fileio.open opens an existing file.  The exception likely indicates that the file was not found.
Use fileio.openNew to create a new file.  See the SimpleFileOutput program pg. 511 to see how this is done.  This program also creates the myfile.txt that the other programs use.


Got it and works !

Now I only have the doubt regarding the coding in the while section [ ! ]

Thanks for your quick reply Sevag.K

Sultan

Sevag.K


Oh forgot about that part.  The explanation point '!' means NOT.  So in essence the loop is "while not end of file, do..."

Sultan

ORALE CAMPEON !!!!!!!!!!!!

Understood !

Thanks Sevag.K for your kind of attention !!!!!!!!

So far I owe you a couple of beers dude, hopefully sometime, we drink some and cheers about HLA hehehehehehehehe.  :dance: :U :cheekygreen:

Regards.


Sultan  :green2

Sultan

Page 565

program QSDemo;

Line 36

shr( l, eax );

Encountered an error and compiler tells me:

C:\ HLA\ Projects\ QSDemo>hla QSDemo.hla
Error in file "QSDemo.hla" at line 36 [errid:41506/hlaparse.bsn]:
Undefined symbol.
Near: << l >>

So, What do I have to do ?

Regards.


Sultan  :red


Sevag.K

Quote from: Sultan on October 24, 2006, 09:01:15 PM
Page 565

program QSDemo;

Line 36

shr( l, eax );

Encountered an error and compiler tells me:

C:\ HLA\ Projects\ QSDemo>hla QSDemo.hla
Error in file "QSDemo.hla" at line 36 [errid:41506/hlaparse.bsn]:
Undefined symbol.
Near: << l >>

So, What do I have to do ?

Regards.


Sultan  :red



change the capital i to the number 1

:)


Sultan

Got it !!!!!!!!!!!!!!

Thanks again.

Sultan  :U :clap: :dance: