Chuck(G)
25k Member
One of the things that I remember about JRT Pascal for the 8080 (it didn't require a Z80) is that it implemented a segmented/virtual memory scheme. You could have data structures and procedures larger than installed RAM, so long as you had disk storage around. That was pretty remakable, given the resources. But, since Pascal pretty much demands a stack-type structure for implementing procedures and local storage, you'll have to do something elaborate as the 8080 makes it difficult to access stack elements. Usually, something like LXI H,offset DAD SP just to get the address of something. Access is by byte only, not words, since the 8080 doesn't have an indirect register load of a word--you've got to do it byte by byte.
K&R C does not have a "string" type, strictly speaking. BASIC/SNOBOL type strings are composite structures. Memory is allocated to them as needed; that includes temporaries and garbage collection. In most implementations, this is accomplished by using a "descriptor" to deliver not only the location of the data and its (current) length. So, in the BASIC sense of a string you can say:
A$ = B$+C$+A$+D$
No such standard structure exists in K&R C, nor does it occur in Wirth's Pascal. There's a good reason for that. Automatic allocation and garbage collection is a process whose time to execution cannot be rigidly specified--and that's an anathema in system-level code. What C calls strings are really pointers to delimited fixed-length character arrays. That's kind of nasty, since basic operations such as strcat have to calculate the length of its operands and run time; the same for strlen. If you've got a descriptor, you just pull the length from it and you're set to go. Of course, it's perfectly possible to implement a descriptor-dynamic allocation mechanism in C if you need it--it's just not a standard part of the language.
K&R C does not have a "string" type, strictly speaking. BASIC/SNOBOL type strings are composite structures. Memory is allocated to them as needed; that includes temporaries and garbage collection. In most implementations, this is accomplished by using a "descriptor" to deliver not only the location of the data and its (current) length. So, in the BASIC sense of a string you can say:
A$ = B$+C$+A$+D$
No such standard structure exists in K&R C, nor does it occur in Wirth's Pascal. There's a good reason for that. Automatic allocation and garbage collection is a process whose time to execution cannot be rigidly specified--and that's an anathema in system-level code. What C calls strings are really pointers to delimited fixed-length character arrays. That's kind of nasty, since basic operations such as strcat have to calculate the length of its operands and run time; the same for strlen. If you've got a descriptor, you just pull the length from it and you're set to go. Of course, it's perfectly possible to implement a descriptor-dynamic allocation mechanism in C if you need it--it's just not a standard part of the language.