Re: Moving from 8051 to AVR



Ulf Samuelsson wrote:
Getting rid of global variables is good programming practices
but the 8051 will force you to use this costing extra time and
making the C code more unreadable.
I'm lost. How do the extra opcode features of the C51, like
direct memory access, and Boolean operators, make code LESS
readable ?



Direct memory access means that you are using up the decoding space that should be used for registers.
It is not "extra" opcode features, it is waste of decoding space.


That's not really a great argument - it would be simple enough to drop a single register (say, r0) and make that refer to "direct memory" with the address given in the next instruction word. That would also have simplified a number of instructions - for example, the "LDS Rd, k" instruction would now be implemented simply "MOV Rd, R0, k".

If you want to argue that this would make a larger core, or increase the critical path lengths of the decoder, or cause problems for the pipelining logic (a more common reason for RISC architectures' omission of direct memory access instructions), that's fine. But there would have been no problem doing a little re-arranging of the opcode space to fit the addressing mode in.

Lack of registers means that local variables cannot be optimized into registers.
This means you are forced to use global variables.
I.E: you are making the code harder to read and thus less maintainable.

If you have more SRAM than you need which is often the case in 0.18u processes
then the use boolean operators makes code less portable/readable.
Writing a boolean variable is more expensive than writing a byte variable
since you have to do a read-modify write - OR go to a much more expensive SRAM implementation.

.



Relevant Pages

  • Re: Yo Ulf S: How about a lds and a sts inst on the AVR?
    ... The new ATtiny20 has a reduced core with but 16 registers. ... The problem is decoding space. ... Have to be a 4 byte instruction, ... or may not be shared by my employer Atmel Nordic AB ...
    (comp.arch.embedded)
  • Re: Yo Ulf S: How about a lds and a sts inst on the AVR?
    ... The new ATtiny20 has a reduced core with but 16 registers. ... The problem is decoding space. ... Have to be a 4 byte instruction, ...
    (comp.arch.embedded)
  • Re: High-bandwidth computing interest group
    ... few dedicated registers? ... There are GPUs with 256-1024 SP FPUs on them. ... 32b SP in a given operation, in parallel in one instruction. ... pipelining, e.g. spreading an 8 element vector over 2 cycles. ...
    (comp.arch)
  • Re: Trivia Question
    ... >> Make all the excuses for your ignorance that you like, but, yes, ... I thought that this was the point of *all* programming languages ... registers are pushed on the stack for PUSHA/PUSHAD? ... And if you don't study the instruction set ...
    (alt.lang.asm)
  • Re: AMD Bulldozer optimization guide
    ... arguably better than instruction sets. ... You don't really miss the immediates. ... Nearly every OS, on machines that do not switch some registers or run on a special interrupt stack in at least some modes, have some sort of "locore" - an area of memory whose address is such that it can be constructed via an immediate WITHOUT DESTROYING ANY REGISTERS, so that you can save the registers that you would have to destroy in order to access any region of memory further afield. ... "Constant pools" - a frequently used constant in a constant pool occupies DRAM, several places in the cache, and the register it is currently held in. ...
    (comp.arch)