3

I'm looking at the basic strcpy function. It is

char *strcpy( char *dest, const char *src );

Which reminds me of assembly language: MOV DEST, SRC

  • 6
    You just need to ask yourself which came first C or Intel *86 chips. Or put it another way processors exist to run programs on, any new processor is going to attempt to efficiently support all features of an existing popular language. – James Anderson Feb 21 '12 at 3:15
  • @James - That's a very good point; Thank You So Much! – Adel Feb 21 '12 at 3:19
  • 3
    strcpy(dest, src) or dest = src. No, in C, these don't accomplish the exact same thing, but the general pattern (destination before source) is the same in both. If C had used a syntax like TI-BASIC's value → variable (source before destination) for assignment, maybe it would have been strcpy(src, dest) too. – a CVn Feb 21 '12 at 9:11
  • @James Anderson: The Intel 8008 was released in 1972, and that set the tone for the Intel processors to follow (8080, 8085, 8086 and beyond), and that's about the time C was released. Looks like independent development to me. – David Thornley Feb 21 '12 at 16:16
  • @David -- but Cs predecessors such as BCPL had already been around for a while. Besides nearly every contemporary instruction set (PDP-11, IBM 360, Unisys, Burroughs etc.) implemented a block move instruction. – James Anderson Feb 22 '12 at 1:26
6

The Intel processors were not yet invented when the C library was designed, so no.

Your observation that C is similar to assembly language is correct, however. C was designed to replace assembly when Unix needed to be ported to other architectures than the original PDP-11 and many constructs map directly to the PDP-11 machine language.

I do not know if the machine language of the PDP-11 was similar to Intel (dest, src) or the reason for the API convention was just that it was this way that made most sense to the designer.

See http://www.unix.org/what_is_unix/history_timeline.html for time line.

  • 1
    Yes, at least with the usual DEC assemblers (e.g., Macro-11), you'd also use mov dst, src. – Jerry Coffin Feb 21 '12 at 4:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.