maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   General (https://talk.maemo.org/forumdisplay.php?f=7)
-   -   Learn Programming - asm on arm (https://talk.maemo.org/showthread.php?t=27056)

CVBruce 2009-02-23 01:10

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.

Matan 2009-02-23 05:06

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.

pycage 2009-02-23 07:22

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.

benohit 2009-02-23 08:57

Re: Learn Programming - asm on arm
 
Quote:

Originally Posted by CVBruce (Post 266376)
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!

Don't worry !
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.

jethro.itt 2009-02-23 09:01

Re: Learn Programming - asm on arm
 
Quote:

Originally Posted by Matan (Post 266432)
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.

And here it is: The ARM Architecture Reference Manual. It's not a tutorial but a comprehensive overview of the "ideal" ARM architecture. Real ARM CPUs amend this text with their own specifications. See http://www.arm.com for details.

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:
  • NXP LPC2103 ARM7TDMI-based microcontroller
  • About 60 MHz (58.9824 MHz actually)
  • 32 kB Flash memory
  • 8 kB RAM
  • Monochrome 240x64 graphical user interface
  • USB and serial port for communication with automation systems
  • Several time-sensitive peripherals to monitor and control
  • Requirement: Sub-millisecond response time to fault conditions
  • Requirement: Sub-microsecond response time to external pulses
  • About 13000 lines of code
  • ... of which about 500 lines is written in assembly code, rest is in C.

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.

benohit 2009-02-23 10:16

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...

lardman 2009-02-23 12:36

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.

twaelti 2009-02-23 15:56

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 :-)

jolouis 2009-02-23 15:57

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.

lcuk 2009-02-23 16:40

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?


All times are GMT. The time now is 20:53.

vBulletin® Version 3.8.8