×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Help with a database program

Help with a database program

Help with a database program

(OP)
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

RE: Help with a database program

Where's the array?

If you're doing a lot of repititive code, chances are you're doing it inefficiently.

Also, I suggest you sort INDEXES and not the actual records, moving records around can be *** time-consuming.

"Information has a tendency to be free.  Which means someone will always tell you something you don't want to know."

RE: Help with a database program

err... if I understand correctly you haven't sent us any code except the menu-reading bit.
You need to decide how to store your data. There are lots of possibilities, but AmkG is right to suggest you choose something where you don't need to move the actual text around when you sort.
You could try looking at the chapters on linked lists in any good textbook. These are sets of records consisting of all the data, plus pointers to the records "above" and "below" in the list. Well, that's doubly linked. There are also singly linked lists that contain just one pointer, the "next" in the list.
These are relatively easy to sort, because you only need to change the pointers, not move the whole data. For instance,
swapping two elements B&C in the list A,B,C,D is now a matter of setting A's "next" to point to C instead of B, C must point to B, and B must point to D. The rest of the list is unchanged.
You will probably find search algorithms too, which you can simply adapt.
Don't even think bubble-sort. It may be relatively easy to programme, but its performance is about as bad as a search routine can reasonably get. If you don't feel up to implementing quicksort, have a bash at shellsort.
Have fun.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close