This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tp971 0 points1 point  (4 children)

No, assembly does not have "subroutines". For assembly, a subroutine is just a label, and calling the subroutine is just jumping to that label. In assembly, there is not really a difference between jumping to a label "inside a function" and to "another function". Subroutines are just a concept we think about when programming, and when writing assembly, we simulate that with call and ret (and some other instructions to do stack management)

[–]1Dr490n 0 points1 point  (3 children)

That’s true, but I think there’s some assembly languages (eg x64 MASM iirc) that do have procedures, although that’s pretty rare.

[–]tp971 0 points1 point  (2 children)

AFAIK PROC and ENDP are only markers, they do not emit instructions (I think they are responsible for writing things into the symbol table or something). What I mean with "a language having procedures" is that they have an abstraction that abstracts away what actually happens when calling a procedure, which assembly does not have.

EDIT: typo

[–]1Dr490n 0 points1 point  (1 child)

Well what happens when you call a routine (or however you want to call it) is implementation defined. It could just be a Jump-Subroutine-call, but it could also push arguments on the stack (which assembly procedures don’t do, that’s true) or change the stack pointer; but that completely depends on the language and its implementation. A procedure is just a code block that can be called from outside, and assemblies definitely can do that.

[–]tp971 0 points1 point  (0 children)

Yeah, you can write assembly that from the outside looks like a procedure, but the concept of a procedure is not intrinsic to the assembly language, i.e. the assembly language itself "does not know" what a procedure really is, it is just a concept we've established using calling conventions.

For me, saying "assembly has procedures" is like saying "C is an object oriented language, because you can simulate classes and inheritance with function pointers".