I need help with two things, I nedd to incorporate a bubble sort that need to rearrange the entries in both arrays. Also Ive tried to use a search but it didnt work, So any help with a sequential search would be a big help. Heres some of the code.
INCLUDE Irvine16.inc
.DATA
.CODE
Driver PROC
MOV AX, @DATA
MOV DS, AX
TOP:
CALL DisplayMenu
CALL GetChoice
CHECK1:
CMP EAX, 1
JNE CHECK2
CALL Init
JMP TOP
CHECK2:
CMP EAX, 2
JNE CHECK3
CALL Insert
JMP TOP
CHECK3:
CMP EAX, 3
JNE CHECK4
CALL Display
JMP TOP
CHECK4:
CMP EAX, 4
JNE CHECK5
CALL FindEid
JMP TOP
CHECK5:
CMP EAX, 5
JNE CHECK6
CALL FindSsn
JMP TOP
CHECK6:
CMP EAX, 6
JNE CHECK7
CALL Delete
JMP TOP
CHECK7:
CMP EAX, 7
JNE CHECK8
CALL SortEid
JMP TOP
CHECK8:
CMP EAX, 8
JNE CHECK9
CALL SortSsn
JMP TOP
CHECK9:
CALL Quit
exit
Driver ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
DisplayMenu PROC USES EDX
.DATA
menuLine1 BYTE "1. Initialize database", 0
menuLine2 BYTE "2. Insert employee", 0
menuLine3 BYTE "3. Display all data", 0
menuLine4 BYTE "4. Search on EID", 0
menuLine5 BYTE "5. Search on SSN", 0
menuLine6 BYTE "6. Delete employee", 0
menuLine7 BYTE "7. Sort by EID", 0
menuLine8 BYTE "8. Sort by SSN", 0
menuLine9 BYTE "9. Quit", 0
.CODE
CALL Crlf
MOV EDX, OFFSET menuLine1
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine2
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine3
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine4
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine5
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine6
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine7
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine8
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine9
CALL WriteString
CALL Crlf
RET
DisplayMenu ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
GetChoice PROC USES EDX
.DATA
prompt BYTE "Your choice? (1...9) ", 0
bad_choice BYTE "...invalid choice...try again...", 0
.CODE
TOP:
CALL Crlf
MOV EDX, OFFSET prompt
CALL WriteString
CALL ReadInt
JNC VALID_INT
INVALID_CHOICE:
CALL Crlf
MOV EDX, OFFSET bad_choice
CALL WriteString
CALL Crlf
JMP TOP
VALID_INT:
CALL Crlf
CMP EAX, 1
JL INVALID_CHOICE
CMP EAX, 9
JG INVALID_CHOICE
RET
GetChoice ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
ProcessChoice PROC
PUSHFD
CHECK1:
CMP EAX, 1
JNE CHECK2
CALL Init
JMP DONE
CHECK2:
CMP EAX, 2
JNE CHECK3
CALL Insert
JMP DONE
CHECK3:
CMP EAX, 3
JNE CHECK4
CALL Display
JMP DONE
CHECK4:
CMP EAX, 4
JNE CHECK5
CALL FindEid
JMP DONE
CHECK5:
CMP EAX, 5
JNE CHECK6
CALL FindSsn
JMP DONE
CHECK6:
CMP EAX, 6
JNE CHECK7
CALL Delete
JMP DONE
CHECK7:
CMP EAX, 7
JNE CHECK8
CALL SortEid
JMP DONE
CHECK8:
CMP EAX, 8
JNE CHECK9
CALL SortSsn
JMP DONE
CHECK9:
CALL Quit
DONE:
POPFD
RET
ProcessChoice ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
Init PROC
.DATA
initMsg BYTE "Hello from 'Init'", 0
.CODE
MOV EDX, OFFSET initMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
Init ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
Insert PROC
.DATA
insertMsg BYTE "Hello from 'Insert'", 0
.CODE
MOV EDX, OFFSET insertMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
Insert ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
Display PROC
.DATA
displayMsg BYTE "Hello from 'Display'", 0
.CODE
MOV EDX, OFFSET displayMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
Display ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
FindEid PROC
.DATA
findEidMsg BYTE "Hello from 'FindEid'", 0
.CODE
MOV EDX, OFFSET findEidMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
FindEid ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
FindSsn PROC
.DATA
findSsnMsg BYTE "Hello from 'FindSsn'", 0
.CODE
MOV EDX, OFFSET findSsnMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
FindSsn ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
Delete PROC
.DATA
deleteMsg BYTE "Hello from 'Delete'", 0
.CODE
MOV EDX, OFFSET deleteMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
Delete ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
SortEid PROC
.DATA
sortEidMsg BYTE "Hello from 'SortEid'", 0
.CODE
MOV EDX, OFFSET sortEidMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
SortEid ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
SortSsn PROC
.DATA
sortSsnMsg BYTE "Hello from 'SortSsn'", 0
.CODE
MOV EDX, OFFSET sortSsnMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
SortSsn ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
Quit PROC
.DATA
byeMsg BYTE "Bye...", 0
.CODE
MOV EDX, OFFSET byeMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
Quit ENDP
END Driver
INCLUDE Irvine16.inc
.DATA
.CODE
Driver PROC
MOV AX, @DATA
MOV DS, AX
TOP:
CALL DisplayMenu
CALL GetChoice
CHECK1:
CMP EAX, 1
JNE CHECK2
CALL Init
JMP TOP
CHECK2:
CMP EAX, 2
JNE CHECK3
CALL Insert
JMP TOP
CHECK3:
CMP EAX, 3
JNE CHECK4
CALL Display
JMP TOP
CHECK4:
CMP EAX, 4
JNE CHECK5
CALL FindEid
JMP TOP
CHECK5:
CMP EAX, 5
JNE CHECK6
CALL FindSsn
JMP TOP
CHECK6:
CMP EAX, 6
JNE CHECK7
CALL Delete
JMP TOP
CHECK7:
CMP EAX, 7
JNE CHECK8
CALL SortEid
JMP TOP
CHECK8:
CMP EAX, 8
JNE CHECK9
CALL SortSsn
JMP TOP
CHECK9:
CALL Quit
exit
Driver ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
DisplayMenu PROC USES EDX
.DATA
menuLine1 BYTE "1. Initialize database", 0
menuLine2 BYTE "2. Insert employee", 0
menuLine3 BYTE "3. Display all data", 0
menuLine4 BYTE "4. Search on EID", 0
menuLine5 BYTE "5. Search on SSN", 0
menuLine6 BYTE "6. Delete employee", 0
menuLine7 BYTE "7. Sort by EID", 0
menuLine8 BYTE "8. Sort by SSN", 0
menuLine9 BYTE "9. Quit", 0
.CODE
CALL Crlf
MOV EDX, OFFSET menuLine1
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine2
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine3
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine4
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine5
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine6
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine7
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine8
CALL WriteString
CALL Crlf
MOV EDX, OFFSET menuLine9
CALL WriteString
CALL Crlf
RET
DisplayMenu ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
GetChoice PROC USES EDX
.DATA
prompt BYTE "Your choice? (1...9) ", 0
bad_choice BYTE "...invalid choice...try again...", 0
.CODE
TOP:
CALL Crlf
MOV EDX, OFFSET prompt
CALL WriteString
CALL ReadInt
JNC VALID_INT
INVALID_CHOICE:
CALL Crlf
MOV EDX, OFFSET bad_choice
CALL WriteString
CALL Crlf
JMP TOP
VALID_INT:
CALL Crlf
CMP EAX, 1
JL INVALID_CHOICE
CMP EAX, 9
JG INVALID_CHOICE
RET
GetChoice ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
ProcessChoice PROC
PUSHFD
CHECK1:
CMP EAX, 1
JNE CHECK2
CALL Init
JMP DONE
CHECK2:
CMP EAX, 2
JNE CHECK3
CALL Insert
JMP DONE
CHECK3:
CMP EAX, 3
JNE CHECK4
CALL Display
JMP DONE
CHECK4:
CMP EAX, 4
JNE CHECK5
CALL FindEid
JMP DONE
CHECK5:
CMP EAX, 5
JNE CHECK6
CALL FindSsn
JMP DONE
CHECK6:
CMP EAX, 6
JNE CHECK7
CALL Delete
JMP DONE
CHECK7:
CMP EAX, 7
JNE CHECK8
CALL SortEid
JMP DONE
CHECK8:
CMP EAX, 8
JNE CHECK9
CALL SortSsn
JMP DONE
CHECK9:
CALL Quit
DONE:
POPFD
RET
ProcessChoice ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
Init PROC
.DATA
initMsg BYTE "Hello from 'Init'", 0
.CODE
MOV EDX, OFFSET initMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
Init ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
Insert PROC
.DATA
insertMsg BYTE "Hello from 'Insert'", 0
.CODE
MOV EDX, OFFSET insertMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
Insert ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
Display PROC
.DATA
displayMsg BYTE "Hello from 'Display'", 0
.CODE
MOV EDX, OFFSET displayMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
Display ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
FindEid PROC
.DATA
findEidMsg BYTE "Hello from 'FindEid'", 0
.CODE
MOV EDX, OFFSET findEidMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
FindEid ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
FindSsn PROC
.DATA
findSsnMsg BYTE "Hello from 'FindSsn'", 0
.CODE
MOV EDX, OFFSET findSsnMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
FindSsn ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
Delete PROC
.DATA
deleteMsg BYTE "Hello from 'Delete'", 0
.CODE
MOV EDX, OFFSET deleteMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
Delete ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
SortEid PROC
.DATA
sortEidMsg BYTE "Hello from 'SortEid'", 0
.CODE
MOV EDX, OFFSET sortEidMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
SortEid ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
SortSsn PROC
.DATA
sortSsnMsg BYTE "Hello from 'SortSsn'", 0
.CODE
MOV EDX, OFFSET sortSsnMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
SortSsn ENDP
;--------------------------------------------------------------------
;
;--------------------------------------------------------------------
Quit PROC
.DATA
byeMsg BYTE "Bye...", 0
.CODE
MOV EDX, OFFSET byeMsg
CALL Crlf
CALL WriteString
CALL Crlf
RET
Quit ENDP
END Driver