curso de c
Facultad De Ingenier´ıa
Programando en C a Bajo Nivel
[75.40] Algoritmos y Programaci´on I
1er Cuatrimestre 2011
C´atedra: Ing. Pablo Guarna
Autor: Bernardo Ortega Moncada
Versi´on 3.0
Programando en C a Bajo Nivel
1er Cuatrimestre 2011
´Indice
1. Introducci´
on
2
2. Representaci´
on de N´
umeros en Base Binaria
2.1. Complementos A1 deun N´
umero . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
2
2
3. Sentencias Bit a Bit en C
3.1. Operaci´
on AND (Bit a Bit) (&) . . . . . . . . . . . .
3.2. Operaci´
on OR (Bit a Bit) (|) . . . . . . . . . . . . .
3.3. Operaci´
on XOR (bit a bit) ( ∧ ) . . . . . . . . . . .
3.4. Operaci´
on Complemento A1 a la Base ( ∼ ) . . . .
3.5.Desplazamiento de Bits . . . . . . . . . . . . . . . .
3.5.1. Desplazamiento de Bits a la Derecha ( >> ) .
3.5.2. Desplazamiento de Bits a la Izquierda ( < < )
3.6. Operador Ternario (? :) . . . . . . . . . . . . . . . .
3.6.1. Ejemplo . . . . . . . . . . . . . . . . . . . . .
3.7. Campos de Bits . . . . . . . . . . . . . . . . . . . . .
3.7.1. Limitaciones de Campos de Bits . . . . . . .
3.8.Ventajas y Desventajas de Operar Bit a Bit . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
..
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
..
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
2
3
4
55
6
6
7
7
8
8
9
9
4. El Preprocesador de C
4.1. ¿Que Es Un Macro? . . . . . . . . . . . . . .
4.2. Ejemplos de Macros . . . . . . . . . . . . . .
4.2.1. Inclusi´
on de Archivos . . . . . . . . .
4.2.2. Creaci´
on de Archivos de Cabecera . .
4.2.3. Creaci´
on de Macros como Constantes
4.2.4. Creaci´
on de Macros como Funci´
on . .
4.3. Otras Directivas del Preprocesador . .. . . .
4.3.1. #undef . . . . . . . . . . . . . . . . .
4.3.2. #if , #else , #elif . . . . . . . . . . .
4.3.3. #error . . . . . . . . . . . . . . . . . .
4.4. Ventajas y Desventajas de Usar Macros . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
..
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
..
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
....
Regístrate para leer el documento completo.