1. Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.
    Dismiss Notice

hardware is still coded with machine/assembly language for efficiency, speed, etc.

Discussion in 'General Electronics Chat' started by PG1995, Mar 25, 2012.

Thread Status:
Not open for further replies.
  1. nsaspook

    nsaspook Well-Known Member

    Joined:
    Mar 24, 2010
    Messages:
    1,141
    Likes:
    219
    Location:
    Fairview, Or
    I was showing each language at it's optimum level in the comparison. CPU bound "ASM" demo and DATA bound "HLL" OS.

    Your words were, "higher level programming languages are only required for complex problems if the person that's programming it has a simple mind" as a predicate.

    The code base for Linux will not be improved by recoding as it's speed on bare metal hardware is as good as native performance when tuned for RTOS mode.

    BTW, Android is a Linux fork. http://en.wikipedia.org/wiki/Android_(operating_system)#Linux
     
    Last edited: Apr 1, 2012
  2. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,966
    Likes:
    1,099
    Back in the mid 70's, high school era+, part of a team that of two that added scope rubouts for VT100 terminals to the PDP-11 RSTS operating system time sharing terminal handler. RSTS was a 32 user time sharing Operating system.

    Well, I had to do button and display multiplexing in 6800 assembly as part of a class.

    Then I did a motorized gantry crane for a model crane (COSMAC 1802 Assembly): 3 rows of 9 boxcars, a motorized oval loading dock and Z was a motorized electromagnet. Everything was compiled by hand. It was just about the time the PC came out. Later I did the same project with a single board basic computer and managed to get X and Y moving at the same time.
     
    Last edited: Apr 1, 2012
  3. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    There is no 'optimum level' I can't even quiet figure out how you can rationalize the statements CPU bound ASM demo and DATA bound higher level languages, what do you even mean by data bound or cpu bound? There's nothing that can't be done in ASM that can only be done with a HLL or vs versa and ASM will always be faster given enough time is put into optimizing the ASM, the only reason for HLL's is to save time and reduce the amount of detailed information required by the programmer to obtain a given set of functional software abilities. In modern times due to hardware fragmentation it's impossible to practically program in ASM due to the diverse hardware that things are run on.

    This is blatantly false, the reason it's speed on bare hardware is so good is because so much of it is based on good assembly programming foundations and a reduced as much as possible amount of overhead. Given any static system you could recode many things with inline assembly to increase system speed, but again it's at time/effort vs payback potential that is the only reason it doesn't occur more.

    I'm well aware Android is a Linux fork it has the same problem as all Linux distributions because of it of hardware/software fragmentation. Even though there are more Android devices developers still prefer IOS because programming for Android requires a higher number of programming hours for the same product due to the different Android versions, and difference in device hardware support for various features, but this is neither here nor there in relation to ASM vs higher level languages.
     
    Last edited: Apr 1, 2012
  4. dave

    Dave New Member

    Joined:
    Jan 12, 1997
    Messages:
    -
    Likes:
    0


     
  5. jlpelect5

    jlpelect5 New Member

    Joined:
    Apr 1, 2012
    Messages:
    25
    Likes:
    0
    Location:
    Michigan, USA

    hello pg1995,

    The real difference between assembler and a high level language is that with assembler there is one step to generate hex code for your program. High level language must compile your program from libraries written by someone else then assemble the compiled program to hex.

    You have a far more control and precision with assembler.

    You are relying on someone else's programming with high level programming.

    This is my first post. Hope it helps.

    jlpelect5
     
  6. jlpelect5

    jlpelect5 New Member

    Joined:
    Apr 1, 2012
    Messages:
    25
    Likes:
    0
    Location:
    Michigan, USA
    Hello misterT,

    Not the most complex but, wrote a program to modulate varying pulse widths at 38khz with a 25% duty cycle.

    jlpelect5
     
  7. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,966
    Likes:
    1,099
    Sounds like an IR remote control.
     
  8. jlpelect5

    jlpelect5 New Member

    Joined:
    Apr 1, 2012
    Messages:
    25
    Likes:
    0
    Location:
    Michigan, USA
    Hello KeepItSimpleStupid,

    Yes it is. The circuit has the ability to read any remote button by button and then store them in eeprom.
    Through a rf trigger (433mhz) the circuit will output the stored info with preproggrammed delay's .

    Reading one of your post, i was roflmao when I saw PDP-11

    jlpelect5
     
    Last edited: Apr 1, 2012
  9. nsaspook

    nsaspook Well-Known Member

    Joined:
    Mar 24, 2010
    Messages:
    1,141
    Likes:
    219
    Location:
    Fairview, Or
    If you have a bike and need to cross the street it's better just to run.

    10 yards: legs
    But at
    100 yards: ?
    1000 yards: ?
    1 mile: ?

    Clearly there is a point where effort (mental or physical), speed, efficiency and the ability to maintain and improve favor a mechanical advantage. Yes there are exceptional people who can run 100 miles but is that the best way to get there?
    The process of computer programming operates on the same level.

    On the topic of what have you done in ASM. My first real taste of a large ASM coded project was the OS for the H-series machines called VULCAN. It was a total maintenance nightmare. Not because it was poorly written but over the years the specifications for it had become so complex it became almost impossible to verify and had become totally dependent on the hardware quirks in the cpu platform during the process of making it run faster when features were added over the years.

    I wrote special device drivers using "system services" on a interface project with custom hardware in assembler and FORTRAN.
    http://www.electro-tech-online.com/custompdfs/2012/04/AA61770-0_VULCAN_Spec_Jan75.pdf
    http://www.electro-tech-online.com/custompdfs/2012/04/0862005-003_vulcanOvr_May78.pdf
     
    Last edited: Apr 1, 2012
  10. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland
    Have you ever programmed microcontrollers with C? Can you show an example where ASM "has far more control and precision" than C.

    Ok. C is not a very high level programming language, so in that respect the above is true. If I use something like Java or C# then I would quite heavily rely on someone else's programming.
     
    Last edited: Apr 1, 2012
  11. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    No it does not, the difference is that exceptional programmers can make a computer run dozens, hundreds, if not thousands of times more efficiently if they're applied properly. The comparison to the human example you gave would be a runner that can run 1000 miles per hour.

    I liken it to more towards the spectrum of light, where it starts going into the UV range. Outside of the direct heating effects no matter how brightly you shine a light on a bacteria or a mold you can not kill it until the frequency of the light breaks past a certain point which is in the low UV range. You can toss a hundred dumb programmers and make something work, but if you toss one great programmer it will work better and faster.

    The problem actually is our demand for software advancement and functionality in the short term is so high in relation to the time it would take to do it properly that the only way to get software products on the market is to use higher level languages. ASM is still superior in every way at being able to fully utilize available resources. The issue is mollified by Moores law staying roughly true.
     
  12. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    A very specific and absolute example is in measurement and calculation, as the number of measurements or calculations approaches the time constant of the procoessor that the program is running on ASM becomes more and more desirable, and after a certain point I'm unable to define doing high precision timing and measurement applications become impossible in C and only ASM can work.

    We're spoiled because of Moores law as I stated in my last post. We can do more and more with C not because it's good efficient or powerful, but because the hardware is so much faster nowdays that ASM doesn't have as much of a practical application until the absolute limits of current technology.

    This is the heart of why the demoscene exists, is to show what can be done in ASM with modern hardware. In order to do these types of real time visual effects using modern C based software would require (and does) room and building sized super computers. Seriously, actually run a few demo's on your computer (better be a fast one) and compare that to what you visually see in movies and the like that take weeks, months or years to render on sever farms.
     
    Last edited: Apr 1, 2012
  13. misterT

    misterT Well-Known Member Most Helpful Member

    Joined:
    Apr 19, 2010
    Messages:
    2,697
    Likes:
    368
    Location:
    Finland
    I do not understand why you think C is a high level language.. it really is not far away from ASM. C is the next closest thing to "hardware level" programming. It is very efficient and powerful.. if you would just take some time and learn the language before comparing it to asm.
     
  14. PG1995

    PG1995 Active Member

    Joined:
    Apr 18, 2011
    Messages:
    1,681
    Likes:
    13
    Hi Jlpelect5

    Thank you for the input and welcome to the forums! :) I'm sure you are going to have a good time here and let me tell you it's one of few forums where people are really nice and helpful without being arrogant and snobbish.

    Regards
    PG
     
  15. nsaspook

    nsaspook Well-Known Member

    Joined:
    Mar 24, 2010
    Messages:
    1,141
    Likes:
    219
    Location:
    Fairview, Or
    In a CPU bound process the speed of the entire process increases with a more efficent coding and/or processor. When a process is DATA bound the speed of processing does not increase with more processor or efficent coding because the time to complete the task is not a simple linear math problem but could be a control problem with asynchronous data dependencies like a OS.

    A simple example.
    A data system written in C reads a byte of data from a port due to an interrupt once every 1ms from a sensor, sends a byte to another system that also reads data from a interrupt once every 1ms from a sensor, waits for the reply, processes the result and then sends it to another port when it receives a interrupt request every 10ms from that system for possible new data sent to a logging device.

    Once the program speed is sufficently fast to handle the tasks for a correct result in the time period needed recoding it in ASM, BASIC, COBOL or even a faster processor will not make it faster.
     
    Last edited: Apr 1, 2012
  16. Ratchit

    Ratchit Well-Known Member

    Joined:
    Mar 12, 2008
    Messages:
    1,955
    Likes:
    83
    misterT,

    I am a little rusty in C, but can't you add two arrays of the same size and shape together with one statement? Of course with ASM, you have to set up a loop counter whose value is the same size as the arrays, then add each element of the array and store it back. C does the same thing, of course, but you don't have to worry about the details. That's why I would call C "high level".

    Ratch
     
  17. Ratchit

    Ratchit Well-Known Member

    Joined:
    Mar 12, 2008
    Messages:
    1,955
    Likes:
    83
    nsaspook,

    Yes, a computer is only as fast as its slowest operation, whether it is memory access or I/O. Having a Gee Whiz CPU does no good it unless its support systems are able to keep up with its speed.

    Ratch
     
  18. KeepItSimpleStupid

    KeepItSimpleStupid Well-Known Member Most Helpful Member

    Joined:
    Oct 30, 2010
    Messages:
    9,966
    Likes:
    1,099
    C is very close to assembly. I know a guy that tends to debug his C programs by looking at the assembly code that C produces.
     
  19. Sceadwian

    Sceadwian Banned

    Joined:
    Oct 27, 2006
    Messages:
    14,047
    Likes:
    141
    Location:
    Rochester, US
    There are four levels of programming language.
    Machine code, which is what actually exists in classical processors. ASM, which is one step above that attempts to make this human understandable by naming things in human language as opposed to raw byte values, and then everything else above that which increase the level of abstraction and distance from ASM. Then there are hardware description languages for CPLD and FPGA type devices that are bellow even ASM, though abstracted because they're not clasic devices, you define them.

    I never said it would, it will however make it more efficient which will use fewer cycles meaning less power.

    This is what I was trying to get at with my statement that the need for use of ASM vs higher level languages follows a gradient vs the available resources.
    C is used because the available resources are astonishing. If we used them well we could do more with what we have.

    Machine code is absolute, (outside of the programmable logic alternative) ASM is good the real killer to efficiency with that is macros which improperly used cause massive code bloat. This bloat extends into higher level languages.
     
    Last edited: Apr 1, 2012
  20. Ratchit

    Ratchit Well-Known Member

    Joined:
    Mar 12, 2008
    Messages:
    1,955
    Likes:
    83
    KISS,

    That is an insufficient reason to call C "close" to assembly.

    Ratch
     
  21. jlpelect5

    jlpelect5 New Member

    Joined:
    Apr 1, 2012
    Messages:
    25
    Likes:
    0
    Location:
    Michigan, USA
    Hello misterT,

    I started out with microsoft assembler using MASM611 programming 8086, 286 and 386. Then I dabbled with C++ and Visual C++, was not long before I went back to assembly.
    Was not impressed with overhead and using someone else's programs that I had no control of or limited amount of control.

    Programming in assembly language can be precise to one clk. In the debug mode I can step my program one
    instruction at a time.
    The achitecture of the atmel microcontrollers is called "pipeling", which means when I execute an instruction
    the next instrution is being loaded at the same time. Therefore almost every clk is a instruction.

    If the odd few instructions needs more than one clock cycle I will see that in the debugger.

    For example, using a 4mhz clock, I can see what is happening every 1/4 million'th of a second, and that is slow as
    the chip is capable of 20mhz, (.05 million'ths of a sec)

    jlpelect5
     
Thread Status:
Not open for further replies.

Share This Page