|
Programming and Assembly Language Please read this Topic's rules!! |
![]() |
| LinkBack | Thread Tools | Rate Thread |
| |||
Quote:
As far as writing hardware drivers - most of it can be done in C quite happily. Typically you'd just write small segments (time critical or sensitive) in assembler. Áedán
__________________ Any views, thoughts and opinions are entirely my own. They don't necessarily represent those of my employer (BlackBerry). |
| |||
Quote:
Áedán
__________________ Any views, thoughts and opinions are entirely my own. They don't necessarily represent those of my employer (BlackBerry). |
| ||||
Today that would seem like an extreme and outlandish sequence of languages to learn and the learning curve could be described with similar terms! ![]() However with some the mention of some of the CPUs you cut your coding teeth on you are inevitably giving away that you are from the generation before mine Aedan. Or perhaps you really have been coding since you were in the cot. ![]() Nice to know there are some old hands with the old assm in the forum though... although we probably would use it (assembler), you and I, for entirely different things. I feel a new thread is looming nerviously in the wings . . . ![]()
__________________ |
| ||||
Quote:
![]() As Aedan points out, the girl in the picture is not me (well DOH) but my lovely girlfriend through 2+ years now, Bettina. The hat is mine, brought all the way home to me from Australia by my older brother. Real leather, real crocodile teeth! Hoo-ah! ![]() ![]()
__________________ |
| ||||
Quote:
Given a choice, I prefer to code in ASM (even on the x86). Why? Because REAL programmers code in ASM, that's why! ![]() For pure, raw, unbridled speed and power, NOTHING touches ASM. It is SUCH a rush to see a program that used to crawl fly by so fast you think something is wrong. You don't have to deal with screwball compiler optimizations. There are no surprises. The program does EXACTLY and ONLY what you tell it to do. However, I'm rarely given the choice. Interfacing an ASM program to a C or C++ application usually involves jumping through hoops. And most of the people who pay my checks don't give a crap if the high-level language I write in requires more powerfull hardware to get reasonable performance, because Moore's law has spoiled them. What they care about is that I can write a program in C in about 1/4 the time I can do it in ASM. Granted, the ASM program will generally run 4 times faster (or better, some times as much as 10 times faster) and have about 50% smaller memory footprint, but that doesn't have an impact on the company's bottom line. Being able to get me off the current project and onto a new one does. The biggest drawback to ASM is, IMHO, the amount of time it takes to find a bug. Things like local variables and variable scope don't exist in ASM; EVERYTHING is a global variable. That means that you can end up with some nasty, NASTY memory management issues. |
| ||||
Quote:
|
| ||||
Quote:
The previous post was elucidating, and a good tale of ASM from a 1st hand perspective. I belive your opinion of compiler optimisations sheds some light on the usual 'coding in assembler is obsolete because modern compilers produce as optimised code as the average ASM programer' argument. However going back to the point illustrated by the quote above, its comparing apples to oranges to say that because it has no 'logical layer' akin to the one that has to be covered before you can feel 'at home' with an OOP language or another high level dev tool that asm is quicker to learn. We must not get trapped into arguing over terminology. When I speak of learning a [formal computer]language I do not consider knowing the set of reserved words or instructions sufficient. I mean the point where the knowledge aquired permits the user to write apt solutions to problems which are well defined and perhaps at some reasonable rate correcting a reasonable amount of errors as he goes along. I think you have to agree it would take more than a couple of weeks for a learner to have got his head around the intricacies and idiosynchracies of the particular architecture he was working on before he had actually mastered the use of a particular ASM. Then again my experience of ASM is v. small. I am arriving at this conclusion from fundamental understanding of Computer Science rather than personal findings. It would be great to get your thoughts on this.
__________________ |
| ||||
Quote:
![]() For most code written by your average programmer, modern optimizing compilers can do a pretty good job, and they are steadily improving. Believe it or not, I have actually learned a couple of tricks from disassembling the code produced by compilers. The thing is, a compiler can only produce optimizations at the local level. It doesn't have the big picture about what problem the application is trying to solve, and so misses things that a good programmer will be able to do because he has the totality of the solution in his mind. Quote:
![]() Quote:
![]() |
| ||||
"It doesn't have the big picture about what problem the application is trying to solve, and so misses things that a good programmer will be able to do because he has the totality of the solution in his mind" - Precisely. In other words . . .Whaddahya know ? A compiler is not intelligent, it is only a program! Funny how many people don't get this. . . - oh yeah I forgot - they are not programmers. (Although paradoxically it is programmers who are making compilers better- and writing themselves out of a job in the process ![]() Computers do not yet build themselves. . . that comes later! ![]()
__________________ Searched near & far across networked lands for a sig. that would do. I searched thorough, & wide, for a signature just right, I explored far & wide, blocked by lulling tide, all I found was you. Needless to impart, I want my money back... Last edited by DimViesel; 3rd June, 2003 at 01:57 AM. |
| ||||
Do you have any sites to start learning Pascal then? It sounds very interesting.. I don't have any experience in programming.. I started learning html and that kind of thing..but thats not even close to the same.. I'm looking to learn how to program and this sounds like it might be a good start.
__________________ |
| ||||
I'm learning ASM this and the next semester. We haven't come very far yet though, but it is very interesting so far. Making arrays, copying them, writing to the monitor, moving stuff around in mem and registers etc. Well, all basic stuff. But I'm sure that will change soon... oh, and I'm doing C++ too now. Copy constructors, operator overloading, and next week inheritance and then later on polymorphy. Fun, fun, fun! ![]() Last semester was more basic though. Like with everything else new.
__________________ |
| ||||
Today we wrote ASM "drivers" for an IO card on the SBC. However, the drivers only handled 8 LED's and 8 DIP switches. We're writing procedures with input parameters and return parameters now (You know, always return in AL/AX/EAX for Byte, word and double word) etc. ![]()
__________________ |
| |||
Nearly as much fun as passing parameters on the stack... It's more fun when you start having to deal with more interesting examples, honest!
__________________ Any views, thoughts and opinions are entirely my own. They don't necessarily represent those of my employer (BlackBerry). |
| ||||
Quote:
![]() But alas we have to start with the basics.. and PUSH'ing parameters onto the stack is one of them. ![]()
__________________ |
| ||||
This week we wrote ASM drivers for a PPI in mode 0. (3 in/out parallel ports, A, B and C). A simple driver, but still a bit more of a challenge than the previous assignments. In C++ we are through to templates atm. Last few weeks were inheritance and polymorphism...
__________________ |
| |||
Assembly is a technicians/engineers language. Program may have more lines of code but it runs faster. Useful in repair/testing, kinda like making a dead frog's legs move with an electric current. Everything has it's use. No good or bad.
__________________ |
| ||||
Discovered another one of those 'screwball' compiler optimizations that I love today.... Consider a class in C++. You write the declaration (.h) and the implementation (.cpp). Now, some functions in the implementation are very simply one liners, so you go ahead and write the implementation as part of the definition. As an example, you do the following in the header file: int Class::Version() {return DEFINED_VERSION;} So far, so good. This compiles and everything seems hunky-dory. The problem here lies in the fact that many optimizing compilers will take this implementation and, because it is defined in the header file, is a simple one-liner, and is returning a constant, instead of compiling the call-return sequence that would be used for a regular function, this call gets compiled into a hard constant in the final application. So far, so good. At some later point you decide that this class is usefull enough to make into a DLL, so that you don't have to include this code in every app that uses it. Since the version checking call above is compiled as a hard constant in the app, you can end up using a dll with a version other than that what you are checking for and NOT KNOW IT! The only way to solve this problem is to take the one-liner out of the header and put it into the implementation, so that it is part of the dll and the link library. I encountered this little gem today and spent the better part of 2 hours trying to figure out what was going on. It was only when I looked at the assembly output of the compiler that I realized what had happened. The nasty part about this is that when I ran the code in debug mode, everything worked right. That is because, generally, when you compile an application in debug mode, all optimizations are disabled. Just thought that you guys might find this real world example of how compilers can sometimes screw you to be helpful. |
| ||||
It was the Microsoft Visual C++ 6 compiler. I've been told that the Borland Turbo C compiler does it as well. It's actually a pretty good trick for optimization which normally works pretty well. The only reason I even discovered it is because I was tracking another problem in some code that someone else wrote and stumbled across this little gem in the process. As a matter of coding style, <I> would NEVER write code this way, but it is a fairly common practice. |
![]() |
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
Thread Tools | |
Rate This Thread | |
| |
![]() | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
80x86 Assembly Trouble. | DigitalKnight | Programming and Assembly Language | 10 | 23rd October, 2004 02:33 PM |
Program? | Microgers87 | General Hardware Discussion | 4 | 27th August, 2003 03:53 PM |
Need program for C++ | Allan | Programming and Assembly Language | 1 | 19th April, 2003 05:37 PM |
The Assembly Language | Garfield | Random Nonsense! | 16 | 7th August, 2002 09:24 PM |
Assembly Programmers | Garfield | Programming and Assembly Language | 13 | 29th June, 2002 02:37 AM |