A small example of what causing confuision for me:
ss proc
mov eax, 10
cmp eax, 10
je ns
exit:
ret
ss endp
ns proc
;do some stuff
jmp exit
ns endp
I keep getting an error at 'jmp exit' that exit is an undefined label.
Both proc are defined in the same file, both procs are EXTERNDEFed. I did a search, do I need to make labels public? The only reason for breaking it into another proc is clarity. If someone has a suggestion keeping it all in one proc, that would be appreciated too. Thanks.
ss proc
mov eax, 10
cmp eax, 10
je ns
exit:
ret
ss endp
ns proc
;do some stuff
jmp exit
ns endp
I keep getting an error at 'jmp exit' that exit is an undefined label.
Both proc are defined in the same file, both procs are EXTERNDEFed. I did a search, do I need to make labels public? The only reason for breaking it into another proc is clarity. If someone has a suggestion keeping it all in one proc, that would be appreciated too. Thanks.
Alright, just figured out the 'all in one proc' way.
But I'm still interested in how can I use a label defined in one proc in another.
Now that I think about, that might be a great way to write spegetti code.
But I'm still interested in how can I use a label defined in one proc in another.
Now that I think about, that might be a great way to write spegetti code.
exit:: <- Note the extra colon!
Its not just a great way to write spaghetti code, its also a great way to write highly dangerous code which screws over the stack!
Mirno
Its not just a great way to write spaghetti code, its also a great way to write highly dangerous code which screws over the stack!
Mirno
Thanks Mirno, now I'm off to program spagetti /jk
Be very careful with jumps between procs.. Unless you've got a good reason to use them, don't :).
If the two procs have a different number of parameters and you jump to the other proc, the stack will be corrupted if you return..
Thomas
If the two procs have a different number of parameters and you jump to the other proc, the stack will be corrupted if you return..
Thomas
Its worse than that Thomas, if there is a uses statement at the start of the proc, if you pop anything off the stack that isn't there because you didn't push it in the original process there will be an earth shattering kaboom...
Mirno
Mirno
And you're JMPing to a RET, which is just extra overhead. And I think this screws up branch prediction on some CPUs, slowing things down even more.
It's just generally not a good thing to do. That's why MASM makes it difficult to do. :)
It's just generally not a good thing to do. That's why MASM makes it difficult to do. :)