Okay so I'm really new at this. I have to do an assignment that sorts through two strings that are inputs. these strings are names so will say name1 and name2, then once the user puts the names in it will then sort and print alphabetically on the screen. Any help would be greatly appreciated
Posted on 2006-04-11 10:45:16 by big_bad_wolf_582
Posted on 2006-04-11 10:45:16 by big_bad_wolf_582
What part do you need help with? If this is an assignment for a class, and they have been teaching you, you should know the basics by now (INPUT/OUTPUT).
We really need to know where you are at and what you are programming in (DOS/Windows/etc???) in order to give you any useful advice.
We really need to know where you are at and what you are programming in (DOS/Windows/etc???) in order to give you any useful advice.
Okay so ive got the comparing down i think! Here is my code thus far.
page Add two numbers and store the results into the third variable 60,132
TITLE A04ASM1 (EXE) Move and add operations
; ---------------------------------------------
STACK SEGMENT PARA STACK 'Stack'
STACK ENDS
; ----------------------------------------------
DATASEG SEGMENT PARA 'Data'
prompt DB 'Enter 1st Name? ',0DH,0AH,'$'
promptnext DB 0DH,0AH,'Enter 2nd Name ',0DH,0AH,'$'
para_list label byte
max_len DB 10
act_len DB ?
input DB 10 DUP(' ')
para_list1 label byte
max_len1 DB 15
act_len1 DB ?
inputin DB 15 DUP(' ')
DATASEG ENDS
; -----------------------------------------------
CODESEG SEGMENT PARA 'Code'
MAIN PROC FAR
ASSUME SS:STACK,DS:DATASEG,CS:CODESEG
MOV AX,DATASEG ;Set address of data
MOV DS,AX ;segment in DS
CALL Q10CLEAR
A20:
MOV AX, 0B800H
MOV ES, AX
MOV AX, 0003H ; Set the current video mode to text mode
INT 10H ; INT 10H, function 00H (mode=03H is standard text)
MOV AX, 0500H ; Set the active page = 00
INT 10H
MOV DX,0000
CALL Q20CURSOR
CALL B10INPUT
CALL Q10CLEAR
CMP ACT_LEN,00
CALL COMPARE
A30: MOV AX,4C00H ;End processing
INT 21H
MAIN ENDP ;End of procedure
B10INPUT PROC NEAR
PUSH AX
PUSH DX
MOV AH,09H
LEA DX,PROMPT
INT 21H
MOV AH,0AH
LEA DX,PARA_LIST
INT 21H
MOV AH,09H
LEA DX,PROMPTNEXT
INT 21H
MOV AH,0AH
LEA DX,PARA_LIST1
INT 21H
POP DX
POP AX
RET
B10INPUT ENDP
COMPARE PROC NEAR
lea si, INPUT
lea di, INPUTIN
mov cx, 10
mov ax, 15
cmp cx, ax
ja NoSwap
xchg ax, cx
NoSwap: repe cmpsb
jne NotEqual
mov ax, 10
cmp ax, 15
NotEqual:
RET
COMPARE ENDP
Q10CLEAR PROC NEAR
PUSHA
MOV AH,06H ;clear and scroll
MOV AL,00H
MOV BH,0F1H ;white background, blue foreground
MOV CX,000H ;starting row:column
MOV DX,184FH ;ending row:column
INT 10H
POPA
INT 10H
RET
Q10CLEAR ENDP
Q20CURSOR PROC NEAR
MOV AH,02H
MOV BH,00
INT 10H
RET
Q20CURSOR ENDP
CODESEG ENDS ;End of segment
END MAIN ;End of program
But now how do i sort it alphabetically? it is already going through and comparing but i want the two names to sort from A- Z any help would be great. Thanks
page Add two numbers and store the results into the third variable 60,132
TITLE A04ASM1 (EXE) Move and add operations
; ---------------------------------------------
STACK SEGMENT PARA STACK 'Stack'
STACK ENDS
; ----------------------------------------------
DATASEG SEGMENT PARA 'Data'
prompt DB 'Enter 1st Name? ',0DH,0AH,'$'
promptnext DB 0DH,0AH,'Enter 2nd Name ',0DH,0AH,'$'
para_list label byte
max_len DB 10
act_len DB ?
input DB 10 DUP(' ')
para_list1 label byte
max_len1 DB 15
act_len1 DB ?
inputin DB 15 DUP(' ')
DATASEG ENDS
; -----------------------------------------------
CODESEG SEGMENT PARA 'Code'
MAIN PROC FAR
ASSUME SS:STACK,DS:DATASEG,CS:CODESEG
MOV AX,DATASEG ;Set address of data
MOV DS,AX ;segment in DS
CALL Q10CLEAR
A20:
MOV AX, 0B800H
MOV ES, AX
MOV AX, 0003H ; Set the current video mode to text mode
INT 10H ; INT 10H, function 00H (mode=03H is standard text)
MOV AX, 0500H ; Set the active page = 00
INT 10H
MOV DX,0000
CALL Q20CURSOR
CALL B10INPUT
CALL Q10CLEAR
CMP ACT_LEN,00
CALL COMPARE
A30: MOV AX,4C00H ;End processing
INT 21H
MAIN ENDP ;End of procedure
B10INPUT PROC NEAR
PUSH AX
PUSH DX
MOV AH,09H
LEA DX,PROMPT
INT 21H
MOV AH,0AH
LEA DX,PARA_LIST
INT 21H
MOV AH,09H
LEA DX,PROMPTNEXT
INT 21H
MOV AH,0AH
LEA DX,PARA_LIST1
INT 21H
POP DX
POP AX
RET
B10INPUT ENDP
COMPARE PROC NEAR
lea si, INPUT
lea di, INPUTIN
mov cx, 10
mov ax, 15
cmp cx, ax
ja NoSwap
xchg ax, cx
NoSwap: repe cmpsb
jne NotEqual
mov ax, 10
cmp ax, 15
NotEqual:
RET
COMPARE ENDP
Q10CLEAR PROC NEAR
PUSHA
MOV AH,06H ;clear and scroll
MOV AL,00H
MOV BH,0F1H ;white background, blue foreground
MOV CX,000H ;starting row:column
MOV DX,184FH ;ending row:column
INT 10H
POPA
INT 10H
RET
Q10CLEAR ENDP
Q20CURSOR PROC NEAR
MOV AH,02H
MOV BH,00
INT 10H
RET
Q20CURSOR ENDP
CODESEG ENDS ;End of segment
END MAIN ;End of program
But now how do i sort it alphabetically? it is already going through and comparing but i want the two names to sort from A- Z any help would be great. Thanks
OK, int 21 is DOS related, so I am going to change the name of your thread in order to attract more appropriate attention.
I don't have much time right now, but I will pick-through your code later and list anything worth noting.
I don't have much time right now, but I will pick-through your code later and list anything worth noting.