6
votes

Before you laugh at me: I want to ask arithmetic operation is done in ALU unit or accumulator. I read a book it says accumulator is a register for doing arithmetic.

This Accumulator said

Without a register like an accumulator, it would be necessary to write the result of each calculation (addition, multiplication, shift, etc.) to main memory, perhaps only to be read right back again for use in the next operation.

Does this mean that without accumulator the operation itself still can be done?

I'm from high level language I need to understand it.

2
How old is this book? CPUs traditionally had dedicated accumulator registers, but now most CPUs have a series of general purpose registers, any of which can be used as an accumulator. What high-level language requires you to know this information? What problem are you trying to solve?Cody Gray
This book was made in 2006, maybe I misunderstand all this stuff.Plain_Dude_Sleeping_Alone
Can you describe more specifically what your programming problem is? If you're writing in a high level language, then the compiler will deal with this for you. If you're writing in assembly language, then your choice of assembly language has determined whether you have an accumulator.Raymond Chen
@RaymondChen I don't think there is a programming problem. Not that every question needs to be a programming problem.fuz

2 Answers

7
votes

Yes, you don't need an accumulator for a CPU. For example, stack-based processors typically only have one or two stack pointers but no accumulator. As the article says, these processors load the values to operate on from memory just prior to operation.

1
votes

No, a CPU does not require an accumulator.

For example, the EDVAC, like many other early vacuum tube computers, have instructions that look like

add 0041 0072 0055

telling the computer to load 2 numbers from memory (at two absolute memory addresses), and store the sum back to memory (at the a third absolute memory address). (In other words, they are 3-operand machines, with all 3 operands in memory).

For another example, each processing element of the Connection Machine 1, like some of the early integrated-circuit computers, likewise does not have an accumulator, only a few flags. It has nanoinstructions that can be used to add 2 numbers from memory (at two absolute memory addresses, a source and a destination), and store the sum back to memory (at the same destination address). (In other words, it is a 2-operand machine, with both operands in memory).

Does this mean that without accumulator the operation itself still can be done?

Yes, operations like AND, OR, NOT, ADD, MULU, etc. are calculated in the ALU. However, the ALU alone is not enough.

For the ALU to work properly, something else needs to hold the two input values to the ALU stable until the ALU calculates its output value, and then that output value generally needs to be stored somewhere. These other things are part of the process for doing arithmetic.

The accumulator, like nearly all other registers, merely holds data values temporarily (without changing it) until some other data value is loaded into them.

an accumulator is a register for doing arithmetic.

I suspect the writer of this sentence is trying to distinguish between various kinds of programmer-visible registers.

Some CPUs, such as the processors in the Motorola 68000 series, have several groups of registers:

  • 8 Data registers are tightly connected to the ALU. On the 68000, most arithmetic or logical instructions can use any of the data registers as the source or destination. These data registers are "registers for doing arithmetic". Often people say the 68000 series has 8 accumulators.
  • 8 Address registers. They can't immediately be used as the source or destination for doing most arithmetic or logical instructions.
  • 1 Program counter. The program counter is a very useful register, but it can't immediately be used as the source or destination for doing most arithmetic or logical instructions.
  • The status register is connected to some of the output flags of the ALU. It is not connected to either input of the ALU or the main output value of the ALU, so it can't immediately be used for doing arithmetic. (It can't even be incremented).

Other CPUs, such as ARM processors, MIPS processors, DLX processors, and RISC-V processor have most of their registers in one group: a "uniform register file" of "general-purpose registers". Programmers can use any of these registers as data registers (generally the two inputs to the ALU come from any 2 of these registers, and the output of the ALU is also stored in any of these registers). So some people say all of those registers are accumulators. Programmers, if they choose, can instead any of these registers as address registers or index registers.

The Western Design Center W65C02S, like most CPUs sold every year, has only one special register ("A") tightly connected to the ALU -- in most arithmetic or logical instructions, the A register is always one of the inputs to the ALU, and the instruction also uses the A register to hold the result value coming out of the ALU. (In other words, it is a 1-operand machine, also called an accumulator machine). The W65C02S, like practically all CPUs, also has a few other registers that are not accumulators -- the index registers, the PC, etc.