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)

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


All times are GMT. The time now is 15:47.

vBulletin® Version 3.8.8