…are a couple interesting articles on YACC (Yet Another Compiler Compiler). This peaked my interest because i’m interested in implementing code-completion(intellisense).
If you scroll down to the resources section, there is a pdf available that is a good reference. (It’s actually an appendix from the text book my class uses.)
There is no best, but I’d say that both the ARM and PPC processors have nice assembly language and are easy to buy: a Game Boy Advance or an old Mac (of course if you want AltiVec support, it musn’t be too old..).
Personnaly I don’t like Z80 assembly language: too primitive IMHO, if you want a CISC, the 68000 is much nicer; I don’t like the MIPS either, branches with slot? No thanks..
>What’s the best processor to learn assembly on, and can it be done on a PC? (Ie – through emulation, or whatever).
I ge tthe feeling that the x86 is not the best place to start, especially since most of the material available is outdated.
Probably the easiest way to learn asm, and with that also computer architecture, it’s to start with a risc isa processor.
>I’d recommend MIPS R2000 assembly. That’s what most college courses seem to use.
MIPS R2000 is very easy, and maybe you could practice even on DLX, it’s not a real processor, but it’s a simple abstraction of most risc architectures.
There’s an awful lot of documentation out there (Old or not the vast majority of x86 assembly documentation is as valid now as when it was written).
There are plenty of x86 assembly specific groups and forums around the net.
All the tools are available for free via the net (Of course this applies to a multitude of other languages as well).
Last, but not least, you are probably using (Or can pick up very cheaply) some x86 hardware to run your code natively.
Basically the rule of thumb here is that the weirder the architecture the less help you’ll find even something as widespread as PPC doesn’t have too many docs lying around the place.
It’s a RISC architecture. It’s EXTREMELY SIMPLE and versatile. (It also doesn’t hurt that the IDE is free and the lowest end Micro is about $1.00.
Take it from me, I’m an electrical engineer who programs firmware EVERY SINGLE DAY for various products. I’ve used Intel 8051 Assembly, Motorola 68000, x86, PIC, z80. By FAR PIC is the easiest (because it’s architecture is the simplest.)
68k is a great platform for learning more complex systems, once you have a grasp on assembly in PIC. 68k assembly is about as difficult to learn as 8051 Assembly is. x86 is MUCH MORE complicated because of the more complex architecture (HOWEVER if you buy an embedded 386, 486, or pentium machine, the architecture will be simpler and easier to work with.
<cough> Isn’t it late (2003) for an introduction to C and Assembly ? Aren’t the readers of Linux Journal aware of the characteristics of those two languages ? Just kidding 🙂
memories are flooding back.. when i was a kid, i read a boook almost cover to cover on 6502, and that was before I had a computer!
i’ve looked at x86 books in bookshops and it scares me. if you want to start, i think a good one is ARM assembly language for the ARM chips. you may be able to get a cheap Acorn Archimedes machine from an online vendor, or even use the ARM ports of linux/bsd. i remember it having a simple instruction set, clear, and uncomplicated behaviour, … enough for a child to learn!
In the articles is the fact that GAS uses AT&T style assembly thanks to it’s unix legacy.
AT&T style ASM and Intel style ASM have radically different syntax, the biggest difference being the order in which operands are declared, with Intel style being destination,source while AT&T style is source,destination, and AT&T using all sorts of funky extra characters that really don’t do anything.
Example, moving the decimal value 10 into the AL register
Intel
MOV AL,10
AT&T
MOV $10,%AL
Me, I prefer Intel style because the lack of goofy extra characters makes it easier to read, and, well, I’ve been programming Intel style since 1978, when I started out on a 4040 processor. Of course, back then it wasn’t called assembly because we didn’t have assemblers. It was machine language, and everything was coded by hand and entered in binary. A joke I often make is that I would rather hand code 1k of Machine Language than spend 30 seconds trying to debug a C program. C is just too cryptic for it’s own good, and lacks the proper restrictions to prevent errors pre-compilation. (Wow, can you tell I’m a Wirth fan?)
Since that time I’ve done assembly on 8080’s, Z80’s and x86’s and even some 6809 and 6502, and oddly every assembler I had used did things Intel style. I never even encountered AT&T style until Linux started to catch on, which is odd since I did some assembly under Xenix in the late ’80’s.
That said, if your going to try to learn assembly, learn it on the processor you want to program for. While most processors have similar commands, register sets and flags, they are NOT identical. Only about 20% of what you would learn on a MIPS R2000 would be of ANY use programming a x86, 680×0 or PPC. Only about 10% of what you would learn on a Motorola 68K would be of any use on an Intel x86. Each processor has it’s own commands, that vary depending on manufacturer, number of bits, etc. Different processors from the same manufacturer can vary wildly in command sets, like the 65xx, 680x and 680×0 processors, all motorola yet very little is in common between any of them!
Bottom line, what computer do you want to make software for? What computer are you on now? If your on an Intel/AMD box, learn x86. If your on a Mac, learn PPC. If your on anything else, you probably already know assembly, are some graphic arts guy on a Sparc, or someone using a webTV for whom this whole discussion means nothing.
I recommend learning x86 programming first, if for no other reason than the fact that it has the largest installed userbase, making assembly language skills for it have a higher demand. I also would reccomend taking the time to learn both Intel and AT&T Style assembly, since on the Windows side of things it’s all Intel style (deny it if you like, but installed user base counts!) while the *nix side of thing is all AT&T Style.
The other big thing about learning x86 is the fact you can do so in baby steps, first learning simple 16 bit with simple addressing, stepping up to 16 bit protected mode, then diving in full bore to 32 bit programming. In a way the x86 is in itself capable of being three completely different programming environments, each a superset of the previous. This is IDEAL for teaching/learning.
> and AT&T using all sorts of funky extra characters that really don’t do anything.
Not really. THey all do matter and are quite easy to understand.
Personally I do prefer AT&T syntax. Intel syntax scares me as one that forces programmer to elaborate himself:
mov eax, dword ptr [edx]
If I do want to move data from memory pointed by edx into 32-bit eax register, I do know that [edx] is dword pointer, no need to mention it in assembly code
> The other big thing about learning x86 is the fact you can do so in baby steps, first learning simple 16 bit with simple addressing, stepping up to 16 bit protected mode, then diving in full bore to 32 bit programming.
I would not suggest learning 16-bit legacy x86, as it is very rarely used and confuses a lot. Pure 32 bit programming, with 4GB linear segments is much easier to uderstand and learn.
But I do agree that the best asm language to learn is the one which your machine uses. And of course x86 is a great architecture to start with. First of all you work with CISC thing, then you may start manually to reorder instructions in order to spped it up. Programming RISC, like the PPC one is then much simplier
PIC’s multiply and Divide suck, that is, unless you go for a higher level Microchip processor.
MACROS in PIC assembly make programming A HELL of a lot easier.
my point about learning PIC was this, it’s really easy, and it FORCES the user to learn how to perform loops, sub routines, and makes it blatantly obvious where code optimizations are needed.
Microcontrollers are easier because everything is integrated, when you’re ready to do something, you can just do it, you don’t have to wait for handshaking with another device (unless you want to.)
They have a free IDE (integrated development environment.) That is, they give away the thing your write your code on, a debugger, a compiler, and in some cases optimization features.
If you go with a much higherlevel PIC processor, like the 17C, or the 18C you have to pay for the compiler. THough there are some cheaper ones out there.
PICs are EVERYWHERE–check ebay even.
I reccommend you start with a 16C55 or 16C54. It’s fairly easy to learn. THere’s A LOT of internet support on PIC projects, –I’d build one of them then learn how to modify the pre-written code. Most of those projects are EXTREMELY well documented, some even have a comment for every line.
I subscribe to EVERYDAY PRACTICAL ELECTRONICS (from the UK,) which is a magazine that lives up to its name. Nearly all of the projects in it are based on the PIC architecture, and its a great way to learn and cheap (2.45 pounds.)
honestly, just google PIC microcontroller.
Some crazy people have even hooked a PIC to a harddrive–hobbists are using PICs for everything from automatic bird feeders to solid-state weather stations.
–please note I don’t work for Microchip, but have used their products extensively.
>Not really. THey all do matter and are quite easy to understand
If so I don’t get it. That’s what keyword recognition is for. To me it’s more like whoever was writing the compiler got lazy.
>mov eax, dword ptr [edx]
Uhm. Ok, all the compiler’s I’ve used that Dword ptr part is redundant. using [] around edx tells it to use it as a pointer, and if the target is a dword, there’s no need to tell it that your want to recieve a dword, unless the compiler your using is some backwards piece of junk. EAX is a 32 bit register, so the mov is going to be 32 bit. Telling it dword is unneccesary.
Simply: mov eax,[edx]
should do the exact same thing. If it doesn’t, then your compiler must be really screwy, or really primitive. This is stuff the old MASM under dos 6 could do. Truthfully I would probably include the selector in that declaration, just to keep it clear since I tend to make use of GS, ES and SS extensively in my 32 bit code. (yes, I do the no-no of using multiple selectors in my 32 bit code. God forbid you should use a register they make available!)
the most fun I ever had with that calculator check out http://www.ticalc.org
in the September edition was a w00t! Heheheh.
I did z80 calc programming too, back in the day. I just went to ticalc.org and noticed some of my TI83 stuff has release dates in early 1997. :O
Is there still an active z80 ASM community?
there is a VERY LARGE and active z80 ASM community–check ZWORLD.com
Z80 assembler…. lovely.
…are a couple interesting articles on YACC (Yet Another Compiler Compiler). This peaked my interest because i’m interested in implementing code-completion(intellisense).
What’s the best processor to learn assembly on, and can it be done on a PC? (Ie – through emulation, or whatever).
I ge tthe feeling that the x86 is not the best place to start, especially since most of the material available is outdated.
There’s also a community of GameBoy “garage games” developers too, although now a days they’re probably converting to ARM assembly for GB Advanced.
I’d recommend MIPS R2000 assembly. That’s what most college courses seem to use. You can pick up a simulator at http://www.cs.wisc.edu/~larus/spim.html
If you scroll down to the resources section, there is a pdf available that is a good reference. (It’s actually an appendix from the text book my class uses.)
There is no best, but I’d say that both the ARM and PPC processors have nice assembly language and are easy to buy: a Game Boy Advance or an old Mac (of course if you want AltiVec support, it musn’t be too old..).
Personnaly I don’t like Z80 assembly language: too primitive IMHO, if you want a CISC, the 68000 is much nicer; I don’t like the MIPS either, branches with slot? No thanks..
Of course it is only a matter of personnal taste.
I was a Z80 full-time programmer up to .. last year ! Some CPUs just take a lot more time to die … 🙂
>What’s the best processor to learn assembly on, and can it be done on a PC? (Ie – through emulation, or whatever).
I ge tthe feeling that the x86 is not the best place to start, especially since most of the material available is outdated.
Probably the easiest way to learn asm, and with that also computer architecture, it’s to start with a risc isa processor.
>I’d recommend MIPS R2000 assembly. That’s what most college courses seem to use.
MIPS R2000 is very easy, and maybe you could practice even on DLX, it’s not a real processor, but it’s a simple abstraction of most risc architectures.
x86 is actually quite a good place to start.
There’s an awful lot of documentation out there (Old or not the vast majority of x86 assembly documentation is as valid now as when it was written).
There are plenty of x86 assembly specific groups and forums around the net.
All the tools are available for free via the net (Of course this applies to a multitude of other languages as well).
Last, but not least, you are probably using (Or can pick up very cheaply) some x86 hardware to run your code natively.
Basically the rule of thumb here is that the weirder the architecture the less help you’ll find even something as widespread as PPC doesn’t have too many docs lying around the place.
MIX or MMIX just get Knuth’s books and the MDK and start programming.
the EASIEST Assembly language to learn is……
PIC Microcontroller Assembly.
It’s a RISC architecture. It’s EXTREMELY SIMPLE and versatile. (It also doesn’t hurt that the IDE is free and the lowest end Micro is about $1.00.
Take it from me, I’m an electrical engineer who programs firmware EVERY SINGLE DAY for various products. I’ve used Intel 8051 Assembly, Motorola 68000, x86, PIC, z80. By FAR PIC is the easiest (because it’s architecture is the simplest.)
68k is a great platform for learning more complex systems, once you have a grasp on assembly in PIC. 68k assembly is about as difficult to learn as 8051 Assembly is. x86 is MUCH MORE complicated because of the more complex architecture (HOWEVER if you buy an embedded 386, 486, or pentium machine, the architecture will be simpler and easier to work with.
microcontroller = internal code memory & RAM.
microprocessor = (usually) external code memory & RAM.
microcontrollers are easier to learn.
<cough> Isn’t it late (2003) for an introduction to C and Assembly ? Aren’t the readers of Linux Journal aware of the characteristics of those two languages ? Just kidding 🙂
Another resource to check out.
Art of Assembly
http://webster.cs.ucr.edu/Page_asm/ArtOfAsm.html
http://webster.cs.ucr.edu/Page_AoALinux/0_AoAHLALinux.html
memories are flooding back.. when i was a kid, i read a boook almost cover to cover on 6502, and that was before I had a computer!
i’ve looked at x86 books in bookshops and it scares me. if you want to start, i think a good one is ARM assembly language for the ARM chips. you may be able to get a cheap Acorn Archimedes machine from an online vendor, or even use the ARM ports of linux/bsd. i remember it having a simple instruction set, clear, and uncomplicated behaviour, … enough for a child to learn!
the 6502 was SWEET!
In the articles is the fact that GAS uses AT&T style assembly thanks to it’s unix legacy.
AT&T style ASM and Intel style ASM have radically different syntax, the biggest difference being the order in which operands are declared, with Intel style being destination,source while AT&T style is source,destination, and AT&T using all sorts of funky extra characters that really don’t do anything.
Example, moving the decimal value 10 into the AL register
Intel
MOV AL,10
AT&T
MOV $10,%AL
Me, I prefer Intel style because the lack of goofy extra characters makes it easier to read, and, well, I’ve been programming Intel style since 1978, when I started out on a 4040 processor. Of course, back then it wasn’t called assembly because we didn’t have assemblers. It was machine language, and everything was coded by hand and entered in binary. A joke I often make is that I would rather hand code 1k of Machine Language than spend 30 seconds trying to debug a C program. C is just too cryptic for it’s own good, and lacks the proper restrictions to prevent errors pre-compilation. (Wow, can you tell I’m a Wirth fan?)
Since that time I’ve done assembly on 8080’s, Z80’s and x86’s and even some 6809 and 6502, and oddly every assembler I had used did things Intel style. I never even encountered AT&T style until Linux started to catch on, which is odd since I did some assembly under Xenix in the late ’80’s.
That said, if your going to try to learn assembly, learn it on the processor you want to program for. While most processors have similar commands, register sets and flags, they are NOT identical. Only about 20% of what you would learn on a MIPS R2000 would be of ANY use programming a x86, 680×0 or PPC. Only about 10% of what you would learn on a Motorola 68K would be of any use on an Intel x86. Each processor has it’s own commands, that vary depending on manufacturer, number of bits, etc. Different processors from the same manufacturer can vary wildly in command sets, like the 65xx, 680x and 680×0 processors, all motorola yet very little is in common between any of them!
Bottom line, what computer do you want to make software for? What computer are you on now? If your on an Intel/AMD box, learn x86. If your on a Mac, learn PPC. If your on anything else, you probably already know assembly, are some graphic arts guy on a Sparc, or someone using a webTV for whom this whole discussion means nothing.
I recommend learning x86 programming first, if for no other reason than the fact that it has the largest installed userbase, making assembly language skills for it have a higher demand. I also would reccomend taking the time to learn both Intel and AT&T Style assembly, since on the Windows side of things it’s all Intel style (deny it if you like, but installed user base counts!) while the *nix side of thing is all AT&T Style.
The other big thing about learning x86 is the fact you can do so in baby steps, first learning simple 16 bit with simple addressing, stepping up to 16 bit protected mode, then diving in full bore to 32 bit programming. In a way the x86 is in itself capable of being three completely different programming environments, each a superset of the previous. This is IDEAL for teaching/learning.
You probably already have one.
> microcontroller = internal code memory & RAM.
+ A/D converters + I/O ports + internal timers + PWM etc
Most microcontrollers can address external code & RAM…
> It’s EXTREMELY SIMPLE and versatile.
I programmed using 68hc11 and hitachi h8/300 assembly,
I used the assembly to create optimized routines and I also used it for some little project.
I never liked too much the PIC instruction set.
To make a “simple” MUL or DIV you have to use a lot of instructions, even if there are a lot of tutorials available.
I used a PIC for a project and I agree about the free IDE and the low cost of microcontrollers!
The IDE is great!
> microcontrollers are easier to learn.
Yep, no MMU… usually.
> and AT&T using all sorts of funky extra characters that really don’t do anything.
Not really. THey all do matter and are quite easy to understand.
Personally I do prefer AT&T syntax. Intel syntax scares me as one that forces programmer to elaborate himself:
mov eax, dword ptr [edx]
If I do want to move data from memory pointed by edx into 32-bit eax register, I do know that [edx] is dword pointer, no need to mention it in assembly code
> The other big thing about learning x86 is the fact you can do so in baby steps, first learning simple 16 bit with simple addressing, stepping up to 16 bit protected mode, then diving in full bore to 32 bit programming.
I would not suggest learning 16-bit legacy x86, as it is very rarely used and confuses a lot. Pure 32 bit programming, with 4GB linear segments is much easier to uderstand and learn.
But I do agree that the best asm language to learn is the one which your machine uses. And of course x86 is a great architecture to start with. First of all you work with CISC thing, then you may start manually to reorder instructions in order to spped it up. Programming RISC, like the PPC one is then much simplier
PIC’s multiply and Divide suck, that is, unless you go for a higher level Microchip processor.
MACROS in PIC assembly make programming A HELL of a lot easier.
my point about learning PIC was this, it’s really easy, and it FORCES the user to learn how to perform loops, sub routines, and makes it blatantly obvious where code optimizations are needed.
Microcontrollers are easier because everything is integrated, when you’re ready to do something, you can just do it, you don’t have to wait for handshaking with another device (unless you want to.)
PIC programming sounds interesting, but what do I need to do it? Where can I order the hardware, and are there any books you recommend?
Any help would be much appreciated.
Here goes.
Microchip homepage (makers of PICs)
http://www.microchip.com
They have a free IDE (integrated development environment.) That is, they give away the thing your write your code on, a debugger, a compiler, and in some cases optimization features.
If you go with a much higherlevel PIC processor, like the 17C, or the 18C you have to pay for the compiler. THough there are some cheaper ones out there.
PICs are EVERYWHERE–check ebay even.
I reccommend you start with a 16C55 or 16C54. It’s fairly easy to learn. THere’s A LOT of internet support on PIC projects, –I’d build one of them then learn how to modify the pre-written code. Most of those projects are EXTREMELY well documented, some even have a comment for every line.
I subscribe to EVERYDAY PRACTICAL ELECTRONICS (from the UK,) which is a magazine that lives up to its name. Nearly all of the projects in it are based on the PIC architecture, and its a great way to learn and cheap (2.45 pounds.)
honestly, just google PIC microcontroller.
Some crazy people have even hooked a PIC to a harddrive–hobbists are using PICs for everything from automatic bird feeders to solid-state weather stations.
–please note I don’t work for Microchip, but have used their products extensively.
Those were the real dayz…
>Not really. THey all do matter and are quite easy to understand
If so I don’t get it. That’s what keyword recognition is for. To me it’s more like whoever was writing the compiler got lazy.
>mov eax, dword ptr [edx]
Uhm. Ok, all the compiler’s I’ve used that Dword ptr part is redundant. using [] around edx tells it to use it as a pointer, and if the target is a dword, there’s no need to tell it that your want to recieve a dword, unless the compiler your using is some backwards piece of junk. EAX is a 32 bit register, so the mov is going to be 32 bit. Telling it dword is unneccesary.
Simply: mov eax,[edx]
should do the exact same thing. If it doesn’t, then your compiler must be really screwy, or really primitive. This is stuff the old MASM under dos 6 could do. Truthfully I would probably include the selector in that declaration, just to keep it clear since I tend to make use of GS, ES and SS extensively in my 32 bit code. (yes, I do the no-no of using multiple selectors in my 32 bit code. God forbid you should use a register they make available!)