I have the following code :
when I run the Program it shows only the first line and gives a windows error message.
1. where is the problem; I tried to solve this problem more the 3h :(
2. is there a better way to find the size of a sting ?
peace
sm STRUCT
iIndex DW ? ;
szLabel DB 50 DUP (0);
szDesc DB 50 DUP (0);
sm ENDS
.data
sysmetrics \
sm <SM_CXSCREEN, "SM_CXSCREEN","Screen width in pixels">
sm <SM_CYSCREEN, "SM_CYSCREEN","Screen height in pixels">
sm <SM_CXVSCROLL,"SM_CXVSCROLL","Vertical scroll width">
sm <SM_CYHSCROLL,"SM_CYHSCROLL","Horizontal scroll height">
sm <SM_CYCAPTION,"SM_CYCAPTION","Caption bar height">
sm <SM_CXBORDER,"SM_CXBORDER","Window border width">
sm <SM_CYBORDER, "SM_CYBORDER","Window border height">
NUMPOINT equ ($-sysmetrics)/sizeof sm
.ELSEIF eax==WM_PAINT
invoke BeginPaint,hWnd, addr ps
mov hdc,eax
push esi
mov esi,offset sysmetrics
assume esi: PTR sm
xor ecx,ecx
.repeat
push ecx
mov eax, cyChar
mul ecx
mov edx,eax
lea ebx,[esi].szLabel
mov al,[ebx]
xor ah,ah
.WHILE al
inc ah
inc ebx
mov al,[ebx]
.ENDW
xor ebx,ebx
mov bl,ah
invoke TextOut,hdc,0,edx,addr [esi].szLabel,ebx
add esi, sizeof sm
pop ecx
inc ecx
.until esi == NUMPOINT * sizeof sm
assume esi:nothing
pop esi
invoke EndPaint,hWnd,addr ps
ret
when I run the Program it shows only the first line and gives a windows error message.
1. where is the problem; I tried to solve this problem more the 3h :(
2. is there a better way to find the size of a sting ?
peace
Use the StrLen supplied in the M32.LIB included with masm32.
You could also hardcode the string length in the structure, if it doesn't change.
I also see a space in your strings for Vertical scroll width, horizontal scroll width, etc. Might be a bad cut and paste tho.
You could also hardcode the string length in the structure, if it doesn't change.
I also see a space in your strings for Vertical scroll width, horizontal scroll width, etc. Might be a bad cut and paste tho.
hi mistronr1
i just had a look at ur code and could not figure out why???
my question is can we put value of ebx (a register) in al (lower order bits of accumulator).
according to me its buggy there.if am wrong pay no heed to my post.
thank you
nickdigital
i just had a look at ur code and could not figure out why???
.WHILE al
inc ah
inc ebx
mov al,[ebx] <---------------this one
.ENDW
my question is can we put value of ebx (a register) in al (lower order bits of accumulator).
according to me its buggy there.if am wrong pay no heed to my post.
thank you
nickdigital
...
my question is can we put value of ebx (a register) in al (lower order bits of accumulator).
according to me its buggy there.if am wrong pay no heed to my post.
thank you
nickdigital
my question is can we put value of ebx (a register) in al (lower order bits of accumulator).
according to me its buggy there.if am wrong pay no heed to my post.
thank you
nickdigital
The square brackets around ebx mean to load whatever is in memory at offset ebx into al. So in this case he loads the byte at offset ebx into al to check for the NULL terminator...the fact that ebx and al aren't the same size doesn't matter in this case.
hi sirchess,
thanks a lot for clearing my doubt.
nickdigital
thanks a lot for clearing my doubt.
nickdigital
Hi guys
I did some changes to the code and still having some problems.
Drarem : I know I could use StrLen, but I want to be able to do it my selv to, I realy need to understand how addressing works in a strucutre, and by the way the space at the end of each line shouldn't matter, it has to be treated as part of the string (I guess).
OK the application writes the first line and the something goes wrong, I am trying to translate some code from from windows programing by Charles Petzold.
thanks for all the replys
peace
I did some changes to the code and still having some problems.
Drarem : I know I could use StrLen, but I want to be able to do it my selv to, I realy need to understand how addressing works in a strucutre, and by the way the space at the end of each line shouldn't matter, it has to be treated as part of the string (I guess).
OK the application writes the first line and the something goes wrong, I am trying to translate some code from from windows programing by Charles Petzold.
thanks for all the replys
peace
I think the problem is that you have to save and restore the EBX register before you invoke any windows function.