AVR vs 6502

Go To Last Post
70 posts / 0 new
Author
Message
#1
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Hi,
i have worked on AVR 8 bit microcontrollers - Atmega32/Atmega16. Now i have to work on 8-bit 6502 microprocessor.
so what is the difference between the both and can i easily migrate from AVR to 6502 ??

Thanks

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

6502??
these are from 1975 and what i now is that the only thing they have simular are that they are 8bit.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Which language do you currently program your AVR in?

If it's C then it'll take you about 2 days to work out how the new toolchain works. As the 6502 has no on chip peripherals anything you know about timers, ADC, SPI, TWI within an AVR is irrelevant. So there's little to learn in the new chip

If Asm expect to take about 2 weeks to get "comfortable" with writing in a different chip's dialect.

I'm intrigued to know what application the 6502 is going to be used within? If it's a controller application wouldn't it make more sense to use a microcontroller rather than a microprocessor as you are going to need a number of support chips around it.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

...

Last Edited: Wed. Feb 17, 2010 - 11:18 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It is a project on developing game on existing 6502 hardware which is available in India using assembly programming. I used to code in C for Atmega32 and have knowledge of assembly language for LC-3.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

...

Last Edited: Wed. Feb 17, 2010 - 11:18 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

If it's a 6502 games machine there's got to be a strong chance it's something like a Vic-20 or a C64 hasn't there? Maybe a BBC-B? In such machines there was usually a firmware/BASIC masked ROM mapped into the address map along with some multiple of 16K of DRAM and there were support chips dotted around the MPU such as a video controller and an audio controller, also an I/O controller interfacing to things like keyboard and joysticks etc.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

darshshah wrote:
It is a project on developing game on existing 6502 hardware which is available in India using assembly programming. I used to code in C for Atmega32 and have knowledge of assembly language for LC-3.

I used to program the Commodore VIC-20 and C-64 using 6502 machine language thirty years ago. Can't recall whether there were any assemblers available at the time.

If you have a 6502 assembler to work with now then all the better. Hope your mass storage is disk based instead of tape. Otherwise, programming the 6502 should be no more difficult than any other CPU or MCU.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Can't recall whether there were any assemblers available at the time.

The Apple II had an assembler for it.

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

...

Last Edited: Wed. Feb 17, 2010 - 11:18 AM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The BBC Micro came with an assembler that was integrated into the standard BASIC ;)

The question if you can develop software on the machine itself, or need to do it on another system. An EPROM simulator is very handy :)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Many HP calculators used 6502, and simple games e.g. Snake have been written for them.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
If Asm expect to take about 2 weeks to get "comfortable" with writing in a different chip's dialect.

NO
Perhaps to write functional code but for a 6502 you have to use an other structure to make a good program. The layout of the zero page is very importent for a 6502, and care should be taken by using C because the stack on a 6502 only is 256 byte.

Jens

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The difference? 6502 is accumulator based - all operations go through the accumulator A whereas the AVR is a risc architecture where operations can be done on the internal 32 8bit registers. Big difference when programming in assembler, of little consequence when programming in C. How hard? That's up to you to decide, for me it is just another day at the office.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Another important differences... a 6502 has only one memory space, stack is limited to 256 bytes, it's much slower and the fairly unique zero page addressing modes.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

i have to develop a game in 6502. so i need to learn its assembly programming.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:
If it's a 6502 games machine there's got to be a strong chance it's something like a Vic-20 or a C64 hasn't there?

I am quite willing to bet that it is a NES clone.

And I would LOVE to be paid for programing such, especially in asm...

JW

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
I would LOVE to be paid for programing such, especially in asm...
Ditto. Back to my younger days...oh the memories...but I can't remember them. :?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

darshshah wrote:
i have to develop a game in 6502. so i need to learn its assembly programming.
Why? School Assignment? If so, professor is less than a dolt.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

If so, professor is less than a dolt.

I don't know if I'd necessarily take that road. Given the tone of the request, this sounds like Microprocessor 101, or maybe Microcontroller 101. There may already be a carton of "dev" boards set up to do the exercises. For 101 and 102 classes, one single-accumulator architecture is as good as another. And as PICs are popular, might as well introduce the students to the pains of a paged system right away.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Put your most used variables in the zero page, that's sorta your "register bank".

I've heard the 6502 lives on in the embedded world. Good for it, it was a game-changer for sure. I wrote a spreadsheet program in asm for it (Syncalc).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

darshshah wrote:
Hi,
i have worked on AVR 8 bit microcontrollers - Atmega32/Atmega16. Now i have to work on 8-bit 6502 microprocessor.
so what is the difference between the both and can i easily migrate from AVR to 6502 ??

Thanks

(1) You will have a MUCH greater appreciation for what the early Personal Computer programmers went through -- why they got so excited when they could print "Hi, Rich!" ten times on a sheet of paper!

(2) FORGET all you know about microcontrollers -- the old microprocessor is a totally different beast. It's like going from an auto-everything sports car to a Model A. If you do not, a lot of your time will be spent on asking, "Why don't we just ..." with the response of "Because the processor can not do that!"

Good luck!
--Rich

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

If you do not, a lot of your time will be spent on asking, "Why don't we just ..." with the response of "Because the processor can not do that!"


Rich--Some of us here started with CARDIAC.
http://en.wikipedia.org/wiki/CAR...

Then I moved up to PDP/8 -- 3-bit op code...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Rubbish. You can do anything with a 6502 that you can do with any other CPU.

And most importantly, you can do it in your sleep. It is so simple and pleasant to use, albeit not clocked as fast as more modern cpus.

It seems that several members here have a lot of experience with the 6502.

In practice, you can live with the fixed size stack. It is more than enough for regular interrupt and subroutine storage. Parameter and local storage can use a software stack.

And you have 128 16bit pointers or 256 8bit register like storage in the zero-page.

David.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

RiJoRi wrote:
You will have a MUCH greater appreciation for what the early Personal Computer programmers went through -- why they got so excited when they could print "Hi, Rich!" ten times on a sheet of paper!

It's not less of an excitement to get an AVR together with all that "advanced" tools to print "Hi, Rich!" ten times on a sheet of a paper. Just go and try it, say with a modern USB-connected laser printer.

JW

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
Rich--Some of us here started with CARDIAC.
http://en.wikipedia.org/wiki/CAR...
This is just too damn cool! I've tried to explain computer concepts by telling folks to use a pencil and paper, but I never felt that I nailed it. This thing looks like it will do the trick. Now I'm off to explore cardboard computers.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Now I'm off to explore cardboard computers.

LOL--the last time it came up I think you could still get them.

Geez, Smiley--memory going? Why, it was just 2005 when it was first mentioned to you by Julie Porter:
https://www.avrfreaks.net/index.p...

Quote:
I still have my CARDIAC. Probably the best program teaching tool ever.

Also https://www.avrfreaks.net/index.p... and https://www.avrfreaks.net/index.p... (which also has 6502 mentions)

According to the link I gave it originated at Bell Labs. When I went to college at Northwestern circa 1970 there were a lot of Bell Labs people from the Napierville facility taking grad courses. This may well be how it started.

Erasing (literally!) the accumulator every operation quickly becomes tedious. Even circa 1971 we had a PDP/8-based simulator of the CARDIAC.

The article gives links to simulator(s); I assume some are still active...

[edit] Yep, you can still get them at Edmund Scientific--for 20 bucks!?!
http://scientificsonline.com/pro...

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
Geez, Smiley--memory going?
You know this will come back to haunt you?

theusch wrote:
Yep, you can still get them at Edmund Scientific--for 20 bucks!?!
http://scientificsonline.com/pro...
Just ordered one. I had to restrain myself from also ordering the USB Lava Lamp. That place is not only over priced, it is addictive.

Should my memory hold out till the mail arrives, I'll report back on it. If I remember that is.

Smiley

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Just ordered one. I had to restrain myself from also ordering the USB Lava Lamp. That place is not only over priced, it is addictive.

Well, the "package" may well include the 50-page booklet. If not, a scan of the booklet is available on the Web.

Quote:

You know this will come back to haunt you?

LOL--yep.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

theusch wrote:
Quote:

If so, professor is less than a dolt.

I don't know if I'd necessarily take that road. Given the tone of the request, this sounds like Microprocessor 101, or maybe Microcontroller 101. There may already be a carton of "dev" boards set up to do the exercises.
That 6502 lab will look terrific on the resume'

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
Well, the "package" may well include the 50-page booklet. If not, a scan of the booklet is available on the Web.

Specifically here:
http://dale-miller.com/cardiac/cardiac_manual.pdf
You can also get pdf's for the computer itself:
http://kylewiki.mine.nu/wiki/Cardiac_Computer

Regards,
Steve A.

The Board helps those that help themselves.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Could be one of these! They had a 6502 core. I know, 'coz I wrote a game once, a long, long time ago...http://en.wikipedia.org/wiki/Atari_2600

Four legs good, two legs bad, three legs stable.

Last Edited: Tue. Feb 2, 2010 - 04:54 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The 6502 is still used (supported) in the rail industry so it's not quite dead yet... :wink:

-=mike=-

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I've read that a stripped down 6502 (like no BCD mode) is still used in processors aimed at toys, just like the Z80 which is used in MP3 player ASICS. I'd not be surprised if 6502 cores are used in FPGAs to replace old big boards so no new firmware needs to be written.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

As I remember a NMOS 6502 os only about 5000 transistors so about 10000 for a CMOS so it's small and depending of the proces my guess is that it can run about 1.2 to 1.5 times the speed as a avr in the same proces (it's a true 8 bit), and as the AVR it make a memory cycle pr. clk. cycle. so that means that a 30 MHz 6502 ASIC should be cheap to make, and work fine.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

THe 6502's brother, the 6809, is still in use today too.

I wonder why this ole Prof. didn't call for using an 8051?

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I had a mad love affair with the 6809 in my youth. It was everything I wanted a microprocessor to be at the time.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
THe 6502's brother, the 6809
Not related at all :) different parents.
You may be thinking about the 6800/6802?
edit
Quote:
I had a mad love affair with the 6809
It must have been the Sign EXtend (SEX) instuction that got you going. :lol: or was it LEA?

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

Last Edited: Tue. Feb 2, 2010 - 11:13 PM
  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

There is some similarity between 6502 and 6802. One was more or less a similar remake of the other just not to pay for a licence. One other thing was they could easily use the same IO chips because of the similar memory bus and memory maped IO.

There were 6502 related "µCs" with a little on chip IO hardware.

The 6502 assembler is relatively easy to learn. Howerver programming is a litte different from the AVR due to only 3 registers.
At least for me the step from 6502 ASM to AVR ASM was not difficult, and I don't think the other way is more difficult.

The difficult part in doing larger ASM projects is to learn how to plan ahead, have the discepline to write all the needed comments and have a system to keep the code well organized. And for this it does not realy matter which CPU.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
Quote:
THe 6502's brother, the 6809
Not related at all :) different parents.
You may be thinking about the 6800/6802?
edit
Quote:
I had a mad love affair with the 6809
It must have been the Sign EXtend (SEX) instuction that got you going. :lol: or was it LEA?

no, it was HCF

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

http://tlindner.macmess.org/wp-content/uploads/2006/09/byte_6809_articles.pdf gives a nice introduction to the 6809 that explains both its design and development. It makes you feel spoiled when you consider the tools we can use these days!

- John

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Howerver programming is a litte different from the AVR due to only 3 registers.

It's kind of 3 + 256 though - I really liked the 0 page stuff!

(I have fond memories of writing an implementation of PacMan on my first Acorn Atom using the built-in assembler - still have two Atom's in the loft - one with piggy-backed RAM upgrade chips)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

clawson wrote:

It's kind of 3 + 256 though - I really liked the 0 page stuff!
That was my experience as well. I found I only needed two levels of comments (three if you include the design documents) for 6502 code since I could assign fixed, descriptive names to the 256, zero page registers.

With accumulator-oriented machines, such as the Data General Nova, I needed another sublevel because of the constant reassigment of the (four) working registers. Granted, with the Nova you could almost feel the bits flowing through a set of 74181 ALUs!

- John

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I learned my craft on data general nova in assembly language. Zillions of lines of code. No protected memory in that mini-computer. fixed head disk drive (fast).

Then I fiddled with 6809s (SWTPC, SS50) and like my first good friend in grammer [sic] school, it has a special place in my geek-memories.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

6809 was a perfect 8bit for Forth. Two stack pointers matches Forth perfectly - one data, one code.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

This sounds sorta like 'Engines 101', where the students work with steam engines.

/Jesper
http://www.yampp.com
The quick black AVR jumped over the lazy PIC.
What boots up, must come down.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

steam engine would be an 8008.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

My first. Complete with paper tape bootloader.
Note grouping of bits is octal.
http://en.wikipedia.org/wiki/Fil...

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

jfiresto wrote:
http://tlindner.macmess.org/wp-content/uploads/2006/09/byte_6809_articles.pdf gives a nice introduction to the 6809 that explains both its design and development. It makes you feel spoiled when you consider the tools we can use these days!

Hi!

It is true though that uC like AVR are much easier to build and use compared to the early microcomputer systems. There has been an enormous leap in technology. What you get with a common low end AVR represents several ICs worth of functions using 8 bit CPUs and peripherals.

I recently built a 6809 computer as part of the N8VEM home brew computer project. The 6809 is very nice and probably was the very top of the classic 8 bit CPUs. One of the builders ported CUBIX operating system to it.

I think it is a shame the 6809 didn't get the "traction" it deserved at the time but I think it was overshadowed by the introduction of the IBM PC which overwhelmed a lot of the microcomputers.

Thanks and have a nice day!

Andrew Lynch

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

6809 lost out because Motorola blew it big time with getting IBM to choose them instead of Intel. IBM Entry Systems Division was in a very short-sighted rush to get something, anything, to meet that year's holiday market. I recall that that ill advised rush to judgment was a floppy disk operating system replacement for paper tape done on contract by Bill Gates to HP stuff and that wasn't Motorola based.

Motorola blew it again with the 68000 family versus MIPS and DEC Alpha. At that time, some people's conventional wisdom was that the bank-switched-memory 8080 would do instead of the linear memory model of the 680x0.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

..and finally Motorola blew it again by alienating a lot more of their loyal customers by dropping things like the HC05 and HC11 range and not provide pin compatibles of newer types.

And for the last blow they changed their name thinking we would not notice. :)

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
And for the last blow they changed their name thinking we would not notice. :)
Freescale probably happened because it was part of a scheme to get an incentive bonus by making cell phones - a bonus for another empty-suit rent-a-CEO

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

the assembly language is easy and i made some graphics and a little game in it. Thanks all of you.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

darshshah wrote:
the assembly language is easy[...]
Oh, just try to explain this to the C afficionados on this forum... ;-)

JW

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Oh, just try to explain this to the C afficionados on this forum.

They probably know - they started life as Asm programmers then saw the light (C is just a fancy macros assembler adding a common structure to the for() and while() loops you were hand coding in Asm anyway)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Cliff wrote:
They probably know - they started life as Asm programmers then saw the light

Light???

Barely a dim candle.

Cliff wrote:
C is just a fancy macros assembler adding [...]
... and forcing the PDP11 idiosyncracies to everybody. Yeah.

No, Cliff. Most C afficionados sincerely do believe that asm is hard and C is easy (as most AVR afficionados believe they are superior to any other 8-bitter). And, what's far worse, they preach this for the newcomers. This is for a very long time the first poster who said "asm is easy".

Jan (the C hater)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Jan (the C hater)

That is allowed, I guess, as long as it is not a hidden promotion for

begin
    Pascal;
end.

You can put lipstick on a pig, but it is still a pig.

I've never met a pig I didn't like, as long as you have some salt and pepper.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

ASM isn't hard. I did it for years. It's just tedious and costs much more than C does in producing a solution. Also much less life-cycle cost with C - most agree that 80% of the cost of software is its life-cycle, not the original design and coding.

ASM versus C is like building a house without power assisted hammers and saws.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

I'd say its more like first making the nails and milling the tree trunks. Or maybe I'm just thinking about the last assembly language I used (which wasn't AVR).

- John

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Once, some of us very experienced developers undertook to beat-the-compiler in a 500 line function to to matrix math. It needed to be really fast (image processing). We couldn't beat the compiler's code in execution speed. Because it was very, very clever at register allocation for variables and pointers. More clever than we could be at juggling what var is in RAM or in a particular register, at any point in the code.

We could beat the compiler for smaller functions. And we probably could for a computer with fewer registers than the one we were using (a MIPS).

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

It used to be fun but tedious to reduce state tables to the required logic, but now we have logic compilers that allow us to use a high level description and produce output in next to zero time. Much the same thing as C vs Asm. You won't see much asm in my recently written stuff.....

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:
We couldn't beat the compiler's code
You mean the compiler's code writer..he/she/them was/were much more experienced in asm coding than the "very experienced developers"..... :wink:

John Samperi

Ampertronics Pty. Ltd.

www.ampertronics.com.au

* Electronic Design * Custom Products * Contract Assembly

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

what i meant easy was that i had done assembly programming course in college and it was quite the same as 6502 except the sizes,memory,speed,registers,etc. so i easily adapted the assembly language of 6502.

But i feel C is good than asm as abstraction level is more. i.e. to write loop in C is 1 line code whereas in asm we have to write 5-6 lines...

So i prefer C but have no objection for using assembly.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

The compiler writers write rules that for a human to implement would take an inordinate amount of time to implement each time a small change was done - register allocation for example. A human tends to write more 'regular' code, for example with an AVR we might use R16 as a temp register whereas the compiler will use what it wants given the circumstances at that point in the code. If we wrote code that way it would be a pig to maintain.

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

stevech wrote:
(a MIPS).

MIPS is one of the least human RISCs. And RISCs are deliberately built to be used with a compiler.

But you all miss the point. The point is not that A or B is better or worse; but that A or B is fit for a purpose.

JW

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

wek wrote:

But you all miss the point. The point is not that A or B is better or worse; but that A or B is fit for a purpose.
And to answer that you need to know the costs and benefits of each approach. I and probably others have been ignoring the suitability of A or B because we don't know the OP's purpose.

- John

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Quote:

Most C afficionados sincerely do believe that asm is hard and C is easy

For me it's not a question of "hard" vs "easy" but more vs less typing. You can achieve in one line of C what you'd need to type 10 lines of Asm to do (the output of the C compiler will show this regularly). THAT is why I switched to using C in about 1995 after having done Asm (mainly Z80) for 15 years. In my time I've written a WYSIWYG word processor/spreadsheet in Z80 Asm: http://web.ukonline.co.uk/cliff.... and http://toastytech.com/guis/pcw.html as well as some of the Sinclair Spectrum operating system so I've done more than my share of Asm but if I had the time again and the tools had been available at the time I'd have done the word pro in C (maybe not the Spectrum - that did need hand optimised Asm)

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

js wrote:
Quote:
We couldn't beat the compiler's code
You mean the compiler's code writer..he/she/them was/were much more experienced in asm coding than the "very experienced developers"..... :wink:
I disagree. The algorithms used for register/RAM allocation in non-trivial nested loops and function calls, I contend, are impractical for a person to do.

I am not a dope!

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

stevech wrote:

We could beat the compiler for smaller functions. And we probably could for a computer with fewer registers than the one we were using (a MIPS).

I can't remember who to attribute the quote to, but someone once said:

"Beginners should not optimise code. Experts should not optimise code... yet"

The quote was about profiling code before introducing "efficiency" hacks. IMO, writing in assembler is one of those.

-- Damien

  • 1
  • 2
  • 3
  • 4
  • 5
Total votes: 0

Kartman:

Quote:
A human tends to write more 'regular' code, for example with an AVR we might use R16 as a temp register whereas the compiler will use what it wants given the circumstances at that point in the code.
For me it's the other way round, the C compiler allways want to use the samme registers over and over again that give a lot of useless mov's that you can avoid. (And yes I do know that the compiler do it that way because the lib's are written to a special register use).