![]() |
Learn Programming - asm on arm
Hello all,
I hope there are some people who can advise me : I would want to learn basic programming, beginning with ASM first. then, i would learn C, then a little C++ stuff, and then perl and python. But i need these things : - a guide of ARM "assembleur" - tools for programming in asm code on my n810 THanks in advance ! |
Re: Learn Programming - asm on arm
Assembler isn't something that can be called basic ;)
|
Re: Learn Programming - asm on arm
Quote:
|
Re: Learn Programming - asm on arm
Quote:
Besides being beginner-friendly, you don't need to compile when using Python, so you can instantly try out your code. You can also open a command-line interface, so that you can try out individual commands. |
Re: Learn Programming - asm on arm - which tools to install ?
Quote:
I know python is very interesting. I know how to do : - algorithmic - shell scripting - basic to turbo pascal - php But since i use computers (since 1992), i don't want to debate about this, but, i'm look for performance you know. I prefer e17 to gnome+compiz I prefer mp3blaster to xmms I prefer vim to gedit I want to know how things work, and to be able to use my n810 for real tasks, than to wait for a web page to be loaded on zimbra for example, or a map to be loaded in gmaps too. Python is used in every tools in ubuntu for update-manager and all things, but i'm the man to launch "apt-get update ; apt-get dist-upgrade". I prefer scripting a daemon instead of using a "good-looking" app that takes some time to launch its scripts, to launch the graphical stuff, update the information in its window, wait for a user interaction, etc... So please just let me know about asm on arm stuff please ! i will then be a forever-smiling man ! Why not programming in python, but in months... ;-) |
Re: Learn Programming - asm on arm
Well, I'm not a very good programmer, but a few years ago I looked into this free ebook on PC asm, I know it isn't ARM asm, but it could be a useful start. I just happened upon this thread so I don't happen to have any useful links to free books for ARM assembly, but I'd imagine a lot of the same principles still apply and can be utilized.
Here is the link to the aforementioned book: http://www.drpaulcarter.com/pcasm/ Hope it helps and best of luck! |
Re: Learn Programming - asm on arm - which tools to install ?
Quote:
Also, after doing quite some assembly myself (admittedly not ARM) I must say it's far from what assembly was in 1992, mostly for two reasons: 1) The operating system. With DOS it was dead easy, nobody cared what your assembly code did, you had simple BIOS routines to interact with the user and that was it. That's no longer the case. Just interacting with the OS to copy a file or read a keypress can be hell. 2) You need to grow a head of the size of a basketball. Seriously. With multiple cores, pipelines, branch prediction, etc, it becomes more and more sorcery to create fast code by hand. Less instructions do no longer mean quicker execution. I had cases where just changing the order of instructions meant a difference of ~30% in speed (!). |
Re: Learn Programming - asm on arm
Learn C, the execution-speed:writing-speed ratio is very good, only very occasionally will you need to resort to raw ASM. I'd skip Python completely if you want speed (plus C is a useful thing to know).
ASM is a pita to use basically, and I only resort to it if I really have to (not very often thankfully :)). To learn it, I scoured the web, mainly looking at existing ARM ASM code (the ARM Linux site has some useful info too: http://www.arm.linux.org.uk/developer/) and also eventually bought a book (ARM Assembly Language - an introduction by J.R. Gibson), however I've not done much ASM since then, and therefore haven't really read the book, so can't actually recommend it in any way other than saying that it's the one that looked best to me at the time :) |
Re: Learn Programming - asm on arm
You can try Vala for speed - it is similar to Python and C#, but translates to C and compiles to native, so the execution speed is much better.
|
Re: Learn Programming - asm on arm
Well this is really pretty easy. Let's see. First you need to stop off at the company that makes the CPU. You should be able to down load a PDF spec that will outline all of the instructions that your particular variant of the ARM processor can execute. Then you need to determine which assembler you are going to use. Probably something from GNU, so you need to get the manual for that. That manual will have all of the directives and formats used by the assemble to translate assembler into machine language. Next you will need to read the man pages for maemo. basically section 2 and 3. That is about it.
As to a book, all that would be in the book would be the machine instructions, addressing formats, etc.; all of which is in the spec sheet from the cpu manufacturer. Assembler directives, etc. are from your assembler vendor. OS callable routines are in the maemo man pages. The book would add little except sample programs. The previous comment about growing a big head is right on. In assemble you must keep in your mind the contents of all registers and status flags, and know how each op code will effect them. Me, I would follow Atilla77's suggestion of python, with a few optimized routines. I read a report a number of years ago that said it takes about 350 lines of assembler to do the same job as about 150 lines of C. Python wasn't mentioned, but I'm pretty sure that it would be well below 100. I've done assembler programming as a job. I've been programming since 1969. My shortest assembler program was a CICS transaction that was 3 lines of code. It was used for a number of years by my employer. Avoid assembler programming! |
Re: Learn Programming - asm on arm
I also agree with lardman. C is a very good compromise between speed of development and speed of execution.
|
Re: Learn Programming - asm on arm
C is no compromise. If you never programmed in assembly (or C, C++, python, perl) then your assembly code is not going to be faster than your C code for anything more useful then a countdown loop, for at least a few years. By then, even ARM might be superscalar and out of order, so you will need to start optimizing your super fast code all over again.
If you do want to learn ARM assembly (it is useful for a lot of things, just not for speed), you need the ARM ARM, since that is the standard text. |
Re: Learn Programming - asm on arm
Speed is not a matter of choosing a certain language, speed is a matter of choosing the right algorithms.
Apart from that, writing whole programs in assembler is not recommended on modern operating systems because you would have to program against a C-level interface. But nothing (except for portability) speaks against writing small functions (e.g. for image processing) in assembler. But don't get the illusion that asm is faster than C. Most C-compilers nowadays produce optimized asm code that is faster than anything you would write yourself in asm. I'd also suggest to skip C++ and learn Java instead. C++ is (or should be) a dead language (although many people don't want to believe so) and not a good choice for object-oriented programming. In other words, C++ is a mess and mostly incompatible with itself. Python OTOH is a really nice and comfortable object-oriented language. C is tiny, easy to learn, but it's not really comfortable for writing big programs. |
Re: Learn Programming - asm on arm
Quote:
I want to learn assembler, in order to understand how the machine works, then indeed, to make a little C stuff ! it's the main goal. I know and think that 80% of programmers today don't think about optimisating their code. I'm one of them in PHP. So before reading a book that mentioned "garbage collector", i didn't had any idea about flushing caches for example. I'm just, again, looking for a guide af ARM assembler, with exercices for example, that i could do on my n810. Because i think that it will be obsolete in 4 years, and that a 1998's powerbook g3 laptop isn't yet, thanks to linux. So why not learn java indeed. But in this order : ASM => C => Perl => java => UML 2 => XML => PHP5 C++ will be necessary to understand linux code. Not to create, but to understand in debug. Learning these languages will make me code in different manners. And optimize algorithms. I ordered a book to learn object oriented programmation. |
Re: Learn Programming - asm on arm
Quote:
Learning ARM assembly on Linux is very time consuming. The OS is stepping on your fingers at every opportunity. You would make better use of your time to learn ARM assembly on a simple ARM7TDMI-based development board, such as this one (33 euros, also see prices for other boards). They cost only tens of dollars and run your program without the burden of an operating system. After you get the hang of assembly programming, you'll see better where the extra effort is beneficial. Most any user-facing software can be written in mixed Python/C/Asm these days. EDIT: Here's a real-world scenario I'm currently working on. Maybe this will illustrate how relevant assembly code is on modern CPU architectures:
So even in a deeply embedded time-critical application such as this one, assembly code accounts for less than 4% of total lines of code. A desktop- or pocket-class machine has even less use for assembly optimization. |
Re: Learn Programming - asm on arm
Thanks to all of you !
I also found this : http://linux.onarm.com/ But i still don't know which tools to install on my n810 to write/run ASM and C code... |
Re: Learn Programming - asm on arm
You need to install GCC - there's a thread somewhere on the board about on-board development, follow those instructions.
|
Re: Learn Programming - asm on arm
No one around of the old C64 scene? I vaguely remember some ASM from back then, for Scrolltexts, Music and Sprite-Animations...
Why anyone would like to start with ASM is way beyond me, however :-) |
Re: Learn Programming - asm on arm
One final vote for C, coming from somebody's who's been along a similar learning path. I gleaned most of my programming (at least the modern useful stuff) from PHP, but started getting into doing embedded device development and found that PHP had all the capabilities, but was WAY too slow and resource-intensive. Started looking into C, and found it amazingly easy to learn because the syntax and concepts are almost exactly the same. (to the point where half of my PHP code could have almost been copied and pasted, compiled and it ran in C sort of thing). The real trick to learning C from a PHP point of view is just to get the whole memory management thing figured out, which really isn't as hard as people make it sound... you just need to make sure you plan and pay a lot of attention when you create variables that you remember to free them later, that's all. If you start getting into UIs and things it can be a little more complex, but for back-end/daemon type stuff it's not hard at all.
|
Re: Learn Programming - asm on arm
let me backup lardman's assertion about c.
I use it every day onboard the device and writing in it gives me 2 very important things after compilation: (1) very close to asm performance (2) code reuse, the same things I write in c are recompilable on arm and x86 that simply is not possible with asm. Also, if whilst learning all about c you NEED an algorithm coding in asm (just like pascal) you can do inline asm directly with your c file and GCC will magically make it for you! You should be well past your "why" things work, just translate your pascal thinking slightly and you end up with c code. by the way, am I the only one who can smell something? |
Re: Learn Programming - asm on arm
In short:
Quote:
|
Re: Learn Programming - asm on arm
Quote:
|
Re: Learn Programming - asm on arm
...I want to learn assembler, in order to understand how the machine works, then indeed, to make a little C stuff ! it's the main goal...
Some well commented assembler source code will provide you with much of what you want to know. Believe it or not, before I could afford a computer, I used to write Z80 assembler programs on paper. I made a little chart showing all of the registers, then I would manually execute the program using pencil and eraser. When I took my assembler class, the first programs we wrote were in machine language. All input was via front panel switches, output was by front panel lights. We would load the program into memory one instruction at a time, and then step to the next memory location. You only need to do a little of this to get the idea of how a cpu works. |
Re: Learn Programming - asm on arm
Quote:
Your quote on C is exactly right. C was designed to be a language for expert programmers. Unfortunately most people think they are experts. I have looked at a great deal of C code over my career, and I have to say that there is more crap out there then you would believe, including the code I wrote. |
Re: Learn Programming - asm on arm
Quote:
|
Re: Learn Programming - asm on arm
Quote:
|
Re: Learn Programming - asm on arm
Quote:
|
Re: Learn Programming - asm on arm
Quote:
|
Re: Learn Programming - asm on arm
I've programmed assembler on the ZX81 (Z80), C64 (6502/6510), Amiga (68000) (those for fun), for the 68HC11, PIC (16C74), and TI DSPs (c50) (for pay) and PPC (for school). I've spent a lot of time coding C for fun, school and work, too. And a smattering of other languages as well, from FORTH to Lisp.
Now? I write in MATLAB, and am learning Python. There is a golden rule: the right tool for the right job. Don't use ASM "just because". If you want to learn about the internals of CPUs, be aware that architectures are all different, and evolve. My 6502 assembler didn't prepare me for RISC, or the Harvard architecture of the PIC chips. What you learn for ARM today can't easily be carried over to i686, or the cell processor or DSP chips, or whatever the chip designers are dreaming of today. VHDL might be more useful! If your goal is to learn about to-the-metal computer programming, I recommend getting yourself an Arduino or maybe a Parallax Propeller kit. I've got myself the former and they're great fun. Programmable with very little ramp-up in C, and ASM if you dig a little. Dead easy to interface. If you want to write applications, start with Python, until you hit a performance or capability bottleneck. Then switch to C++ or C. If you want to learn about OS design, hit the books. Then learn C. Then look at the Linux source. Read more books. OS design is very complex and academic these days, and there are many difficult algorithms at play. |
All times are GMT. The time now is 20:53. |
vBulletin® Version 3.8.8