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

asked Feb 21, 2012 at 2:07
5
  • 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. Commented Feb 21, 2012 at 3:15
  • @James - That's a very good point; Thank You So Much! Commented Feb 21, 2012 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. Commented Feb 21, 2012 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. Commented Feb 21, 2012 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. Commented Feb 22, 2012 at 1:26

1 Answer 1

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.

answered Feb 21, 2012 at 2:19
1
  • 1
    Yes, at least with the usual DEC assemblers (e.g., Macro-11), you'd also use mov dst, src. Commented Feb 21, 2012 at 4:17

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.