Hot answers tagged

41

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 ...


38

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 ...


36

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 ...


23

... 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 ...


20

But how instructions like DEC, DEX and DEY works ? By adding $FF provided by the precharged internal data bus to the register content. In Detail: 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 ...


12

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 ...


12

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 ...


11

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 ...


11

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 ...


9

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 TEST 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....


7

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 ...


7

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 ...


5

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,...


5

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 ...


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 ...


4

Some arithmetic operations in the Xerox Alto would leave registers in unpredictable states, as the cycle time was shorter than the total propagation time of the ALU: With a 137ns clock cycle time, the CP pushes the underlying hardware to its limits. As a result, some combinations of input sources requested by a microinstruction will not produce valid ...


1

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.


1

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 ...


1

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 ...


Only top voted, non community-wiki answers of a minimum length are eligible