Now that I have my exit_status, I want to know how many spaces the value is so I can prepare a TextOut call. tens, hundreds, thousands...


    xor esi,esi
      cmp exit_status,1000
      jg @Push_four
      cmp exit_status,100
      jg @Push_three
      cmp exit_status,10
      jg @Push_two
      jmp @Push_one
@Push_one:
mov esi,1
jmp @Push_finish
@Push_two:
mov esi,2
jmp @Push_finish
@Push_three:
mov esi,3
jmp @Push_finish
@Push_four:
mov esi,4
jmp @Push_finish
@Push_finish:
invoke wsprintf,addr Block_Length,T("%d"),esi  ; <- Here I put my value of spaces to Block_Length
cmp exit_status,1
je @force_zero
ret


Now, outside of that call, in WndProc I try to use the value of Block_Length...


.data
Block_buffer db 32 dup(0)
Block_Length  db 1

.code
        xor esi,esi
        lea esi,Block_Length
        invoke MessageBox,0,esi,0,MB_OK  ;<- this shows me that esi contains a 4
push 4 ;esi        ; <- If I push esi the entire thing crashes
        push offset Block_buffer ;size of blocked
        push 10
        push 242
        push hdc
        call TextOut


(And why do you use push/call instead of invoke, by the way?)

Because I have n00b slapped on my fore-head.

-#2pencil-
Posted on 2005-08-18 13:58:29 by number2pencil
Ahh, I see things much clearer now :)

TextOut doesn't want the address an integer (which you're getting with your LEA). It wants an integer. So, instead of "lea esi, ", you should do "movzx esi, ". Or you could directly use on the call to TextOut.

If there's more trouble, try using a DWORD instead of byte for the blocklength var.
Posted on 2005-08-18 14:34:20 by f0dder
This doesn't work either. 

        xor esi,esi
        ;lea esi,Block_Length
        movzx esi,
        invoke MessageBox,0,,0,MB_OK  ; <- now this crashes, even with push esi
        invoke TextOut,hdc,242,10,offset Block_buffer,

Now when I try to do this without the MessageBox for checking value of esi, I get way more than the value of 4.  It prints the entire line with boxes.  Maybe I'm going about finding the spaces in my value, the wrong way?

-#2pencil-
Posted on 2005-08-18 14:46:03 by number2pencil

@Push_one:
mov ,1
jmp @Push_finish
@Push_two:
mov ,2
jmp @Push_finish
@Push_three:
mov ,3
jmp @Push_finish
@Push_four:
mov ,4
jmp @Push_finish
@Push_finish:
;invoke wsprintf,addr Block_Length,T("%d"),esi

Problem solved, thank you f0dder.  Now, what is the differance between Block_Length & ?

-#2pencil-
Posted on 2005-08-18 14:56:58 by number2pencil

Now, what is the differance between Block_Length & ?

In MASM, it's the same... but brackets indicate memory reference (makes a lot of difference with ESI vs ),and even though MASM ignored [] for variables, I tend to be explicit with them, as assemblers like NASM and FASM requires them.
Posted on 2005-08-18 15:00:59 by f0dder