the size of code between 2 labels?
my approach/idea was:
@Start:
some code here
.
.
.
@End:
lea ebx, @End
lea edx, @Start
sub ebx,edx
but all i get is this error:
error A2138: invalid data initializer
tia
Amadeus
CodeSize (https://www.jj2007.eu/MasmBasicQuickReference.htm#Mb1221)
Btw your code works, too. Post the complete version, so we'll find out which line made it crash.
thanks @jj2007
the code is:
.data?
str1 dd ?
Hits dd ?
.code
start:
;#########################################################################
invoke crt_printf,chr$ ("Collatz Theorem",CR,LF,CR,LF)
@Start:
and Hits,0
mov str1,input("enter a number between 4 and 2000 : ")
mov esi,sval(str1)
push esi
invoke crt_printf,chr$ (CR,LF,CR,LF,"%d -> { "),esi
pop esi
mov ebx,3
.repeat
; test esi,1
.if !(esi & 1) ;ZERO?
mov eax,esi
shr eax,1
mov esi,eax
.if (eax != 1)
invoke crt_printf,chr$("%d, "),eax
.else
invoke crt_printf,chr$("%d }"),eax
.endif
.else
mov eax,esi
; mov ecx,3
mul ebx
add eax,1
mov esi,eax
invoke crt_printf,chr$("%d, "),eax
.endif
inc Hits
.until esi==1
@End:
lea ebx, @End
lea edx, @Start
sub edx,ebx
invoke crt_printf,chr$("used Bytes : %d ",CR,LF,CR,LF),edx
; invoke crt_printf,chr$ (CR,LF,CR,LF)
invoke crt_printf,chr$ (CR,LF,"%d -> Nodes",CR,LF),Hits
;#########################################################################
invoke wait_key
invoke ExitProcess, 0
end start
PS: found it (sub edx,ebx) registers inverted
again thanky you @jj2007 have nice weekend
Amadeus
Don't forget the "$' operator, which gives you the current address in your code (or data):
TokenParseChars DB ' ', ',', "'", 'H', $hexChar, $EOL, $EOF, ';'
$numParseChars EQU $ - TokenParseChars
gives you the number of characters in that list. You can put it in code segments too to measure distance.
thanks for the tip