0
    .data
myname byte "Ngoche Penpa Gyaltsen",0
space byte ' ',0

.code

main PROC
    mov esi,0
    mov eax,0
    mov ecx,lengthof myname
    mov edx,offset space

L1:
movzx eax,myname[esi]
call writechar

mov eax,16
mov eax,yellow +(blue*16)
call settextcolor
call writestring
inc esi
loop L1;

exit

My question here is why do we need to set mov eax,0 and mov esi,0. Also, mov eax,16 is it mandatory before mov eax,textcolor +(background) because when I run without this my program shows an error. In addition, I want to learn more about masm counter and coloring in program. Can anyone suggest me site where I can practice and solved programming exercises.

nrz
  • 10,435
  • 4
  • 39
  • 71
ngoche
  • 65
  • 2
  • 8

1 Answers1

1

I don't see any reason for the mov eax, 0, because the value will be overwritten by the following movzx instruction. The mov esi, 0 is required because the esi register is used to index into the myname array.

There is no need for the mov eax,16, because the value is overwritten by the very next instruction. Are you sure that removing that line causes an error? It sure doesn't look like it should.

Jim Mischel
  • 131,090
  • 20
  • 188
  • 351
  • if I write like mov al,myname[esi] that's only time I write mov eax,0? mov eax,16 is not needed you are right. another question pls. what is the meaning of push and pop? push eax mov eax,300 call delay mov eax,16 call randomrange inc eax mov textcolor,eax mov eax,(textcolor+(blue*15)) call settextcolor pop eax inc esi inc dh – ngoche Oct 29 '13 at 21:51
  • @PenpaGyaltsen: You need an x86 assembler tutorial. Check out http://cs.smith.edu/~thiebaut/ArtOfAssembly/artofasm.html – Jim Mischel Oct 29 '13 at 22:06