Some uses for a bitshift operation:
implementing a more efficient multiplication than repeated adding
implementing division algorithms
implementing an algorithm for exponentiation of integers by other integers
bitwise algorithms e.g. "how many one bits in this integer"
fast multiplication and division by powers of 2 including indexing arrays of integer ...
In the case of the Z80, the ALU is only 4 bits wide. That's no problem, since the internals of the CPU are controlled by a program internal to the processor, called the microprogram (or microcode), which is responsible for piping data around in the necessary way to execute some instruction. So if the Z80 gets an instruction like ADD HL, BC, the microprogram ...
How did 8 bit processors such as the Z80 and 8080 perform 16 bit arithmetic?
Same way one adds multiple digit numbers on paper. One digit (-pair) at a time and iterating over all digits while incooperating any carry. With(in) a CPU the chunks are ALU sized units like 4/8/16 or 32 bit.
As with paper based addition this method can be used for numbers of ...
... a scaled-down, cost-reduced, clone of the Intel 8080.
The Z80 had a massively extended instruction set, featured more addressing modes and had more registers than the 8080.
It also had a built-in DRAM refreshing logic.
... and it was more expensive than the 8080!
This is the opposite of "cost-reduced".
It only used a 4-bit ALU. I assume this would ...
But how instructions like DEC, DEX and DEY works ?
By adding $FF provided by the precharged internal data bus to the register content.
The internal databus is precharged with $FF during PHI2 (*1)
During the next phase it's loaded into the B register (signal DB/ADD)
At the same time the index register is transfered via SB (*/SB) to the A ...
Possibly a simple logic trick. The slow path in addition is carry propagation (not the individual half-adders). You can thus often double the clock rate by pipelining the carry. If you pipeline the carry, then you can reuse the bit adders at the beginning of the chain, and put them at the end. Depending on the ratio between pipeline registers, reuse ...
by using CARRY flag. Bignum (its common name for any large number lib like arbitrary size integer/fixed point/floating point numbers) algorithms do the same thing (compute m*n bit operations using only n bit operations) for more info see
Cant make value propagate through carry
So operations like +,- are done by sequencing from LSW to MSW (where word is the ...
The 1955 manual for the IBM 704 on page 7 talks about data representation in the computer.
When a word is interpreted as numerical data, the
zero position acts as the sign of the word. (…) When
a logical operation is performed on a word, the
word is interpreted as a 32-bit signless number.
As an algebraic (signed) binary number, a word can
Why did the Z80 with 4-bit ALU out-perform the fully 8-bit Intel 8080?
Did it? I guess this depends on what 'performance' meant here.
If it's about instructions per clock, then No. They are, for all practical purposes, identical.
If it's about reaching higher clock speed, then Yes.
If it's about an increased instruction set, then as well Yes.
If it's about ...
Then you haven't done any embedded work, or anything to do with comms or protocols.
If you're working with embedded code, you need a way to get values into specific bits in a register. This is true even for the base processor, but especially so for microcontrollers which have extra registers to control the I/O, and for data going to and from devices such ...
There are a lot of instructions on x86 that leave the flag(s) in an indeterminate state, which means the whole FLAGS register is also undefined. Most will have AF undefined, for example
The OF and CF flags are set to 0. The SF, ZF, and PF flags are set according to the result (see the “Operation” section above). The state of the AF flag is undefined....
In the days before floating point hardware there was fixed-point integer arithmetic! Bit shift instructions were used to implement the "scaling factor" - specifically, to adjust it when you multiplied (or divided) numbers and then had to rescale the number to achieve the desired precision. (Or when adding and subtracting if the operands had different scale ...
Along with the many uses of bitshifting (multiplying and dividing by powers of 2, bitmasks, etc.), bitshifting is also very cheap to implement: a simple implementation uses one multiplexer per bit to logical shift for each direction. Adding arithmetic shift is easy too: arithmetic left shift is identical to logical left shift, while arithmetic right shift ...
The repeated-addition algorithm you describe is not the usual way. Instead, think of long multiplication, but in base 2 instead of base 10. The shift instructions available in most CPUs are useful here.
Here's how you might do it on a 6502:
; shift result up by one place
First RNS machine seemed to be tube-based EPOS (Elektronický Počítací Stroj) made around 1963 in Czechoslovakia.
The successor of that machine, EPOS-2, was transistorized and was built around 1973.
In USSR, there was Т340А machine, built also around 1962 and used for prototyping radar station machines. Later that machine turned into production К340А system,...
One example are the two undocumented 8085 flags that can be found by reverse-engineering the silicon (well, it's part of a register, not a complete register). They have uses for signed overflow in arithmetic operations and signed comparison. There are actually a few undocumented opcodes that make use of at least the K flag.
They were put in deliberately (so ...
(Another "what was the first" question where it's basically impossible to answer it unless one goes through all computer instruction sets ...)
One example of the usage of "logical" is the IBM 7090 (1959), as one can verify in the manual where the shift instructions are listed starting on page 31:
ALS Accumulator Left Shift
It seems that some of the information you have doesn't apply to the SAP-2.
Earlier in the book, it said that to execute a decrement instruction, you must load the value you want to decrement in A, subtract 1, and then load it back into the designated register.
The Simple As Possible SAP-2 computer has dedicated decrement instructions.
Section 11-4 "...
Conceptually, this is a lot like how we (humans) do add, subtract, multiply, etc multi-digit numbers. An 8-bit processor has 8-bit "digits" that it can concentrate on one at a time.
If we want to add 1234+5678, we do as follows: we add the two lowest digits (4+8=12), we write down the 2 in the 1s column of the answer, carry the 1. We add 7+3, plus the ...
I'm not familiar with the 8080's internal design, but the Z80 had, in addition to a general-purpose four-bit ALU, a separate 16-bit limited-function ALU (operations limited to adding or subtracting one) which sat on a 16-bit bus with all of the registers. In addition, a few of the 16-bit registers like PC and SP were isolated from the rest of the registers ...
Forgive me if this is a repeat, but I didn’t see it mentioned.
If 8080 compatibility isn’t needed, the ability to swap an entire register set instead of using a stack makes context switching faster, especially for an interrupt service routine.
And then there are data registers of various FPUs leaving one or more entries in unspecified state after an operation. Well known for example the AMD 9511 series where next to all higher FP functions like SIN or LOG working on a single argument leave at least two entries in undefined states (*1).
*1 - Two operand functions always leave one entry undefined ...