Vistas de página en total

jueves, 30 de mayo de 2013

RESTA

Siguiendo con las funciones matemáticas y con la misma filosofía. Aquí está la resta de dos variables.


RESTA.ASM
; 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/>.
;resta al minuendo el substraendo dejandolo en  resultado

; codigo

include main.mac
_modelo exe
_code
rutina _resta min,subs,res
        push bx                      ;salva los registros usados
        push si
        push di
        mov si,[bp].min        ; recoge las direcciones de las variables
        mov bx,[bp].subs
        mov di,[bp].res
        mov ax,[si]                ; opera los datos, primera palabra
        sub ax,[bx]
        mov [di],ax
        mov ax,[si+2]            ; opera los datos, segunda palabra 
        sbb ax,[bx+2]
        mov [di+2],ax           ; almacena el resultado en la dirección de la variable indicada
        pop di                         ; recupera los registros para que la función sea transparente
        pop si
        pop bx
        pop bp
        ret
_resta endp
_data
_end

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.