News:

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

Help solve this

Started by shadowsatan, July 18, 2007, 07:46:08 PM

Previous topic - Next topic

shadowsatan

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...

TNick

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

shadowsatan

Thx bro it's work :U.
is  there a thread to a newbie code like this ?

TNick

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

shadowsatan

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).

TNick

A great place to start coding in asm for Windows are the Iczelion Tutorials

Have a look.

Nick