Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- org 100h
- .data
- ;string variables to be printed
- wi db 0ah, 0dh,"Wrong input, Press any key to back to the main menu...$"
- aaf_ db 0ah, 0dh, "Please choose the type of the father's blood : $"
- aam_ db 0ah, 0dh,"Please choose the type of the mother's blood : $"
- aau_ db 0ah, 0dh,"Please choose your blood type : $"
- give_to db 0ah, 0dh, "You are allowed to give your blood to somebody with blood type of : $"
- rec_from db 0ah, 0dh, "You can only receive blood from people with blood type of : $"
- bloods db 0ah, 0dh, "1-AB 2-A. 3-B. 4-O$"
- choice_msg db "Choose a blood type : $"
- sons db 0ah, 0dh, "Sons blood type is : $"
- newline db 0ah, 0dh,'$'
- menu db 0ah, 0dh,"Please select a choice from the menue :-",0ah, 0dh,0ah, 0dh,"1- Knowing your blood type.", 0ah, 0dh, "2- Knowing the factions that you can give your blood to.",0ah, 0dh, "3- Knowing the factions that you can receive blood from.", 0ah, 0dh,"4- Exit.", 0ah, 0dh, 0ah, 0dh, "Your Choice >> $"
- AB db "AB$"
- A_B db "A,B$"
- A_O db "A,O$"
- B_O db "B,O$"
- O db "O$"
- A_B_AB db "A,B,AB$"
- A_B_AB_O db "A,B,AB,O$"
- A_AB db "A,AB$"
- B_AB db "B,AB$"
- .code
- ;escape everything and jump to main
- jmp main
- ;blood labels
- AB_sons_blood:
- lea dx,AB
- mov ah, 9
- int 21h
- mov ah, 01h
- int 21h
- jmp main
- A_B_AB_sons_blood:
- lea dx,A_B_AB
- mov ah, 9
- int 21h
- mov ah, 01h
- int 21h
- jmp main
- A_B_sons_blood:
- lea dx,A_B
- mov ah, 9
- int 21h
- mov ah, 01h
- int 21h
- jmp main
- A_B_AB_O_sons_blood:
- lea dx,A_B_AB_O
- mov ah, 9
- int 21h
- mov ah, 01h
- int 21h
- jmp main
- A_O_sons_blood:
- lea dx,A_O
- mov ah, 9
- int 21h
- mov ah, 01h
- int 21h
- jmp main
- B_O_sons_blood:
- lea dx,B_O
- mov ah, 9
- int 21h
- mov ah, 01h
- int 21h
- jmp main
- O_sons_blood:
- lea dx,O
- mov ah, 9
- int 21h
- mov ah, 01h
- int 21h
- jmp main
- A_AB_sons_blood:
- lea dx,A_AB
- mov ah, 9
- int 21h
- mov ah, 01h
- int 21h
- jmp main
- B_AB_sons_blood:
- lea dx,A_AB
- mov ah, 9
- int 21h
- mov ah, 01h
- int 21h
- jmp main
- main:
- ;init. the data segment
- mov ax, @data
- mov ds, ax
- ;clear the screen
- jmp clear_screen
- back:
- ;printing the menu
- lea dx, menu
- mov ah, 09h
- int 21h
- read_input:
- ;reading a char from the stdin and save its ascii code into the AL register
- mov ah, 01h
- int 21h
- ;compring the values in AL to what we can porcess
- ;if there is 1, 2, 3 or 4, jump to a certain label, if else, jump to wrong_input label
- cmp al, '1'
- je choice1
- cmp al, '2'
- je choice2
- cmp al, '3'
- je choice3
- cmp al, '4'
- je halting
- jmp wrong_input
- ;our labels
- choice1:
- ;get the father's blood type
- lea dx, aaf_
- mov ah, 09h
- int 21h
- lea dx, bloods
- int 21h
- lea dx, newline
- int 21h
- lea dx, choice_msg
- int 21h
- ;get the father's blood type and store it in BL
- mov ah, 01h
- int 21h
- mov bl, al
- ;get the mother's blood type
- lea dx, aam_
- mov ah, 09h
- int 21h
- lea dx, bloods
- int 21h
- lea dx, newline
- int 21h
- lea dx, choice_msg
- int 21h
- ;get the mothre's blood type and store it in BL
- mov ah, 01h
- int 21h
- mov bh, al
- ;print the sons message
- lea dx, sons
- mov ah, 09h
- int 21h
- ;do some operations on the moms and dad blood types to figure out the sons blood types
- ;figure out the dad's blood type
- cmp bl,'1'
- je AB_blood
- cmp bl,'2'
- je A_blood
- cmp bl,'3'
- je B_blood
- cmp bl,'4'
- je O_blood
- jmp wrong_input
- ;doing that same for mom's blood and jump to a certain label to print a certain message
- AB_blood:
- cmp bh,'1'
- je AB_sons_blood
- cmp bh,'2'
- je A_B_AB_sons_blood
- cmp bh,'3'
- je A_B_AB_sons_blood
- cmp bh,'4'
- je A_B_sons_blood
- jmp wrong_input
- A_blood:
- cmp bh,'1'
- je A_B_AB_sons_blood
- cmp bh,'2'
- je A_O_sons_blood
- cmp bh,'3'
- je A_B_AB_O_sons_blood
- cmp bh,'4'
- je A_O_sons_blood
- jmp wrong_input
- B_blood:
- cmp bh,'1'
- je A_B_AB_sons_blood
- cmp bh,'2'
- je A_B_AB_O_sons_blood
- cmp bh,'3'
- je B_O_sons_blood
- cmp bh,'4'
- je B_O_sons_blood
- jmp wrong_input
- O_blood:
- cmp bh,'1'
- je A_B_sons_blood
- cmp bh,'2'
- je A_O_sons_blood
- cmp bh,'3'
- je B_O_sons_blood
- cmp bh,'4'
- je O_sons_blood
- jmp wrong_input
- choice2:
- ;print the message that asks about your blood type
- lea dx, aau_
- mov ah, 09h
- int 21h
- ;print the bloods list
- lea dx, bloods
- int 21h
- ;read blood type number
- mov ah, 01h
- int 21h
- ;store it in BL
- mov bl, al
- ;prints who to donate to message
- lea dx, give_to
- mov ah, 09h
- int 21h;
- ;do the checking operation and give the user the result
- cmp bl,'1'
- je AB_sons_blood
- cmp bl,'2'
- je A_AB_sons_blood
- cmp bl,'3'
- je B_AB_sons_blood
- cmp bl,'4'
- je A_B_AB_O_sons_blood
- jmp wrong_input
- choice3:
- ;print the message that asks about your blood type
- lea dx, aau_
- mov ah, 09h
- int 21h
- ;print the bloods list
- lea dx, bloods
- int 21h
- ;read blood type number
- mov ah, 01h
- int 21h
- ;store it in BL
- mov bl, al
- ;print receive from message
- lea dx, rec_from
- mov ah, 09h
- int 21h
- ;do the operations and print out the result
- cmp bl,'1'
- je A_B_AB_O_sons_blood
- cmp bl,'2'
- je A_O_sons_blood
- cmp bl,'3'
- je B_O_sons_blood
- cmp bl,'4'
- je O_sons_blood
- jmp wrong_input
- halting:
- ;perform a clear halting
- mov ah, 4ch
- int 21h
- wrong_input:
- ;prints the wrong input message
- lea dx, wi
- mov ah, 09h
- int 21h
- ;wait for the user to press a key
- mov ah, 01h
- int 21h
- jmp main
- clear_screen:
- mov al, 03h
- mov ah, 0h
- int 10h
- jmp back
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement