why use ASM anymore

GFA, ASM, STOS, ...

Moderators: simonsunnyboy, Mug UK, Zorro 2, Moderator Team

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5001
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: why use ASM anymore

Postby simonsunnyboy » Wed Mar 21, 2018 4:56 pm

C is a fancy macro assembler - and the best mix is inbetween.
Lowlevel stuffs need assembly language but noone sane (except Demo coders) really has the time left to do all our main logic stuffs in assembly language itself, just because it takes more time to develop and test.

It is less relevant for applications and apps anyway as those sit on a higher level like Dot.Net or Android or something similar.

So, no it is not obsolete but becoming more and more a specialist profession.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
metalages
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 110
Joined: Thu Jun 06, 2013 5:14 pm
Location: France
Contact:

Re: why use ASM anymore

Postby metalages » Wed Mar 21, 2018 5:33 pm


joska
Hardware Guru
Hardware Guru
Posts: 3957
Joined: Tue Oct 30, 2007 2:55 pm
Location: Florø, Norway
Contact:

Re: why use ASM anymore

Postby joska » Wed Mar 21, 2018 7:30 pm

Zamuel_a wrote:But on older computers like the Atari I prefer the 68000 assembler. It's not much different than program in C.
C: A = A + 1
ASM ADD #1,D0

C: A = B[10]
ASM MOVE 10(a0),d0


But most programs are sliiiightly more advanced than that... With very small snippets of code it is very easy to follow assembly code. Not so easy when you create the logic of a game or write a GEM application. As I said, there is a reason why high level languages exist.

True, C is a bit like assembler in the sense that in both cases you need to understand pointers. But with C you can write reusable, compact code that's easy to read in a fraction of the time you need to create the same code in assembler. The cost is this:

Zamuel_a wrote:What I mean is that in C I don't know what A = B[10] will compile too. In asm I know what I'm doing and how many cycles it takes.


...but in 99.9% of the time the implementation details does not matter, as the result is the same. It's only the remaining 0.1% where you *need* assembly. But...

Zamuel_a wrote:The only programming I do on Atari is time critical advanced stuff so I guess that's why I prefer assembler.


...this is of course where assembly really shines.

Zamuel_a wrote:If I for some reason want to create a ordinary slow text editor or something else I would do in on PC in C++ instead ;)


However, this was a particularly bad example. A text editor spends virtually all of it's time waiting for user input, only really really bad C code (or a really really bad C compiler) would be noticeably slower than hand optimized assembler in this case. In most cases the choice of algorithm has a lot more impact on speed than programming language.

Of course, in our case it doesn't matter which programming language you use, as long as you choose the one that you enjoy most. This is not work.

And yes, I program in both 68k (and a bit of Z80) and C myself. I find C fascinating, like assembly you learn new stuff all the time even though C has a lot less instructions than the 68k.
Jo Even

Firebee - Falcon060 - Milan060 - Falcon040 - MIST - Mega ST - STM - STE - Amiga 600 - Sharp MZ700 - MSX - Amstrad CPC - C64

User avatar
metalages
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 110
Joined: Thu Jun 06, 2013 5:14 pm
Location: France
Contact:

Re: why use ASM anymore

Postby metalages » Wed Mar 21, 2018 7:59 pm

Ok for 68k. On modern cpu with a modern c++ compiler it is really hard to do a better job than the compiler. Even on gpu we use high level language. Also on modern architecture code execution is not the problem. Memory access is the performance weak point. Very good presentation by Mike Acton at the cpp con about that
https://youtu.be/rX0ItVEVjHc
Last edited by metalages on Wed Mar 21, 2018 9:22 pm, edited 1 time in total.

User avatar
metalages
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 110
Joined: Thu Jun 06, 2013 5:14 pm
Location: France
Contact:

Re: why use ASM anymore

Postby metalages » Wed Mar 21, 2018 9:14 pm

Also at the CPP con 2016very good presentation perfectly in this topic :)
CppCon 2016: Jason Turner “Rich Code for Tiny Computers: A Simple Commodore 64 Game in C++17”
https://youtu.be/zBkNBP00wJE

User avatar
Frank B
Atari Super Hero
Atari Super Hero
Posts: 960
Joined: Wed Jan 04, 2006 1:28 am
Location: Boston

Re: why use ASM anymore

Postby Frank B » Thu Mar 22, 2018 8:41 am

You still need to understand assembly for reverse engineering. Very important to verify static analysis and dynamic analysis vulnerabilities in a binary.

User avatar
shoggoth
Nature
Nature
Posts: 902
Joined: Tue Aug 01, 2006 9:21 am
Location: Halmstad, Sweden
Contact:

Re: why use ASM anymore

Postby shoggoth » Thu Mar 22, 2018 1:22 pm

A screwdriver is handy for one thing, a toothbrush for another. Each tool has its place.
Ain't no space like PeP-space.

User avatar
metalages
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 110
Joined: Thu Jun 06, 2013 5:14 pm
Location: France
Contact:

Re: why use ASM anymore

Postby metalages » Thu Mar 22, 2018 3:32 pm

shoggoth wrote:A screwdriver is handy for one thing, a toothbrush for another. Each tool has its place.


Agree :)

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5001
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: why use ASM anymore

Postby simonsunnyboy » Thu Mar 22, 2018 4:59 pm

metalages wrote:
simonsunnyboy wrote:C is a fancy macro assembler - and the best mix is inbetween.
Like This ? :)
https://github.com/gibs75/demOS/blob/ma ... N/ARJDEP.C


No certainly not in this fashion. More the way that it automatically updates your indirect addressing right when using structs etc.

On a modern platform (non-m68k) C compilers will optimize better and produce tighter (and more unreadable) assembler code than a human coder would do.

So the smaller and the more limited a platform is, the more assembler is necessary.
Spekaing for Ataris, if you want to get the job done and finished and 100% speed is not the main goal, using C is a much better way to go.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5001
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: why use ASM anymore

Postby simonsunnyboy » Thu Mar 22, 2018 5:00 pm

Frank B wrote:You still need to understand assembly for reverse engineering. Very important to verify static analysis and dynamic analysis vulnerabilities in a binary.


Yes, I agree. You have to be able to understand but not necessarily be able to code the whole application on that low level.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: why use ASM anymore

Postby Foxie » Thu Mar 22, 2018 5:34 pm

simonsunnyboy wrote:Spekaing for Ataris, if you want to get the job done and finished and 100% speed is not the main goal, using C is a much better way to go.


This might be why Cubase has a whopping 2ms MIDI thru latency, and is incapable of driving more than one MIDI out at 8MHz.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5001
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: why use ASM anymore

Postby simonsunnyboy » Thu Mar 22, 2018 6:51 pm

Foxie wrote:
simonsunnyboy wrote:Spekaing for Ataris, if you want to get the job done and finished and 100% speed is not the main goal, using C is a much better way to go.


This might be why Cubase has a whopping 2ms MIDI thru latency, and is incapable of driving more than one MIDI out at 8MHz.


2ms latency..wooohoo..you should team up with charles to make a better one. :lol:
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
metalages
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 110
Joined: Thu Jun 06, 2013 5:14 pm
Location: France
Contact:

Re: why use ASM anymore

Postby metalages » Thu Mar 22, 2018 8:34 pm

simonsunnyboy wrote:No certainly not in this fashion. More the way that it automatically updates your indirect addressing right when using structs etc.

On a modern platform (non-m68k) C compilers will optimize better and produce tighter (and more unreadable) assembler code than a human coder would do.

So the smaller and the more limited a platform is, the more assembler is necessary.
Spekaing for Ataris, if you want to get the job done and finished and 100% speed is not the main goal, using C is a much better way to go.


Yes. It was a joke ;)

The goal of this routine was to be able to test my algorithms on PC using directly Atari floppy images (portable code).
Data on my floppy images are often compressed with ARJ m4 and I use Mr Ni ARJ depack ASM routine to depack them.
Instead of trying to understand the ARJ m4 depack algorithm in order to code it on PC, it was faster to emulate the 68k routine in C... :)

But fortunately, rest of the code does not look like this ;)

alienkidmj12
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 140
Joined: Sat Mar 10, 2012 6:45 pm

Re: why use ASM anymore

Postby alienkidmj12 » Thu Mar 22, 2018 8:55 pm

i would love to learn assembly but not really sure where to start to be honest

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5001
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: why use ASM anymore

Postby simonsunnyboy » Thu Mar 22, 2018 8:58 pm

alienkidmj12 wrote:i would love to learn assembly but not really sure where to start to be honest


If you want to do this for the Atari ST, google for the Perihelion tutorials.

ON a more generic base it is better to start it on microcontrollers like AVR or PIC. After getting the point for those, it is easy to grasp for m68k and others.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
metalages
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 110
Joined: Thu Jun 06, 2013 5:14 pm
Location: France
Contact:

Re: why use ASM anymore

Postby metalages » Fri Mar 23, 2018 6:53 am

Back in time I have gone from gfa basic to asm. At the beginning just with small sub routines into a gfa program and then progressively to full asm programs.
This can also be a way to try asm 68k asm. c or gfa basic mixed with asm.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5001
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: why use ASM anymore

Postby simonsunnyboy » Fri Mar 23, 2018 4:07 pm

I learned assembly language for microcontrollers at a university course. I straightly went to apply the knowledge on the ST when Perihelion did his tutorials. I did some small full projects in assembly language but I soon focused on doing inlines for GFA until 2009 and since then I am combining it with C.

Lack of spare time leads to very few large projects surfacing, a reason why I warn of doing everything in assembly. it takes more time even if the result may be very shiny.
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
metalages
Obsessive compulsive Atari behavior
Obsessive compulsive Atari behavior
Posts: 110
Joined: Thu Jun 06, 2013 5:14 pm
Location: France
Contact:

Re: why use ASM anymore

Postby metalages » Fri Mar 23, 2018 11:11 pm

Agree mixing c and asm is a good trade off.

MrPixel
Captain Atari
Captain Atari
Posts: 191
Joined: Mon Jan 08, 2018 4:31 am

Re: why use ASM anymore

Postby MrPixel » Sat Mar 24, 2018 1:40 am

the tutorial for Devpac is good, but the programs won't run, and i can't see the error because Hatari goes too fast. i've since stopped using it.

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2258
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: why use ASM anymore

Postby charles » Sat Mar 24, 2018 11:31 am

I vote this gets moved to "discussions" field ,,,
it has nothing to do with physical coding , only a discussion on programming languages
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: why use ASM anymore

Postby Foxie » Sat Mar 24, 2018 6:05 pm

simonsunnyboy wrote:I learned assembly language for microcontrollers at a university course. I straightly went to apply the knowledge on the ST when Perihelion did his tutorials.


I went the other way around - I learned assembly on the ST first, and when microcontrollers became accessible to the hobbyist I started straight away with assembly on them.

I think the first MCU I programmed for personal use was the venerable PIC16F84, although I also did 8051 at university. These days I've mostly forgotten 8051, PICs are far more useful being cheaper and more powerful. It's pretty much mandatory to use assembly on a PIC or 8051. Some people do try to use C but it's completely hopeless for anything remotely time critical.

I have considered learning ARM or MIPS assembly to take full advantage of faster MCUs, but so far it hasn't been necessary. If I need to do something real-time, I tend to use assembly language on a PIC - because you can cycle count very easily and absolutely guarantee the performance you need. Most of the ARM/MIPS MCUs are cached, so it's a futile exercise even trying to cycle-count. You end up doing something silly like copying all your code into zero-wait-state RAM.

User avatar
simonsunnyboy
Moderator
Moderator
Posts: 5001
Joined: Wed Oct 23, 2002 4:36 pm
Location: Friedrichshafen, Germany
Contact:

Re: why use ASM anymore

Postby simonsunnyboy » Sat Mar 24, 2018 9:06 pm

Learned 8051 first, PIC was a pain in the ass and a reason why I thoroughly dislike those devices and do not recommend using them.

Doing Cortex-M devices for a living these days but in C....
Simon Sunnyboy/Paradize - http://paradize.atari.org/

Stay cool, stay Atari!

1x2600jr, 1x1040STFm, 1x1040STE 4MB+TOS2.06+SatanDisk, 1xF030 14MB+FPU+NetUS-Bee

User avatar
Foxie
Captain Atari
Captain Atari
Posts: 354
Joined: Wed Feb 03, 2016 7:12 pm

Re: why use ASM anymore

Postby Foxie » Sat Mar 24, 2018 11:14 pm

simonsunnyboy wrote:Learned 8051 first, PIC was a pain in the ass and a reason why I thoroughly dislike those devices and do not recommend using them.

Doing Cortex-M devices for a living these days but in C....


It does depend which PIC you use, and what you're doing with it. The 16F54 can be a pain since each bank is tiny (something like 32 bytes?). The newer 16F devices are also pretty bad with bank switching. Luckily the 18F series has a method to avoid bank switching most of the time - it's a bit like the 6502's zero page. One thing I like about the whole 8 bit series is that almost all instructions are one cycle. That makes is so easy to calculate cycle accurate code, which I find myself having to do all the time. I had a brief look at the AVRs, but the cycle counts were all over the place. I don't really have the patience to learn all of that, for so little gain. They're also usually too expensive to use in a commercial product.

If I need to use a faster MCU, I might consider the Cortex-M3 and up. Although the PIC32 series is also quite interesting, it's MIPS-based. You can get the smaller ones in DIP packages too, which are AFAIK the fastest DIP MCUs on the market. You can also get ARMs in DIP packages these days, but they have horrible performance (Cortex-M0) and you may as well just use an 8 bit.

Have you managed to find a development environment for ARM which shows you a cycle count for snippets of C code? As far as I remember, the Microchip development tools offer that facility.

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2258
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: why use ASM anymore

Postby charles » Sat Mar 24, 2018 11:41 pm

foxie
youre confusing mt pixel again ...
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!

User avatar
charles
10 GOTO 10
10 GOTO 10
Posts: 2258
Joined: Tue Aug 17, 2004 12:11 am
Location: ont. Canada
Contact:

Re: why use ASM anymore

Postby charles » Sun Mar 25, 2018 12:10 am

and me too!

..is this is way off topic about using Atari asm?

even tho there is a 8051 assembler for Atari st
atari is my lifestyle,not a hobby.
HOLD ON ! ! !,
Im printing unreadable characters ...!


Social Media

     

Return to “Coding”

Who is online

Users browsing this forum: No registered users and 2 guests