Created
January 7, 2021 19:55
-
-
Save Kop3sh/6e0a36633c157b77aa1271c4c36f81aa to your computer and use it in GitHub Desktop.
sorting
This file contains 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
include emu8086.inc | |
NEWLINE MACRO | |
mov ah, 2 | |
;newline and cret | |
mov dl, 0ah | |
int 21h | |
mov dl, 0dh | |
int 21h | |
ENDM | |
GET_UNS_NUM MACRO storeAddr | |
PRINT 'Enter a number (between 001 and 255): ' | |
mov ah, 1 | |
mov cx, 03 | |
mov di, 1000h | |
input: | |
int 21h | |
sub al, '0' | |
mov [di], al | |
inc di | |
loop input | |
NEWLINE | |
;converting input to decimal and storing it | |
mov di, 1000h | |
mov al, [di] | |
mov cl, 100 | |
mul cl | |
mov dl, al | |
jo error | |
inc di | |
mov al, [di] | |
mov cl, 10 | |
mul cl | |
inc di | |
add al, [di] | |
add al, dl | |
mov [si], al | |
;checks if al==0 | |
cmp al, 00 | |
je error | |
jnc cont | |
error: | |
mov dx, offset err_msg | |
mov ah, 9 | |
int 21h | |
NEWLINE | |
INT 20h | |
cont: | |
mov [storeAddr], al | |
ENDM | |
org 100h | |
GET_UNS_NUM [n] | |
mov bp, 0 | |
mov cl, 0 | |
get_vals: | |
mov al, x[bp] | |
GET_UNS_NUM al | |
inc bp | |
cmp cl, n | |
jne get_vals | |
INT 20h | |
DEFINE_SCAN_NUM | |
err_msg db "Enter a valid number...Exiting the program !! $" | |
n db 0 | |
x db n DUP(0) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment