maemo.org - Talk

maemo.org - Talk (https://talk.maemo.org/index.php)
-   Development (https://talk.maemo.org/forumdisplay.php?f=13)
-   -   [ASSEMBLER] How easy is it to get started asm coding on Maemo5? (https://talk.maemo.org/showthread.php?t=56016)

S0urcerr0r 2010-06-12 19:50

[ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
Is it easy to get started coding assembler for the N900?

is there anything that needs to be taken in consideration when coding assembler for Maemo5 (...full hardware access? backgroundtasks? other conflicts?)

which tools is most suited for assembler (developer environments, etc)?

Joorin 2010-06-12 20:02

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
I'd say that it's just as easy to use assembler on the N900 as on any stationary computer. Read up on ARM assembler and off you go, nothing special at all.

Out of curiosity, what would you want to create that's not possible in C? C with some inline assembler is a nice mix in my experience. Modern compilers are very good at optimization if this is the issue.

RolePlayGame 2010-06-12 20:13

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
Quote:

Originally Posted by Joorin (Post 712414)
I'd say that it's just as easy to use assembler on the N900 as on any stationary computer. Read up on ARM assembler and off you go, nothing special at all.

Out of curiosity, what would you want to create that's not possible in C? C with some inline assembler is a nice mix in my experience. Modern compilers are very good at optimization if this is the issue.

Totally agree, assembler "good old times" stopped years ago.
But I think he wants direct access to hardware internals-acceleration, am I wrong?
The language is not the problem. The drivers are the problem.

Optln 2010-06-12 20:40

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
I might be wrong but I think you can't access NEON features with C compilers and you need to use assembly for them. It provides great acceleration in matrix/vector calculations.

Joorin 2010-06-12 20:47

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
Quote:

Originally Posted by Optln (Post 712462)
I might be wrong but I think you can't access NEON features with C compilers and you need to use assembly for them. It provides great acceleration in matrix/vector calculations.

So, inline assembler in a C program then.

And, I might be wrong but, the compiler generates assembler that is assembled into object code so arguing that the compiler can't do something comes across as a bit off target.

S0urcerr0r 2010-06-13 00:14

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
im very inexperienced.

ive only coded a little asm on x86, and a little computer each student had to build at school 10 years ago (based on Z80+RAM chips if i remember correctly) - that was supposed to control a matrix printer.

...anyway...

yes, i was meaning everything in general, incl. hardware internals acceleration.

there are only 2 reasons i want to use assembler.

1. Speed - i rather sacrifice compatibility in exchange for speed when coding for the N900 - why i needed to know if the OS makes some restrictions thats good to be aware of.

2. Reverse Engineering - if i get much more experienced, i want to take a look at the PowerVR driver (and some other drivers) to see if theres a reason that VSync dont work as it should on the N900. by comparing the N900 SGX driver to other phones SGX driver with the same chipset (Palm Pre, Motorola Droid, Iphone 3GS, etc) there may be some way to hack the driver to get better a better framebuffer in RAM, and activating VSync ...for that i will need alot of experience and find the Code that handles transfers to the framebuffer - and somehow force vsync, instead of realtime rendering.

also reverse-engineering can be good to optimize the most hogging parts of the kernel and system background tasks.

EDIT: PS. with reverse engineering i will probably need a disassembler to be able to understand the machine code, but i guess such already exists


but i need to get started somewhere and i know its a far way to go if i want to get that good... i remember the author of ZSNES (fastest snes emu for x86) developed it as a asm project (and some c and c++) while learning assembler at the university.

Joorin 2010-06-13 08:13

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
Quote:

Originally Posted by S0urcerr0r (Post 712644)
im very inexperienced.

ive only coded a little asm on x86, and a little computer each student had to build at school 10 years ago (based on Z80+RAM chips if i remember correctly) - that was supposed to control a matrix printer.

I've also spent some time writing assembler for a Z80 processor. 1.2MHz and 16KByte of memory felt blazing at the time. ;)

Quote:

1. Speed - i rather sacrifice compatibility in exchange for speed when coding for the N900 - why i needed to know if the OS makes some restrictions thats good to be aware of.
Unless you're planning to do extensive mathematical computations, you'll have trouble hand coding anything that's faster than what the compiler can generate with somewhat sane levels of optimization. Modern compilers are very good at this and the N900 is not like the Z80 with very limited resources where you need to tweak everything.

Quote:

2. Reverse Engineering - if i get much more experienced, i want to take a look at the PowerVR driver (and some other drivers) to see if theres a reason that VSync dont work as it should on the N900. by comparing the N900 SGX driver to other phones SGX driver with the same chipset (Palm Pre, Motorola Droid, Iphone 3GS, etc) there may be some way to hack the driver to get better a better framebuffer in RAM, and activating VSync ...for that i will need alot of experience and find the Code that handles transfers to the framebuffer - and somehow force vsync, instead of realtime rendering.
There has been statements made from NOKIA about Vsync and it pretty much was summed up in "It won't happen.". If you were to find a way to make it happen, that'd be awesome.

What would there be to do to get "a better framebuffer in RAM"?

Quote:

also reverse-engineering can be good to optimize the most hogging parts of the kernel and system background tasks.
As far as I know, the kernel is open source, including patches for using the hardware in the N900. So, no need to reverse engineer anything. What would you want to make better in the kernel?

Quote:

EDIT: PS. with reverse engineering i will probably need a disassembler to be able to understand the machine code, but i guess such already exists
Yes, there are disassemblers for ARM code.

Quote:

but i need to get started somewhere and i know its a far way to go if i want to get that good... i remember the author of ZSNES (fastest snes emu for x86) developed it as a asm project (and some c and c++) while learning assembler at the university.
Happy hacking!

noipv4 2010-06-13 08:22

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
Another possible project would be to use the C6400 DSP. This DSP was top of the line a few years ago (2003), and still boasts substantial processing power to run various codecs.

www.ll.mit.edu/HPEC/agendas/proc03/powerpoints/orofino.ppt

noipv4 2011-02-08 22:20

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
To view this mail in a browser, copy
http://links.mkt2223.com/servlet/Mai...cyS0&mt=1&rt=0
into your browser.


T E X A S I N S T R U M E N T S
--------------------------------------------------------------------------

TI MAKES DSP PROGRAMMING EASY FOR ARM DEVELOPERS

C6EZFlo, C6EZRun and C6EZAccel software development tools ease DSP
programming

The free C6EZFlo, C6EZRun and C6EZAccel software development tools
simplify and accelerate DSP programming on a variety of DSPs and
DSP + ARM SoCs.
http://links.mkt2223.com/ctt?kn=41&m...cyS0&mt=1&rt=0
http://links.mkt2223.com/ctt?kn=26&m...cyS0&mt=1&rt=0
http://links.mkt2223.com/ctt?kn=43&m...cyS0&mt=1&rt=0

C6EZFlo allows developers to:
- Drag and drop connection I/O blocks to peripherals on the DSP without
needing to know DSP code, architecture or drivers
- Generate clean, optimized C code that?s easy to read, modify and
expand
http://links.mkt2223.com/ctt?kn=41&m...cyS0&mt=1&rt=0

C6EZRun enables developers to:
- Easily run ARM code on a DSP without learning DSP architecture or
changing ARM code
- Quickly partition the code between the DSP and the ARM core to
improve overall performance
- Utilize a familiar development environment to Linux(R) programmers
with a GNU Compiler Collection (GCC)-like interface, simplifying
the development experience
http://links.mkt2223.com/ctt?kn=26&m...cyS0&mt=1&rt=0

C6EZAccel allows developers to:
- Access a framework to over 130 optimized DSP kernels
- Add product differentiation without writing DSP code or learning
DSP architecture
- Leverage the DSP to run ready-to-use algorithms, enabling efficient
use of the SoC and avoiding processor upgrades
http://links.mkt2223.com/ctt?kn=43&m...cyS0&mt=1&rt=0

The tools are ideal for adding intensive digital signal processing
functionality such as:
- Digital room correction capabilities to an audio system
- People-counting capabilities to a video system
- Power measurement and analysis to a power metering system

C6EZFlo supports TI's C6000(TM) DSPs as well as DSP-based DaVinci(TM)
digital media processors. C6EZRun and C6EZAccel support Integra(TM)
DSP + ARM processors, DaVinci(TM) digital media processors and OMAP(TM)
processors.
http://links.mkt2223.com/ctt?kn=45&m...cyS0&mt=1&rt=0
http://links.mkt2223.com/ctt?kn=62&m...cyS0&mt=1&rt=0
http://links.mkt2223.com/ctt?kn=20&m...cyS0&mt=1&rt=0
http://links.mkt2223.com/ctt?kn=62&m...cyS0&mt=1&rt=0
http://links.mkt2223.com/ctt?kn=52&m...cyS0&mt=1&rt=0

C6EZRun and C6EZAccel are also available as a part of the free EZ
software development kit (EZ SDK), now supporting the C6A816x Integra
DSP + ARM processors.
http://links.mkt2223.com/ctt?kn=60&m...cyS0&mt=1&rt=0

Download the free C6EZFlo, C6EZRun and C6EZAccel software development
tools today!
http://links.mkt2223.com/ctt?kn=41&m...cyS0&mt=1&rt=0
http://links.mkt2223.com/ctt?kn=26&m...cyS0&mt=1&rt=0
http://links.mkt2223.com/ctt?kn=43&m...cyS0&mt=1&rt=0

--------------------------------------------------------------------------

The right processor. The right software. The rightresources.

--------------------------------------------------------------------------

To ensure delivery to your inbox, please add tiprime@dlep14.itg.ti.com
to your address book or safe sender list.

(C)Copyright 2011 Texas Instruments Incorporated, 12500 TI Blvd, Dallas, TX 75243. Read TI's
Privacy Policy:
http://links.mkt2223.com/ctt?kn=115&...jMxMjcyS0&rt=0

gerdich 2011-02-08 22:31

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
"TI MAKES DSP PROGRAMMING EASY FOR ARM DEVELOPERS"

And what about THUMBEE?

teroyk 2012-09-18 14:48

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
It is very easy.
- Just install Binutils in N900
- Open texteditor (I use nano) and write code
- Assemble with as-command
- Link with ld-command
- set execute rights with chmod
- run (remember put ./ before your program name)

But I have question why
mov r7,#4
looks with hexeditor like this:
hex 0407A0E3=bin 0000 0100 0000 0111 1010 0000 1110 0001
but If I look ARM instructions manual, it should look like
1111 0i10 0100 imm4 0imm3 Rd imm8
or
1111 0i00 010s 1111 0imm3 Rd imm8?

And why there is in executable file 74 bytes before first command come? And lot bytes after commands and data?

reinob 2012-09-18 20:20

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
@teroyk,

Normally executable programs have a format. Linux uses ELF.

teroyk 2012-09-19 07:39

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
Quote:

Originally Posted by reinob (Post 1268696)
@teroyk,

Normally executable programs have a format. Linux uses ELF.

thanks. And I found all Linux executable information:
http://www.kernel.org/doc/man-pages/...an5/elf.5.html

reinob 2012-09-19 07:54

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
Quote:

Originally Posted by S0urcerr0r (Post 712644)
1. Speed - i rather sacrifice compatibility in exchange for speed when coding for the N900 - why i needed to know if the OS makes some restrictions thats good to be aware of.

The idea is in itself good. The problem is that the CPU on your N900 is no Z80, no 8080 and no 80286. Meaning you have a f*ckload of "features" (predictive branching, out of order execution, etc. etc. no to speak about the different instruction sets that you can use in parallel: neon, thumb, thumb2, vfp3, ...)

So there's no way a human could possibly beat a good compiler (and we have good compilers) in optimizing code.

I also used to hand-optimize my programs (mostly 286 and 486). I stopped with the first Pentium.

Quote:

2. Reverse Engineering - if i get much more experienced, i want to take a look at the PowerVR driver (and some other drivers) to see if theres a reason that VSync dont work as it should on the N900. by comparing the N900 SGX driver to other phones SGX driver with the same chipset (Palm Pre, Motorola Droid, Iphone 3GS, etc) there may be some way to hack the driver to get better a better framebuffer in RAM, and activating VSync ...for that i will need alot of experience and find the Code that handles transfers to the framebuffer - and somehow force vsync, instead of realtime rendering.
Good luck. I don't see why VSync is necessary. But again, I don't see why one of the most important features of a modern smartphone has to be the "smooth" transitions. It's just a damned phone/computer. You use it (work with it), and then you lock the screen or turn it off. There's no point (IMHO) in just staring at your N900 while you swipe left and right. It's enough that most so-called "hands-on" tests on the Internet do exactly just that. I find it painful/shameful to watch. Anyway..

Quote:

also reverse-engineering can be good to optimize the most hogging parts of the kernel and system background tasks.

EDIT: PS. with reverse engineering i will probably need a disassembler to be able to understand the machine code, but i guess such already exists
As noted already in this thread, the kernel is open source. It's generally (but not always) preferable to review/patch source code compared to reviewing/patching executable code. There are notable exceptions (for some time I always applied a binary patch to all my kernels, as well as to pine. But that's off-topic here).

Most (all?) services and daemons running in your N900 are also open-source.

Quote:

but i need to get started somewhere and i know its a far way to go if i want to get that good... i remember the author of ZSNES (fastest snes emu for x86) developed it as a asm project (and some c and c++) while learning assembler at the university.
You can do lots of things in assembler, but think of it as a language and you'll feel more comfortable with it. Otherwise you'll assume that using assembler you have direct access to hardware (which is wrong) and that your code will run faster (which is also wrong).

freemangordon 2012-09-19 08:14

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
+1

I also stopped doing hand-optimized assembler code with 486. With one exception - stupid M$ compiler did't optimize well for Duron's pipelines, so I hand-optimized some mmx code (video decoder), but that was just an exception.

Using assembler makes absolutely no sense for general programming, especially now we have gcc 4.7.X. You may use assembler for some specific piece of code, but still, you won't beat compiler if you don't have a sh*tload of emulators, so you can trace pipelines, branches, caches, instruction dependencies, whatnot.

@Reinob - "smooth transitions" falls in the same category as "ecosystem" if you ask me :D

raandoom 2012-09-19 08:45

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
S0urcerr0r, take a look at asm source of my elf:
https://dl.dropbox.com/u/28532483/lo...mpress.v.1.1.s
And the same, but some updated at C:
https://dl.dropbox.com/u/28532483/lo...ress.v.1.2.cpp
Asm source can be compiled with:
Code:

gcc logo_compress.v.1.1.s -o logo_compress.elf
I hope it will help you :)

wook_sf 2012-09-19 09:44

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
ELF is actually ARMs executable and linkable file.
it's not just for linux, elfs can be loaded with symbian and with WinCE oses too.
FASMARM is one great assembler and it's opesource so it can be tweaked up too.
i think that writing includes for both maemo5 and maemo6 shouldn't be so hard.
i will try to do some contribution for harmattan at least
+1 for this thread

reinob 2012-09-19 10:33

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
@wook_sf,

ELF existed before ARM. It's used by most Linux/Unix operating systems, and is architecture-independent, meaning it can be used for x86, ARM, or whatever. Originally it was used for x86.

AFAIK Symbian used an ELF-like (or ELF-derived) format, but not quite ELF.

I'm not aware of any Windows (CE or not) versions using ELF natively. Windows (including CE) uses PE (portable executable).

wook_sf 2012-09-19 10:44

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
Quote:

Originally Posted by reinob (Post 1268950)
@wook_sf,

ELF existed before ARM. It's used by most Linux/Unix operating systems, and is architecture-independent, meaning it can be used for x86, ARM, or whatever. Originally it was used for x86.

AFAIK Symbian used an ELF-like (or ELF-derived) format, but not quite ELF.

I'm not aware of any Windows (CE or not) versions using ELF natively. Windows (including CE) uses PE (portable executable).

well, pe for winCE have ELF header same as PE for win32 have MZ (dos header)
ELF is officially supported by arm and that format is used for this processor.
there was one really really good book about arm asm that explains lot about assembly, in my opinion far better for students than any other book i've read :D and i will try to link it here.

about symbian - i wasn't talking about EPOC, but about ELF ;)
basicly, elfs should be runnable on every arm machine :)

reinob 2012-09-19 11:17

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
@wook_sf,

OK, this is getting off-topic, but:

PE does not and cannot have an ELF header. PE is a different format than ELF.

An ARM processor can run ARM instructions. The format of the executable file is of no concern for the processor, but for the operating system (dynamic linker), which needs to be able to identify the code sections so that they can be executed by the processor.

Symbian uses the E32Image format. During compilation with the standard tools a PE or ELF executable is generated. This executable must be then converted to E32Image so that Symbian can use it.
(see http://www.antonypranata.com/node/9).

As for "ELFs should be runnable on every arm machine". The statement is obviously true, as long as the operating system can make sense of (use the) ELF format.

That's like saying "ZIPs should be extractable on every ARM machine". Yes, but you need the unzip tool for that machine. Same as x86, mips or any other CPU architecture.

Now we can go back on-topic :)
.. unless, that is, you have some references supporting your assertions.. :)

wook_sf 2012-09-19 12:25

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
you're not getting what i am trying to tell you.
zip format has nothing to do with instructions.
i also did expressed something in wrong sense, but i'll try to explain it later

teroyk 2012-09-22 07:17

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
Quote:

Originally Posted by reinob (Post 1268870)
So there's no way a human could possibly beat a good compiler (and we have good compilers) in optimizing code.

I disagree.
My information source is:
http://www.shervinemami.info/armAssembly.html

teroyk 2012-09-22 07:20

Re: [ASSEMBLER] How easy is it to get started asm coding on Maemo5?
 
Quote:

Originally Posted by wook_sf (Post 1268937)
FASMARM is one great assembler and it's opesource so it can be tweaked up too.

Is there version for N900?


All times are GMT. The time now is 17:33.

vBulletin® Version 3.8.8