TITLE Sort names entered from terminal (bsort.asm)
.MODEL small
.STACK 256
INCLUDE macs.inc
.DATA
nameprm label byte ;name prm list:
maxlen db 21 ; max length of name
namelen db ? ; # of char's entered
namefld db 21 dup(' '),'$' ; name & delimiter
; for displaying
crlf db 13, 10, '$'
end_addr dw ?
prompt db 'Name? ','$'
count db 0
name_tbl db 30 dup(20 dup(' ')) ; name table
name_sav db 20 dup(?), 13,10,'$'
did_excg db 0
.CODE
;---------------------------------------------------------
; the MAIN procedure
main proc
mov ax,@data ;init segment regs
mov ds,ax
mov es,ax
cld
lea di,name_tbl
ClearScreen
mov dx,0000
SetCur
mloop:
call name_in ;input name
cmp namelen,0 ;name entered?
jz @@30 ; if not goto sort
cmp count,30 ;30 names entered?
je @@30 ; if so goto sort
call sto_name ;store entered name in tbl
jmp mloop
@@30:
ClearScreen
mov dx,0000
SetCur
cmp count,1 ;one or no names entered?
jbe mexit ;if yes , then exit
call bsort
call dis_names ;display sorted names
mexit:
mov ah,4ch
int 21h
main endp ;end main procedure
im suppose to write the procedures for this.. but i cant figure out how to write the sto_name proc.. all i know is im suppose to use the rep movsw command please give me some hints if you can
.MODEL small
.STACK 256
INCLUDE macs.inc
.DATA
nameprm label byte ;name prm list:
maxlen db 21 ; max length of name
namelen db ? ; # of char's entered
namefld db 21 dup(' '),'$' ; name & delimiter
; for displaying
crlf db 13, 10, '$'
end_addr dw ?
prompt db 'Name? ','$'
count db 0
name_tbl db 30 dup(20 dup(' ')) ; name table
name_sav db 20 dup(?), 13,10,'$'
did_excg db 0
.CODE
;---------------------------------------------------------
; the MAIN procedure
main proc
mov ax,@data ;init segment regs
mov ds,ax
mov es,ax
cld
lea di,name_tbl
ClearScreen
mov dx,0000
SetCur
mloop:
call name_in ;input name
cmp namelen,0 ;name entered?
jz @@30 ; if not goto sort
cmp count,30 ;30 names entered?
je @@30 ; if so goto sort
call sto_name ;store entered name in tbl
jmp mloop
@@30:
ClearScreen
mov dx,0000
SetCur
cmp count,1 ;one or no names entered?
jbe mexit ;if yes , then exit
call bsort
call dis_names ;display sorted names
mexit:
mov ah,4ch
int 21h
main endp ;end main procedure
im suppose to write the procedures for this.. but i cant figure out how to write the sto_name proc.. all i know is im suppose to use the rep movsw command please give me some hints if you can