Escolar Documentos
Profissional Documentos
Cultura Documentos
Arquitectura de computadoras
CMOS
NDICE
1 PROGRAMAS RESIDENTES TIPEADOS DE LOS TEXTOS ESPECIALIZADOS
EN ALGN LENGUAJE PEQUEO PORTABLE (ASEMBLER, BASIC, C STD,
PASCAL, ETC).................................................................................................. 2
1.1
1.2
PROGRAMAS:..................................................................................... 2
1.2.1
1 Primer Programa.....................................................................2
1.2.2
2 Segundo Programa.................................................................3
2.2
2.3
REGISTROS DE ESTADO.....................................................................7
2.3.1
REGISTRO A................................................................................. 7
2.3.2
REGISTRO B................................................................................. 7
2.3.3
REGISTRO C................................................................................. 7
2.3.4
REGISTRO D................................................................................ 8
2.3.5
4.1
4.2
4.3
INTERRUPCIONES DE HARDWARE:...................................................12
5.2
INTERRUPCIONES DE SOFTWARE:....................................................16
BIOS SETUP...................................................................................... 23
8.2
8.3
8.4
BIBLIOGRAFIA......................................................................................... 27
1.2 PROGRAMAS:
1.2.1 1 Primer Programa
Este primer programa en C colocar de manera perpetua mi nombre
Lab. Arquitectura haciendo un pseudoscroll horizontal en la
esquina superior derecha.
#include <dos.h>
#include <conio.h>
extern unsigned _heaplen=1024;
extern unsigned _stklen=512;
void interrupt (*OldTic)(void);
void KillTic(void);
void interrupt Tic()
{
unsigned int (far *pantalla)[80];
static int prueba=0;
int i;
static char cad[24] = "LABORATORIO ARQUITECTURA";
pantalla = MK_FP(0xb800,0);
0x7900;
#include <dos.h>
#include <stdio.h>
#include <stdlib.h>
#define vec_int 0x09
DE
void main(void)
{
if (esta ()){
printf ("\nEl programa ya est instalado.\n");
printf ("\nNo permite m s instalaciones.... NiCe 2 MEET U
by
IcEmAn\n\n");
printf ("\nPara desinstalar pulsar [CTRL]+[ALT]\n");
exit (0);
}
almacen = getvect (vec_int); /* guardo la direccion del vector de inter.*/
setvect (vec_int,&Madre); /* meto la rutina madre en el vector de inter.*/
/* madre */
void KillMadre (void)
{
nosound ();
/* quitas el sonido que esta activo*/
setvect (vec_int,almacen); /* mete la direccion donde apunta el vector
de*/
/* interrupciones en el vector de interrupciones*/
/* y asi se anula la rutina que haba en memoria*/
freemem(peek(_psp,44));/* Desplazamos _psp a la posicion 44 que es donde
se guarda la direccion del segmento de entorno
y liberamos la memoria */
freemem(_psp);
}
void interrupt Madre (void)
{
sound (inportb(0x60)*200); /* lees del puerto de teclado, y el entero */
/* resultante lo multiplicas para que salga*/
/* un sonido audible */
if ((peekb(0x40,0x17) & 12)==12) /* si pulsas control alt */
KillMadre();
almacen();
}
Registros de estado C y D
Bits 7 del registro de estado A
Bits 7 del byte de segundos (Index 00h)
Los primeros 14 bytes de la RAM RTC se emplean para el reloj y los cuatro
registros de estado. Los restantes 50 Bytes sirven para la configuracin del
sistema. La ocupacin exacta de los diferentes bytes se pueden ver en la
siguiente tabla.
00
h
Segundos
01
h
Segundos Alarma
02
h
Minutos
22h Cabezales HD 1
03
h
Minutos Alarma
23h HD 1
Low
inicio
Pre-Compensation
04
h
Horas
24h HD 1
High
inicio
Pre-compensation
05
h
Horas Alarma
06
h
Da de la semana
07
h
Da del mes
27h HD 1 sectores
08
h
Mes
28h Opciones 1
09
h
Ao
29h Reservado
Estado A
2A
h
Reservado
0B
h
Estado B
2B
h
Opciones 2
0C
h
Estado C
2C
h
Opciones 3
0D
h
Estado D
2D
h
Reservado
10
h
Tipo de Flopy
11
h
Reservado
12
h
Tipo de HD
13
h
Reservado
14
h
Equipamiento
15
h
16
h
17
h
18
h
19
h
1A
h
3A
h
1B
h
Reservado
3B
h
1C
h
Reservado
3C
h
HD 2 Sectores
Reservado
3D
h
Reservado
1Eh Reservado
3Eh Reservado
3Fh Reservado
Direcci
n
Datos
BCD
Segundos
00
00
59
hasta
Segundos Alarma
01
00
59
hasta
Minutos
02
00
59
hasta
Minutos Alarma
03
00
59
hasta
Da de la semana
06h
01
07
hasta
Da del mes
07h
01
31
hasta
Mes
08h
01
12
hasta
Ao
09h
01
99
hasta
ALE:
MOV
DIV
MOV
MOV
MOV
MOV
DIV
ADD
MOV
MOV
MOV
MOV
DIV
ADD
MOV
MOV
MOV
MOV
DIV
ADD
MOV
MOV
MOV
MOV
DIV
ADD
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
INC
MOV
INC
INC
DEC
CMP
JNZ
BX,18
BX
DH,AL
BH,10
AH,0
AL,CH
BH
AX,3030H
WORD PTR HORA,AX
HORA+2,':'
AH,0
AL,CL
BH
AX,3030H
WORD PTR HORA+3,AX
HORA+5,':'
AH,0
AL,DH
BH
AX,3030H
WORD PTR HORA+6,AX
HORA+8,':'
AH,0
AL,DL
BH
AX,3030H
WORD PTR HORA+9,AX
AX,PANTALLA
ES,AX
DI,2*(80-11)
CX,11
SI,0
AL,HORA[SI]
ES:[DI],AL
DI
BYTE PTR ES:[DI],31
SI
DI
CX
CX,0
ALE:
FIN:
POP ES
POP DS
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
STI
IRET
RELOJ ENDP
INSTALAR PROC
MOV AX,0000H
MOV ES,AX
MOV BX,01CH*004H
CLI
MOV WORD PTR ES:[BX],OFFSET RELOJ
MOV WORD PTR ES:[BX+2],CS
MOV DX,OFFSET INSTALAR
STI
INT 27H
INSTALAR ENDP
CODIGO ENDS
END INICIO
;PROGRAMA DE RELOJ RESIDENTE
10
AX
BX
CX
DX
SI
DI
DS
ES
AX,40H
ES,AX
SI,6CH
AX,ES:[SI]
DX,ES:[SI+2]
BX,32771
BX
AX,1
CH,AL
MOV
MOV
MOV
DIV
MOV
AX,DX
DX,0
BX,1092
BX
CL,AL
MOV
MOV
MOV
DIV
MOV
AX,DX
DX,0
BX,18
BX
DH,AL
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
MOV
HORA,'F'
HORA+1,'E'
HORA+2,'R'
HORA+3,'D'
HORA+4,'I'
HORA+5,'N'
HORA+6,'A'
HORA+7,'N'
HORA+8,'D'
HORA+9,' '
HORA+10,'C'
HORA+11,'O'
HORA+12,'N'
HORA+13,'D'
HORA+14,'O'
HORA+15,'R'
HORA+16,'I'
11
HORA+17,' '
BH,10
AH,0
AL,CH
BH
AX,3030H
WORD PTR HORA+18,AX
HORA+20,':'
MOV
MOV
DIV
ADD
MOV
MOV
AH,0
AL,CL
BH
AX,3030H
WORD PTR HORA+21,AX
HORA+23,':'
MOV
MOV
DIV
ADD
MOV
MOV
AH,0
AL,DH
BH
AX,3030H
WORD PTR HORA+24,AX
HORA+26,':'
MOV
MOV
DIV
ADD
MOV
AH,0
AL,DL
BH
AX,3030H
WORD PTR HORA+27,AX
MOVER:
MOV AL,HORA[SI]
MOV ES:[DI],AL
INC DI
MOV BYTE PTR ES:[DI],31H
INC SI
INC DI
LOOP MOVER
FIN:
POP ES
POP DS
POP DI
POP SI
POP DX
POP CX
POP BX
POP AX
STI
IRET
RELOJ ENDP
INSTALAR
MOV
MOV
MOV
CLI
MOV
MOV
MOV
STI
PROC
AX,0000H
ES,AX
BX,01CH*004H
WORD PTR ES:[BX],OFFSET RELOJ
WORD PTR ES:[BX+2],CS
DX,OFFSET INSTALAR
12
Descripcin
Sistema
Sistema
Teclado
Libre
COM2,
COM4
COM1,
COM3
Libre
Sistema
Libre
Reservada para
Impresoras.
Sistema
Libre
10
Libre
11
Libre
12
Libre
13
Sistema
14
Sistema
LPT1,
Normalmente
libre
an
si
hay
Solo se pueden utilizar las que figuran libres mas la IRQ15 y las de los
puertos COM.
14
15
16
17
DESCRIPCIN
20H
Terminar Programa
21H
Peticin de funcin
22H
Direccin de terminacin
Especifica la direccin a donde se bifurcar cuando se
termine el programa. Esta direccin se copia sobre el PSP
23H
18
25H
26H
27H
28H
No se usa (Reservada)
3FH
No se usa (Reservada)
dseg
A263103.ASM
macro
mov
mov
int
endm
ah,0h
al,2h
10h
segment
memo
pan
x1
y1
xx0
yy0
x0x
y0y
c01
c02
f01
f02
x2
y2
XX
AA
BB
CC
EE
FF
GG
HH
II
JJ
KK
LL
MM
para 'datos'
;Segmento de datos, Definiciones en assembler
dw 0B800h
;Inicio de la pantalla
dw 2000 dup(?) ;Separa memoria sin inicializar
dw 20
;Coordenadas esquina sup.izq. del menu.
dw 4
;Coordenadas esquina sup.izq. del menu.
db 0
;
db 0
;
db 0
db 0
dw 0
dw 0
dw 0
dw 0
dw 60
;Coordenadas esquina inf.derecha del menu.
dw 22
;Coordenadas esquina inf.derecha del menu.
db '[7 3 3 3 3 3 3 3G7R7A7F7I7C7A7D7O7R7 3 3 3 3 3 3 3]7' ;Menu
db 'Fa18
M O D O
T E X T O
'
db 'Fa28
M O V I M I E N T O
C O N
A R R A S T R E
'
db 'Fa38
M O V I M I E N T O
C O N T R O L A D O
'
db 'Fa48
M O D O
G R A F I C O
'
db 'Fa58
C U A D R A D O
R E L L E N O
'
db 'Fa68
C U A D R A D O
E N
M O V I M I E N T O
'
db 'Fa78
M O V I M .
E N
P E R S P E C T I V .
'
db 'Fa88
M O V I M I E N T O
D E
L I N E A S
'
db 'Fa98
M O V I M I E N T O
A N I M A D O
'
db 'Fa1808
G R A F I C A D O R
'
db ' E8S8C8
F I N
'
db
19
dseg
NN
car
fil
col
fi1
co1
color
colo
long1
long2
video
ends
db
db
dw
dw
dw
dw
dw
db
dw
dw
db
0
0
0
0
0
0
0
0
11h
;fila actual
;columna actual
;fila anterior
;columna anterior
;color
cseg
segment
;Programa principal.
assume cs:cseg, ds:dseg, es:cseg, ss:cseg
ini:jmp
marco
;inicio de programa
marco proc
near
;
mov
ax,cs
;
mov
ax,dseg
;
mov
ds,ax
;
mov
es,ax
;
call
salva
;
push
ax
;
menu:mov
ax,MEMO
;Inicio de memoria de pantalla
mov
ES,ax
;
mov
di,598
;CLEAR SCREEN
MOV
AX,0720h
;
cle1:add
di,80
;
mov
cx,80
;
cle0:add
di,1
;
mov
es:[di],ax ;
loop
cle0
;
cmp
di,3300
;
jl
cle1
;
MOV
AX,MEMO
;Inicio de la pantalla
MOV
ES,AX
;
MOV
CX,58
;Longitud de cadena a imprimir
MOV
AX,850
;Posicion en la pantalla
MOV
DI,AX
;Direccion destino
MOV
SI,OFFSET AA;Direccion origen de la cadena AA
REP
MOVSB
;Repite traslado de cadena byte a byte
MOV
CX,58
;
add
AX,160
;
MOV
DI,AX
;
MOV
SI,OFFSET BB;
REP
MOVSB
;
MOV
SI,OFFSET EE;
REP
MOVSB
;
MOV
CX,58
;
add
AX,160
;
MOV
DI,AX
;
MOV
SI,OFFSET FF;
REP
MOVSB
;
MOV
CX,58
;
lea
bx,CS:f3
;
lea
bx,CS:f4
;
opcion:call
resetraton
;
call
punteroon
;
opcion1:mov
ah,01
;Funcion: leer una tecla ah=1
int
16h
;llamada al ROM BIOS
jnz
etiqw
;
call
leerraton
;
test
bx,1
;
jz
opcion1
;
sub
dx,40
;algoritmo para el mouse
mov
ax,dx
;
jmp
etiqr
;
etiqw: mov
ah,0
;algoritmo para el teclado
20
16h
al,ah
al,59
ah,ah
ax,10
finx
bl,6
bl
bx,f1
bx,ax
bx
opcion
graf1
ya
graf2
ya
graf3
ya
graf4
ya
graf5
ya
graf6
ya
graf7
ya
graf8
ya
graf9
ya
graf10
ya
fin
ah,8
21h
ah,0
al,2
10h
menu
ah,0
al,2
10h
ax
ds,ax
ax,MEMO
ES,ax
di,0
cx,2000
ax,pan[di]
es:[DI],ax
di,2
ir01
ah,4ch
21h
near
xx0,40
yy0,12
car,0dbh
escrib
punteroon
ax
ah,0h
16h
ah,04dh
;
;
;
;
;
;Compara con Esc
;
;
;
;
;
;Fin de opciones
;Llama procedimientos graf
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;
;Salida de bifurcacion
;
;Espera que se pulse una tecla, sin eco.
;
;Modo
; normal de
; pantalla 80 x 25
;
;Modo
; normal de
; pantalla
;
;
;Inicio de memoria de pantalla
;
;LOAD SCREEN
;longitud de pantalla
;
;
;
;
;Salida al DOS con codigo
;
de errores.
;
;Movimiento controlado de un caracter en modo
;Inicializa el modo texto.
;
;
21
de
ah,04bh
iz
ah,048h
ax
ret
z3:mov
jmp
graf1 endp
yy0,00
w3
graf2
proc
near
modot
mov
xx0,40
mov
yy0,12
mov
car,0dbh
call
escrib
call
punteroon
push
ax
tecla: mov
ah,0h
int
16h
cmp
ah,04dh
w7: add
yy0,01
jmp
escrit
escrit:mov
car,0dbh
call
escrib
jmp
tecla
z4:mov
xx0,00
jmp
w4
z5:mov
xx0,80
jmp
w5
z6:mov
yy0,25
jmp
w6
z7:mov
yy0,00
jmp
w7
esca:pop
ax
ret
graf2 endp
graf3
call
cuad
proc
modot
call
push
push
push
push
mov
mov
pixel
loop
ret
endp
;MOVIMIENTO TEXTO
;Activa mouse
near
punteroon
ax
bx
cx
dx
xx0,40
yy0,12
ir63
graf4 proc
near
mov
col,61
mov
cx,517
ale: inc
col
call
pixel
loop
ale
cmp
fil,437
jl
mar
ret
graf4 endp
graf5 proc
near
call
modo
add
fil,01
cmp
long1,00
jg
iiii
ret
;CUADRADO RELLENO
22
endp
proc
near
call
modo
call
punteroon
push
ax
i01:mov
col,90
mov
fil,10
mov
long1,460
mov
long2,460
i00:mov
color,01
cmp
al,27
jne
i01
pop
ax
ret
graf6 endp
graf7 proc
near
call
modo
call
punteroon
mov
col,19
mov
fil,79
mov
color,01
mov
long1,300
mov
col,320
mov
fil,220
mov
color,0fh
call
pixel
push
ax
tcla: call
guard
mov
ah,0h
int
16h
cmp
ah,047h
modo
proc
near
mov
ah,0h
mov
al,video
int
10h
ret
mov
ah,02h
mov
dh,yy0
mov
dl,xx0
mov
bh,0h
int
10h
mov
ah,09h
mov
bh,0h
mov
bl,03h
mov
cx,01
mov
al,car
int
10h
pop
dx
pop
cx
pop
bx
pop
ax
ret
escri endp
salva proc
near
mov
ax,MEMO
mov
ES,ax
mov
di,0
MOV
cx,2000
sal0:MOV
ax,es:[DI]
mov
pan[di],ax
add
di,2
loop
sal0
mov
ax,ds
ret
salva endp
guard proc
near
push
ax
push
bx
23
guard
borra
borra
pixe1
pixe1
pixel
mov
mov
mov
mov
pop
pop
ret
endp
proc
push
push
push
mov
mov
mov
mov
int
pop
pop
pop
ret
endp
proc
push
push
push
mov
mov
mov
mov
int
pop
pop
pop
ret
endp
proc
push
push
push
mov
mov
mov
ax,fil
bx,col
fi1,ax
co1,bx
bx
ax
near
cx
dx
ax
cx,co1
dx,fi1
ax,00h
ah,0ch
10h
ax
dx
cx
near
cx
dx
ax
cx,col
dx,fil
al,0fh
ah,0ch
10h
ax
dx
cx
near
cx
dx
ax
cx,col
dx,fil
ax,color
;color
;Escribe pixel
;color
;Escribe pixel
;color
ret
leerraton endp
punteroxy proc near
mov ax,4
sub bx,bx
int 51
ret
punteroxy endp
resetraton proc near
mov ax,0
int 51
ret
resetraton endp
cseg
ends
end
ini
24
25
26
27
29
9 BIBLIOGRAFIA
http://club.telepolis.com/mydream/Asm/ASM1.html
http://www.uhu.es/tomas.mateo/ac2/manual%20ensamblador%20UHU.pdf
30