Shop OBEX P1 Docs P2 Docs Learn Events
Is Assembly universal? — Parallax Forums

Is Assembly universal?

DgswanerDgswaner Posts: 795
edited 2007-06-04 20:31 in General Discussion
noob question, I've been reading about the different stamps and it appears that a lot of them, as well as other PIC's can be coded in assembly. my question is? If I learn assembly would I have to learn a different version for every platform that I use, or is assembly the same cross platform? Is a PC assembly language the same as a PIC or a Propeller? I know there will be additional code to handle the differences between the hardware but is a for next loop coded the same all the way around?

Thanks

▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
A complex design is the sign of an inferior designer. - Jamie Hyneman, Myth Buster

Comments

  • FranklinFranklin Posts: 4,747
    edited 2007-06-03 01:31
    Usually in assembler the program that converts the assembly code to object code will have most of the same commands for the assembler but everything else underneith is different. Different names for the registers, different sizes and so on. Most people use assembly when they need total control of all the inner workings of the processor for speed or small code size. Some people will use it for the entire project but most use it when needed and use a higher level language when they don't.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    - Stephen
  • metron9metron9 Posts: 1,100
    edited 2007-06-03 02:21
    I started learning assembler on the old commodore64 computer with the 6502 processor. Most of what I learned back then (20 years ago) is still the same with all of the atmel chips I program. increment a byte decrement a byte move a byte from a register to a memory location, add two registers together , compare bytes, are pretty much all the same. Atmel has done a nice job creating a core processing unit that uses pretty much all of the same op codes for all their processors. Most of the processors come in 3 sizes and the code is portable across all of them with some differences in instructions for access to larger memory for example.

    I think Assembler is much easier to code than C for example, I know exactly what each line of code does because it can only do that one thing. Working with C is a nightmare for me especially the OOP stuff with classes and whatnot. I prefer the simple stuff witch is kind of funny when it comes to assembler, for me it is much simpler to understand because it is at the core of the processor. Higher level languages I find hard to debug on simple 8 bit microcontroller. If you are very orginized you can set up macros that look like basic commands and all of your math and subroutines can be setup and called using macros to parse parameters.

    I have to say though the SX assembler for me is a tougher nut because you can make some of the instructions overlap others for example and I really can't stand using characters like *!& and such for programming, I am finally getting use to the << but I prefer op codes with just letters. That's just my stubborn attitude though and is a reason I never understood higher math and physics I suppose.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-03 15:06
    I too learned assembly on the 6502 (VIC-20) and compatible 6510 (C=64)…When I later moved to 6809 I found an entirely new instruction set. Same with the Z80 and 8080, etc. Each CPU family has its own instruction set and assembly mnemonics. This is of course besides their architectural differences such as different address spaces, registers, status flags, stacks, etc.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • DgswanerDgswaner Posts: 795
    edited 2007-06-04 04:24
    Wow Vic 20 haven't heard that in a while. I think I was in the 5th grade when that was all the rage. and my parents opted for the C64 knock off. oh how I envied my neighbors. But we had a Kaypro II so I couldn't complain too much.

    Ok so my goal with wanting to learn assembly is so that when I start a project I can choose a stamp, pic, amtel or a combination of all of them, rather than use the same micro processor to do everything. I think I'm getting to the point of out growing the BS2. so I want to start my learning in another direction. I'm really interested in the Propeller, but I haven't dared make the switch yet. My interests lie in tele-robotics and autonomous robotics. would this be a good direction to move to? or do I just need to bite the bullet and learn some higher level languages?

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    A complex design is the sign of an inferior designer. - Jamie Hyneman, Myth Buster
  • Chris SavageChris Savage Parallax Engineering Posts: 14,406
    edited 2007-06-04 04:32
    The only way to do what you want is if you had a cross-compiler…I don’t know of any that support so many different architectures.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Chris Savage
    Parallax Tech Support
  • metron9metron9 Posts: 1,100
    edited 2007-06-04 06:51
    I think you mean you want to be able to use assembler on all of the chips, it will be different code for each type of chip but you have the right idea. Once you learn assembler on one chip switching to another chip will indeed be easier as the fundamental process of moving bytes in memory, adding subtracting comparing incrementing, decrementing and branching on the condition of flags that get set or cleared is pretty universal to all assembler. The Op codes vary and accessing the memory and registers may be very different between chips but the logic and program flow is pretty much the same. It gets you down to the core of the processor. When you work with a 20 mhz atmel chip for example you can do 20 million operations per second as most instructions take only one clock cycle. This is a large scale difference in thinking vs the level of thousands of instructions per second.

    Learning how to use different hardware built into the chips like timers and ADC's , comparators , serial interfaces on the assembler logic level is very interesting stuff to learn as well and will keep you occupied for many hours. You can download atmels AVR Studio and start coding for any of their chips and step through the code with the debugger, watch the port pins, timers and flags for each of the assembler op codes to first hand see exactly what happens in 20 millionths of a second per step. I love assembler.

    Learning to make sense of the datasheets gets some getting use to. Setting up a timer for example can have you spanning 10 pages with information that you would swear someone deliberately randomized just to throw you off track, It's not like looking at the PBASIC help file and saying oh that makes sense because it's all on one page and shows a nice example of how to use it. Other than that I encourage you to give it a go as the software is free and the tools are pretty cheap as well.

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Think Inside the box first and if that doesn't work..
    Re-arrange what's inside the box then...
    Think outside the BOX!
  • sam_sam_samsam_sam_sam Posts: 2,286
    edited 2007-06-04 20:31
    Hi Every One



    I am also think about·learn assembly·language

    Which one would be easyer to learn

    SX assembler language·or the Propeller language

    I have both chips so which one should I do frist..... Any idea.gif·s..


    .......And Why.........

    ·

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    ··Thanks for any·idea.gif·that you may have and all of your time finding them

    ·
    ·
    ·
    ·
    Sam
Sign In or Register to comment.