Assembly Code


61 posts   Page 3 of 3   1, 2, 3
by tufty » Tue May 22, 2012 11:15 am
antiloquax wrote:It's interesting to read that the ARM chip apparently can't do division!

That's not the case for all ARM processors. ARMv7-R and ARMv7-M can do unsigned and signed division. However, the ARMv6 core in the Pi can't (neither can the ARMv7-A cores used by Apple's iDevices, so at least we're in trendy company).

Still, if you really feel the need to do division in assembler (bearing in mind what rurwin said), this is a pretty good implementation, and a pretty good read for assembler beginners to boot.

Simon
Posts: 1330
Joined: Sun Sep 11, 2011 2:32 pm
by andyl » Tue May 22, 2012 11:45 am
[quote="antiloquax"]My feeling about Assembly Code is that it's incredibly helpful to get an insight into exactly what is happening at the lower level when we use a loop (or whatever) in a higher level language. [/q]

Of course get a language at a high enough level of abstraction and it isn't helpful at all to see what is happening at a low level. For example if you are executing a SQL query, or a piece of Prolog.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by DexOS » Tue May 22, 2012 11:55 am
Assembly coders that program fully in ASM, are called "crazy" in the programming world.
See more "crazy" people here:
http://www.youtube.com/watch?v=jULUGHJCCj4

When i coded my OS for the x86, in 2002 and coded a games console type GUI in stead of the normal windows GUI, everyone said, thats not a real gui, when are you going to make a real GUI, like windows.
When i said in 5-10 years most GUI will be like this And you would run one program at a time, in full screen, they said your "crazy".
Now see todays GUI's, like the i-pad and the new win8 who was "crazy" ?.
You can read about the "crazy" people here:
http://www.techradar.com/news/software/ ... ems-934484
Batteries not included, Some assembly required.
User avatar
Posts: 851
Joined: Wed May 16, 2012 6:32 pm
by AlArenal » Tue May 22, 2012 2:05 pm
DexOS wrote:Now see todays GUI's, like the i-pad and the new win8 who was "crazy" ?.


I consider Windows 8 "crazy" as it tries to force people to work on their pc like it's a tablet which is just not.

Regarding assembler, I never did too much with it. Did some x86 ages ago but every time I read articles about other architectures such as MIPS, SPARC, DEC Alpha or ARM I felt like crying with all those registers they had and I didn't...

I think of coding and using certain languages for certain jobs like this: The higher level the problem the higher level the language. That's just because time is money and a powerful API and programming language that has a lot of action per code line will save you huge amounts of time and money.

Of course you won't probably get the fastest and leanest program possible, but in most cases on pcs it make more sense economically to go for better hardware (or also use the GPUs) instead of putting man years into micro optimizations or implementations in something that gives you more control.

You wouldn't recommend SAP coding their software in Assembler, would you?

Within kernel space assembler has its uses, or even when doing optimizatians for very hungry applications such as games or video editing, though even those might get written in some higher level language like C (think of OpenCL) these days. But of course there is a myriad of microcontrollers out there with very very limited resources and there assembler is almost inevitable, because development costs get divided by the number of pieces you sell and if you can save a few cents on a MCU and sell thousands or millions of pieces you will probably save more money than by using the faster and cheaper embedded C code on the more powerful but more expensive MCU.

Does knowing about assembler a web developer any better? I doubt it. I hardly ever think of assembler. But knowing about how a processor works doesn't hurt either.
Posts: 141
Joined: Sun Feb 26, 2012 6:58 pm
Location: Germany
by andyl » Tue May 22, 2012 2:49 pm
AlArenal wrote:
DexOS wrote:Now see todays GUI's, like the i-pad and the new win8 who was "crazy" ?.


I consider Windows 8 "crazy" as it tries to force people to work on their pc like it's a tablet which is just not.

Regarding assembler, I never did too much with it. Did some x86 ages ago but every time I read articles about other architectures such as MIPS, SPARC, DEC Alpha or ARM I felt like crying with all those registers they had and I didn't...


Although x86 has a smallish number of registers (in comparison to something like Sparc) it still had a reasonable number of registers. The segmentation and addressing modes made things less clear than they should be though. I remember the Transputer which was a pure stack based architecture I believe - you didn't have any registers.
Posts: 265
Joined: Tue Jan 10, 2012 11:05 am
by antiloquax » Tue May 22, 2012 4:58 pm
Today I've been looking at the functions chapter of "Programming from the ground up". It really helped me to understand "the stack" - something I was rather unclear about!
If I have time later I am going to have a go at re-writing it for ARM.
I also want to get my head around using assembly code functions within C. I will check out the sites people have mentioned above.
mark
Posts: 406
Joined: Sun Nov 20, 2011 11:37 am
by hippy » Tue May 22, 2012 7:11 pm
AlArenal wrote:But of course there is a myriad of microcontrollers out there with very very limited resources and there assembler is almost inevitable

For Microchip PICmicro I've always favoured B Knudsen Data C compilers because they generate very tight assembly code and allow C to be used as a very flexible macro assembler with the ease of use and compactness of C. A quick check that the generated assembler is as efficient as hoped for where it needs to be and you're on the way again. I suppose that's assembly programming in C without using #asm, a kind of hybrid approach.
Posts: 757
Joined: Fri Sep 09, 2011 10:34 pm
by rurwin » Tue May 22, 2012 8:15 pm
Another alternative is something like Micro Autocode. My one claim to fame; Eric Raymond deigned to include it on his retro computer languages page. It needs a serious rewriting, but it has been used for one real-world project.
User avatar
Forum Moderator
Forum Moderator
Posts: 2890
Joined: Mon Jan 09, 2012 3:16 pm
by hippy » Tue May 22, 2012 11:24 pm
rurwin wrote:Micro Autocode


That was a flashback. The first computing book I picked up in the school library was on Autocode.
Posts: 757
Joined: Fri Sep 09, 2011 10:34 pm
by kdakin » Sun Jun 10, 2012 4:07 pm
See also the post under Other Languages re: Mono (C#) and IBM/390 Assembler Language.
http://www.raspberrypi.org/phpBB3/viewtopic.php?f=34&t=8037
Posts: 54
Joined: Sat Mar 24, 2012 7:20 am
by kdakin » Sun Jun 10, 2012 4:19 pm
AlArenal wrote:.

"....Does knowing about assembler a web developer any better? I doubt it. I hardly ever think of assembler. But knowing about how a processor works doesn't hurt either.[/quote]"

Knowing any subject in-depth makes a developer better. Can you even consider a Formula 1 engineer not caring about how efficient his engine is running? The programming community has ignored efficiency for too many years now and lost the gains from hardware enhancements. Being ignorant of how something works under the hood is an excuse not an argument. How would you like your car maintenance guy at the local garage to not understand how your brakes work? Or how about the chef at your local restaurant to not understand food hygiene? Got the idea yet?
Posts: 54
Joined: Sat Mar 24, 2012 7:20 am