Email: Password: Remember Me | Create Account (Free)

Back to Subject List

Old thread has been locked -- no new posts accepted in this thread
???
12/09/08 00:20
Read: times


 
#160775 - Calling conv more depending on target than language
Responding to: ???'s previous message
No. Pascal can pass parameters by both value and reference.

C only passes by value. When you use a pointer, you pass the value of the pointer. And if you want to modify the pointer, then you have to pass the address of the pointer, i.e. the value of the address of the pointer. This need to always use a pointer (or array as they are mostly interchangeable) is one of the things that may confuse a programmer who don't have so much experience with C.

C++ extends C by also supporting pass-by-reference. The caller need not know that a parameter is sent by reference (with the exception that it must be a parameter value that can be taken the address of). And inside the function, the code does not show that there is an indirection in all accesses to the parameter.

You have basic differences that C normally sends the parameters from right to left, and Pascal from left to right. And in Pascal, the function normally cleans up any parameters while in C it is the caller who has to clean up any stack. This distinction is why C support varying number of parameters to a user-defined function - if you pass the wrong number of parameters, the same code will also be responsible for removing them. Both can pass in registers. It is up to the compiler vendor.

But in reality, the calling models do not really translate to the real hardware. Most compilers vendors uses whatever calling model that fits the ABI of the OS. This makes sure that on application can call OS functions and OS libraries without problems. In the embedded world, you don't have any OS (or other programs) to care about. So the compiler vendor may choose any way that works. On the 8051, the calling methods are mostly controlled by the 8051 limitations and exremely little by the language.

Pascal or C should be able to produce almost identical assembly code if the two compilers where developed by the same person (and one compiler wasn't the first attemt at learning).

Code quality is more important to discuss when you decide between one C compiler or another. Or one Pascal compiler and another. Make your language selection based on knowledge, and availability of examples and other developers. And possibly political customer or company requirements about what language the important products should be written in.

List of 50 messages in thread
TopicAuthorDate
Which programming language is the best?            01/01/70 00:00      
   depends on compiler            01/01/70 00:00      
   Who is "we"            01/01/70 00:00      
   Creativity            01/01/70 00:00      
      Responding to Andy Neil "Who is we?"            01/01/70 00:00      
         apples and oranges            01/01/70 00:00      
            Re: apples and oranges            01/01/70 00:00      
               Correct            01/01/70 00:00      
               Calling conv more depending on target than language            01/01/70 00:00      
                  Re: Calling conv...            01/01/70 00:00      
         not the rule            01/01/70 00:00      
   Do you think Spanish is better than Mandarin?            01/01/70 00:00      
      Concise?            01/01/70 00:00      
         fair question            01/01/70 00:00      
            Maybe            01/01/70 00:00      
               There is no question about it!            01/01/70 00:00      
                  Does it work ?            01/01/70 00:00      
                     Unless it impacts cost ...            01/01/70 00:00      
                  Bottom line            01/01/70 00:00      
                     ... and that is the problem with many products ...            01/01/70 00:00      
                        Not true            01/01/70 00:00      
                           low-volume/high-volume tradeoffs            01/01/70 00:00      
                        Bottom line price is more than just consumed kB code space            01/01/70 00:00      
            Oh no, not that old chestnut            01/01/70 00:00      
               Assembler and processor size            01/01/70 00:00      
                  Is that relevant to this environment?            01/01/70 00:00      
                     Human brain            01/01/70 00:00      
               You will have trouble convincing me ...            01/01/70 00:00      
                  I agree with you there!            01/01/70 00:00      
      Re: Spanish better than...            01/01/70 00:00      
         That's the point!            01/01/70 00:00      
         not so            01/01/70 00:00      
   In a war which is the best weapon ?            01/01/70 00:00      
      the language in which programmer feels comfortable            01/01/70 00:00      
         Comfort is not the issue!            01/01/70 00:00      
            true, but            01/01/70 00:00      
         It's about the right tool(s) for the job            01/01/70 00:00      
   My two cents            01/01/70 00:00      
      If it fits ...            01/01/70 00:00      
         that is (ir)relevant            01/01/70 00:00      
            What is small?            01/01/70 00:00      
               Would that be appropriate on 805x?            01/01/70 00:00      
                  more on big/small series            01/01/70 00:00      
                     Does this approach fit 805x and other small MCU?            01/01/70 00:00      
                        Already have full Linux solutions too            01/01/70 00:00      
   Yes..C and asm is the best            01/01/70 00:00      
   I prefer KEIL U2V , C programming language.            01/01/70 00:00      
      Magic with Kel C?            01/01/70 00:00      
      Makes no sense!            01/01/70 00:00      
   Pascal is not dead            01/01/70 00:00      

Back to Subject List