Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

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

share|improve this question
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. –  Michael Kjörling 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
add comment

1 Answer 1

up vote 6 down vote accepted

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.

share|improve this answer
    
Thank You Very Much, this is very helpful! –  Adel Feb 21 '12 at 3:18
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
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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