Vistas de página en total

domingo, 12 de mayo de 2013

DOS


En esta cabecera se encuentran definidas las principales funciones del dos, para manejo de ficheros, directorios y memoria.
    Al inicio están definidas las constantes de manejo de unidades y atributos de ficheros.




DOS.MAC

; Copyright (C) 2013  José Ángel Moneo Fernández

;    This program is free software: you can redistribute it and/or modify
;    it under the terms of the GNU General Public License as published by
;    the Free Software Foundation, either version 3 of the License, or
;   (at your option) any later version.

;    This program is distributed in the hope that it will be useful,
;    but WITHOUT ANY WARRANTY; without even the implied warranty of
;    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;    GNU General Public License for more details.

;    You should have received a copy of the GNU General Public License
;    along with this program.  If not, see <http://www.gnu.org/licenses/>.
; definición de unidades
ifndef _unidades
    _unidades equ 1
;unidades
_A equ  0
_B equ 1
_C equ 2
_D equ 3
endif

; definición de atributos de ficheros y directorios
ifndef _atributos
   _atributos equ 1
;;atributos de fichero
_O_READ  equ 1
_HIDE    equ 2
_SISTEM  equ 4
_VOL     equ 8
_DIR     equ 16
_ARCHIVO equ 32
_TODOS   equ 00111111B
endif

; borrar de fichero
delete macro file
    mov ah,41h
    push dx
    lea dx,file
    int 21h
    pop dx
 endm

; renombrar fichero
 rename macro file,file1
     push es
     push dx
     push di
     lea dx,file
     lea di,file1
     mov ah,56h
     push ds
     pop es
     int 21h
     pop di
     pop dx
     pop es
 endm

; crear directorio
mkdir macro subdir
    mov ah,39h
    push dx
    lea dx,subdir
    int 21h
    pop dx
endm

;renombrar directorio
rmdir macro subdir
    mov ah,3ah
    push dx
    lea dx,subdir
    int 21h
    pop dx
endm

;cambiar de directorio
chdir macro subdir
    mov ah,3bh
    push dx
    lea dx,subdir
    int 21h
    pop dx
endm

; tomar el directorio actual
getcurdir macro  unidad,destino
    mov ah,47h
    push dx
    push si
    mov dl,unidad
    lea si,destino
    int 21h
    pop si
    pop dx
  endm

;colocar atriburos a un fichero
setattr macro file, atributo
    push dx
    push cx
    lea dx,file
    mov cx,atributo
    mov ax,4301h
    int 21h
    pop cx
    pop dx
endm

;leer los atributos de fichero
getattr macro file
    local sal
    push dx
    push cx
    lea dx,file
    mov ax,4300h
    int 21h
    jc sal
    mov ax,cx
 sal:
    pop cx
    pop dx
endm

; moverse a una unidad
setdisk macro unidad
    mov ah, 0eh
    PUSH DX
    mov dl, unidad
    int 21h
    POP DX
    endm

;tomar la unidad activa
getdisk macro unidad
    mov ah, 19h
    int 21h
    mov unidad,al
    endm

;interceptar una interupción
setint macro inter,posicion
ifndef _set_inter
     extrn _set_inter:near
endif
        mov ax,offset posicion
        push ax
        mov ax,seg posicion
        push ax
        mov ax,inter
        push ax
        call _set_inter
        add sp,6
 endm

; Finalizar y dejar residente
keep macro fin,codigo
        mov al,codigo
        mov ah,31h
        mov dx,offset fin
        mov cl,4
        shr dx,cl
        int 21h
 endm

; tomar la interrupción
 getint macro segmento,offset
        push bx
        push cx
        mov ah,35h
        int 21h
        mov ax,es
        mov segmento,ax
        mov offset,bx
        pop es
        pop bx
      endm

;Nos devuelve el tipo de sistema operativo
 ;ah numero menor
 ;al numero mayor
 ;bx,cx numero serie
 dosver macro
        mov ah,30h
        int 21h
      endm

 ;devuelve en buffer el segmento donde consigue la mamoria pedida
farmalloc macro segmento,tamano
        push bx
        push cx
        mov ah,48h
        mov bx,tamano
        mov cl,4
        shr bx,cl
        int 21h
        mov segmento,ax
        pop cx
        pop bx
 endm


;liverar memoria
 farfree macro segmento
        push es
        mov ah,49h
        mov es,buffer
        int 21h
        pop es
 endm



No hay comentarios:

Publicar un comentario

Si tienes algún comentario, duda o sugerencia, o si quieres aportar algún código creado a partir de las librerías expuestas aquí, por favor, indícamelo.