The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: shadowsatan on July 18, 2007, 07:46:08 PM

Title: Help solve this
Post by: shadowsatan on July 18, 2007, 07:46:08 PM
hello i'm a newbie in asembly programming...
Could any one help to solve this code

.386
.model flat,stdcall
option casemap:none

include \masm32\include\windows.inc
include \masm32\include\kernel32.inc
include \masm32\include\masm32.inc

includelib \masm32\lib\kernel32.lib
includelib \masm32\lib\masm32.lib

.data
   hallo db "Hello World" , 0
.code
start:
   mov ecx,6

_tes:   invoke StdOut, addr hallo
   Loop _tes    
        invoke ExitProcess, 0

end start
   
how to make it loop 6 times only
sorry my english is not good

** sorry i think i got a wrong thread to discuss diz code...
Title: Re: Help solve this
Post by: TNick on July 18, 2007, 08:03:29 PM
that doesn't work because the ecx register that is used by loop instruction is not prezerved before entering in StdOut procedure.
I bet this will work

__tes:
push ecx
invoke StdOut, addr hallo
pop ecx
Loop __tes


the thing is, even if there you see just aline of code (invoke StdOut ...), in fact the code that is executed before pop ecx may have hundreds or thousands of instructions that - you can safelly assume - will modify the value stored in ecx. As a rule, you can rely on ebx, esi and edi that will have same value before and after the call, and you may assume that eax and ecx will have diffrent values. You, too, must preserve ebx, esi and edi if you use any of them in a procedure (later, you will discover that you are not required to do this always, but, for now, it's safer this way).

HTH :U
Nick
Title: Re: Help solve this
Post by: shadowsatan on July 19, 2007, 05:04:50 AM
Thx bro it's work :U.
is  there a thread to a newbie code like this ?
Title: Re: Help solve this
Post by: TNick on July 19, 2007, 05:49:47 AM
QuoteThe Campus
A protected forum where programmers learning assembler can ask questions in a sensible and safe atmosphere without being harassed or insulted. This is also targetted at experienced programmers from other languages learning assembler that don't want to be treated like kids.

:cheekygreen:

Nick
Title: Re: Help solve this
Post by: shadowsatan on July 19, 2007, 08:16:02 AM
Ow...this the right place...
Do u have a good reverence book for a newbie?
cause the TASM book is not suitable with masm :((there is no masm32 book in the book store here).
Title: Re: Help solve this
Post by: TNick on July 19, 2007, 08:46:54 AM
A great place to start coding in asm for Windows are the Iczelion Tutorials (http://win32assembly.online.fr/tutorials.html)

Have a look.

Nick