The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: purpleafroman1 on December 04, 2011, 03:48:28 AM

Title: Am i on the right track?
Post by: purpleafroman1 on December 04, 2011, 03:48:28 AM
So I've been wanting to learn assembly, and i've recently found this l (http://homepage.mac.com/randyhyde/webster.cs.ucr.edu/www.artofasm.com/Windows/HTML/AoATOC.htm) book. However, when I look at people coding in MASM32 or something else like that, the code is completely different than HLA! For example, (This isn't my code, I found it searching these forums) ;**************** Procedure to Convert Integer to ASCII ***********************
; Given   :  A pointer to the integer to be converted in the ESI register and a
;            pointer to the output string in EDI
; Process :  Convert the integer to a string of ASCII digits and store the
;         :  string in the address pointed to by EDI.  No registers are changed
;         :  and the flags are not affected.
; Return  :  Nothing
;******************************************************************************
Dec2Ascii PROC NEAR32
        pushad                          ;Save the contents of all registers
        pushfd                          ;
        cld                             ;Set the direction flag for forward
        mov eax,[esi]                   ;copy the integer to eax
        mov ecx,0h                      ;Zero the CX register for digit counter
        mov ebx,10d                     ;Set up divisor of 10 decimal
NextOut:mov edx,0h                      ;Zero EDX reg for high order dword of div
        div ebx                         ;Divide number in EAX by 10d
        push edx                        ;Save remainder on the stack
        inc ecx                         ;Count the digit
        cmp eax,0h                      ;Is number in EAX greater than 0
        ja NextOut                      ;Yes, get next digit
CharOut:pop eax                         ;Get number from the stack
        or eax, 0030h                   ;Convert Int to Ascii by adding 30h
        stosb                           ;  and store  in the destination string
        dec ecx                         ;Reduce characters to print by one
        jnz CharOut                     ;If CX > 0 loop to print next digit
        mov al,0                        ;Place a NULL in AL
        stosb                           ;  and null terminate the string
        popfd                           ;Restore the registers
        popad                           ;
        ret                             ;Return to Calling procedure
Dec2Ascii ENDP


as opposed to...


program LogicalOp;

#include( "stdlib.hhf" );

begin LogicalOp;


stdout.put( "Input left operand: " );
stdin.get( eax );

stdout.put( "Input right operand: " );
stdin.get( ebx );


mov( eax, ecx );
and( ebx, ecx );

stdout.put( "$", eax, " AND $", ebx, " = $", ecx, nl );

mov(eax, ecx);
or( ebx, ecx );

stdout.put( "$", eax, " OR $", ebx, " = $", ecx, nl );

mov( eax, ecx );
xor( ebx, ecx );

stdout.put( "$", eax, " XOR $", ebx, " = $", ecx, nl );

mov( ebx, ecx );
not( ecx );

stdout.put( "NOT $", ebx, " = $", ecx, nl );

end LogicalOp;


in HLA. Would I be staying on the right path if i kept using the book above? Or should i switch to another source for learning?
Title: Re: Am i on the right track?
Post by: jj2007 on December 04, 2011, 07:47:34 AM
Depends on what you want. HLA is, as the name says, a High Level Language. It is close to assembler but not the same.

If you want "real" assembler, one "book" is the programmer's guide (http://www.masm32.com/board/index.php?topic=5433.0).

Then there are diverging opinions on what "real" assembler is. One fraction says .Repeat ... .Until is already too high level, others say "everything that gets assembled by MASM" - which includes Let My$="Hello"+CrLf$+"how are you?" if you have the right macros (http://www.masm32.com/board/index.php?topic=12460).