This topic has been a question in another pace but as I cannot safely post there, I have placed one easy approach here for anyone who is interested. A "PROC" in masm is effectively a label and can be addressed by the OFFSET operator at assembly time but there is an even easier way where you don't have to store both values and do the calculation and this is demonstrated below. Now where there is a potential limitation that may return a larger BYTE count than the proc size is if each procedure is aligned and the alignent padding is included in the two OFFSETs that are used. In this context if it was a problem a label placed after the RET would yield the correct result.
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
include \masm32\include\masm32rt.inc
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
comment * -----------------------------------------------------
Build this template with
"CONSOLE ASSEMBLE AND LINK"
----------------------------------------------------- *
.code
start:
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
call main
inkey
exit
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
main proc
var = last_proc - how_big ;;;; calculated at assembly time
mov eax, var
print str$(eax)," = how_big proc length in BYTES",13,10
ret
main endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
how_big proc
nop
nop
nop
nop
nop
nop
nop
nop
ret
how_big endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
last_proc proc
nop
ret
last_proc endp
; «««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««««
end start
Hutch,
as I understand it, the OP was trying to find this info at assemble time (but then again, I'm not too sure).
Ossa
Ossa,
"var = last_proc - how_big" does the calculation at assembly time, I just used screen display to show the results. The value of the calculation result in "var" is written as an immediate with the following "mov eax, var" so if "var" is 9 then the code is generated as "mov eax, 9"
Soz, hutch, missed that
Ossa