Created
January 4, 2017 19:09
-
-
Save dutchand/58b28733bb082b3bf505e2b2fd8fffd6 to your computer and use it in GitHub Desktop.
Assembly
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| stack segment para stack 'stack' | |
| db 256 dup(0FFH) | |
| stack ends | |
| ; | |
| data segment para public 'data' | |
| arreglo DB 20 dup(?) | |
| data ends | |
| ; | |
| code segment para public 'code' | |
| assume cs:code | |
| mov ax,data | |
| mov ds,ax | |
| assume ds:data | |
| ;Inicio del programa | |
| main proc far | |
| ;Entrada de datos | |
| mov cx, 20 | |
| mov [si], offset arreglo | |
| Do2:mov ah, 01h | |
| int 21H | |
| mov ah,6 | |
| mov dl, ' ' | |
| int 21H | |
| mov [si], al | |
| inc si | |
| loop Do2 | |
| ;hallar mayor | |
| call mayor | |
| mov dx, ax | |
| ;hallar menor | |
| call menor | |
| mov bx, ax | |
| ;salida de datos | |
| mov cx, 20 | |
| mov si, offset arreglo | |
| Do3:mov ah,02H | |
| mov al, [si] | |
| int 21h | |
| loop Do3 | |
| ;mayor | |
| mov ah, 02H | |
| mov al,dl | |
| int 21H | |
| ;menor | |
| mov ah, 02H | |
| mov al,bl | |
| int 21H | |
| ;diferencia | |
| mov ah, 02H | |
| sub dx,bx | |
| mov al,dl | |
| int 21H | |
| mov ah, 4ch | |
| int 21H | |
| ret | |
| main endp | |
| mayor proc far | |
| mov cx, 20 | |
| mov si, offset arreglo | |
| mov ax, [si] | |
| inc si | |
| Do: cmp ax, [si] | |
| jl sw | |
| inc si | |
| loop Do | |
| sw: mov ax, [si] | |
| inc si | |
| loop Do | |
| ret | |
| mayor endp | |
| menor proc far | |
| mov cx, 20 | |
| mov si, offset arreglo | |
| mov ax, [si] | |
| inc si | |
| Do1:cmp ax, [si] | |
| jg sw2 | |
| inc si | |
| loop Do1 | |
| sw2: mov ax, [si] | |
| inc si | |
| loop Do1 | |
| ret | |
| menor endp | |
| code ends | |
| end main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment