Sei sulla pagina 1di 20

CURSO DE

MICROPROCESDORES

Ing. Luis Enrique Acosta Galván

UNIVERSIDAD TECNOLOGICA
2018
Operaciones aritméticas

1. Operaciones sobre enteros


• Adición y sustracción
• Multiplicación y división
• Desbordamientos
2. Punto flotante – Números reales
• Representación y operaciones.
Números sin signo

Representación de los números sin signo

0 hasta 2n-1 donde n es el #de bits


Operaciones aritméticas

Ej. Escriba los numero sin signo para 3 bits

0 hasta 23-1 0 000


0 hasta 7 1 001
2 010
3 011
4 100
5 101
6 110
7 111
Magnitud y signo
Representación de los números
Digito Magnitud y signo
-7 1111
-6 1110
Operaciones aritméticas

Signo y magnitud -5 1101


-4 1100
-3 1011
0111 +8 -2 1010
-1 1001
1111 -8 0 1000
0 0000
Signo 1 0001
2 0010
-2n-1 – 1 hasta +2n-1 – 1 3 0011
4 0100
5 0101
6 0110
7 0111
Magnitud y signo

Representación de los números Digito Compleamento A2


-8 1000
-7 1001
Operaciones aritméticas

Complemento A2 -6 1010
-5 1011
-4 1100
0111 +7 -3 1101
-2 1110
1001 -7 -1 1111
0 0000
-2n-1 hasta +2n-1-1 1 0001
2 0010
3 0011
4 0100
5 0101
6 0110
7 0111
Adición y sustracción números
sin signo
SUMA RESTA

A B RESUL CARRY A B RESUL BORROW


0 0 0 0 0 0 0 0
0 1 1 0 0 1 1 1
Operaciones aritméticas

1 0 1 0 1 0 1 0
1 1 0 1 1 1 0 0
Adición y sustracción

Full Adder
Sumador de n bits
Operaciones aritméticas
Adición y sustracción

Full Subtractor
Operaciones aritméticas
Adición y sustracción
we get 1100 + 1101 = 11001, which produces a
For example, the valid range for a 4- 1 for both Unsigned_Overflow and c . XORing
3
bit signed number goes from –2 to 2 –
3 3
these two values together gives a 0 for the
1 (i.e., from –8 to 7). Adding the two Signed_Overflow signal. On the other hand, if
signed numbers, 4 + 5 = 9 should we treat the two binary numbers, 1100 and 1101,
result in a signed number overflow as unsigned numbers, then we are adding 12 +
since 9 is outside the range
Operaciones aritméticas

13 = 25. 25 is outside the unsigned number


range, and so the Unsigned_Overflow signal
should be asserted.
Adición y sustracción

Sumador restador
Operaciones aritméticas
Multiplicación
Sin signo
Operaciones aritméticas
Multiplicación
Con signo

Inicio
Algoritmo de Booth
A=0 Q-1 =0
M=Dato1 Q=Dato2
Operaciones aritméticas

C=nbit

10 01
Q0Q1
A=A-M 11 00 A=A+M
Rot Aritm derecha
AQQ-1

c=c-1

N
C=0?
S
Fin
Multiplicación
Con signo Algoritmo de Booth
Inicio
A=0 Q-1 =0
M=Dato1 Q=Dato2
C=nbit
Operaciones aritméticas

10 01
Q0Q1
A=A-M 11 00 A=A+M
Rot Aritm derecha
AQQ-1

c=c-1

N
C=0?
S
Fin
División
Con signo Algoritmo división
Operaciones aritméticas
Punto flotante – Números reales

• Representation for non-integral numbers


– Including very small and very large numbers
• Like scientific notation
Operaciones aritméticas

– –2.34 × 1056 normalized


– +0.002 × 10–4
not normalized
– +987.02 × 109
• In binary
– ±1.xxxxxxx2 × 2yyyy
• Types float and double in C
Punto flotante – Números reales

• Defined by IEEE Std 754-1985


• Developed in response to divergence of representations
– Portability issues for scientific code
Operaciones aritméticas

• Now almost universally adopted


• Two representations
– Single precision (32-bit)
– Double precision (64-bit)
Punto flotante – Números reales
single: 8 bits single: 23 bits
double: 11 bits double: 52 bits

S Exponent Fraction
Operaciones aritméticas

x  (1)S  (1 Fraction)  2(Exponent Bias)


• S: sign bit (0  non-negative, 1  negative)
• Normalize significand: 1.0 ≤ |significand| < 2.0
– Always has a leading pre-binary-point 1 bit, so no need to
represent it explicitly (hidden bit)
– Significand is Fraction with the “1.” restored
• Exponent: excess representation: actual exponent + Bias
– Ensures exponent is unsigned
– Single: Bias = 127; Double: Bias = 1203
Punto flotante – Números reales
• Exponent 8 bit: excess representation: actual exponent + Bias
– Ensures exponent is unsigned
– Single: Bias = 127; Double: Bias = 1203
Operaciones aritméticas

Single

0 127 255

-128 0 +127
Punto flotante – Números reales
single: 8 bits single: 23 bits

S Exponent Fraction

x  (1)S  (1 Fraction)  2(Exponent Bias)


Operaciones aritméticas
Punto flotante – Números reales
single: 8 bits single: 23 bits

S Exponent Fraction

x  (1)S  (1 Fraction)  2(Exponent Bias)


Operaciones aritméticas

Potrebbero piacerti anche