Advertisement
Guest User

Untitled

a guest
Dec 8th, 2017
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. org 100h
  2.  
  3. .data
  4.    ;string variables to be printed
  5.     wi db 0ah, 0dh,"Wrong input, Press any key to back to the main menu...$"
  6.     aaf_ db 0ah, 0dh, "Please choose the type of the father's blood : $"
  7.     aam_ db 0ah, 0dh,"Please choose the type of the mother's blood : $"
  8.     aau_ db 0ah, 0dh,"Please choose your blood type : $"
  9.     give_to db 0ah, 0dh, "You are allowed to give your blood to somebody with blood type of : $"
  10.     rec_from db 0ah, 0dh, "You can only receive blood from people with blood type of : $"
  11.     bloods db 0ah, 0dh, "1-AB  2-A.  3-B.  4-O$"
  12.     choice_msg db "Choose a blood type : $"
  13.     sons db 0ah, 0dh, "Sons blood type is : $"
  14.     newline db 0ah, 0dh,'$'
  15.     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 >> $"
  16.      
  17.    
  18.     AB       db "AB$"
  19.     A_B      db "A,B$"
  20.     A_O      db "A,O$"
  21.     B_O      db "B,O$"
  22.     O        db "O$"  
  23.     A_B_AB   db "A,B,AB$"
  24.     A_B_AB_O db "A,B,AB,O$"
  25.     A_AB     db "A,AB$"
  26.     B_AB     db "B,AB$"
  27.    
  28.    
  29. .code  
  30. ;escape everything and jump to main
  31. jmp main
  32.  
  33.  
  34. ;blood labels
  35. AB_sons_blood:
  36.       lea dx,AB      
  37.       mov ah, 9              
  38.       int 21h
  39.       mov ah, 01h
  40.       int 21h
  41.       jmp main  
  42.          
  43. A_B_AB_sons_blood:
  44.       lea dx,A_B_AB  
  45.       mov ah, 9              
  46.       int 21h
  47.       mov ah, 01h
  48.       int 21h
  49.       jmp main  
  50.      
  51. A_B_sons_blood:
  52.       lea dx,A_B      
  53.       mov ah, 9              
  54.       int 21h  
  55.       mov ah, 01h
  56.       int 21h
  57.       jmp main  
  58.      
  59. A_B_AB_O_sons_blood:
  60.       lea dx,A_B_AB_O  
  61.       mov ah, 9              
  62.       int 21h    
  63.       mov ah, 01h
  64.       int 21h
  65.       jmp main  
  66.      
  67. A_O_sons_blood:
  68.       lea dx,A_O      
  69.       mov ah, 9              
  70.       int 21h
  71.       mov ah, 01h
  72.       int 21h
  73.       jmp main  
  74.          
  75. B_O_sons_blood:
  76.       lea dx,B_O      
  77.       mov ah, 9              
  78.       int 21h  
  79.       mov ah, 01h
  80.       int 21h
  81.       jmp main  
  82.      
  83. O_sons_blood:
  84.       lea dx,O        
  85.       mov ah, 9              
  86.       int 21h  
  87.       mov ah, 01h
  88.       int 21h
  89.       jmp main  
  90. A_AB_sons_blood:
  91.       lea dx,A_AB    
  92.       mov ah, 9              
  93.       int 21h  
  94.       mov ah, 01h
  95.       int 21h
  96.       jmp main    
  97.          
  98. B_AB_sons_blood:
  99.       lea dx,A_AB    
  100.       mov ah, 9              
  101.       int 21h  
  102.       mov ah, 01h
  103.       int 21h
  104.       jmp main
  105.  
  106. main:
  107.    ;init. the data segment
  108.     mov ax, @data
  109.     mov ds, ax
  110.                    
  111.     ;clear the screen
  112.     jmp clear_screen
  113.     back:
  114.    
  115.     ;printing the menu              
  116.     lea dx, menu
  117.     mov ah, 09h
  118.     int 21h                    
  119.    
  120.    
  121. read_input:    
  122.  
  123.     ;reading a char from the stdin and save its ascii code into the AL register
  124.     mov ah, 01h
  125.     int 21h
  126.                    
  127.     ;compring the values in AL to what we can porcess
  128.    ;if there is 1, 2, 3 or 4, jump to a certain label, if else, jump to wrong_input label
  129.     cmp al, '1'
  130.     je choice1
  131.    
  132.     cmp al, '2'
  133.     je choice2
  134.    
  135.     cmp al, '3'
  136.     je choice3
  137.    
  138.     cmp al, '4'
  139.     je halting
  140.    
  141.     jmp wrong_input          
  142.    
  143.    
  144. ;our labels
  145.  
  146. choice1:
  147.    ;get the father's blood type
  148.     lea dx, aaf_
  149.     mov ah, 09h
  150.     int 21h      
  151.    
  152.     lea dx, bloods
  153.     int 21h
  154.     lea dx, newline
  155.     int 21h
  156.     lea dx, choice_msg
  157.     int 21h
  158.    
  159.     ;get the father's blood type and store it in BL
  160.     mov ah, 01h
  161.     int 21h
  162.     mov bl, al  
  163.    
  164.     ;get the mother's blood type
  165.     lea dx, aam_
  166.     mov ah, 09h
  167.     int 21h      
  168.    
  169.     lea dx, bloods
  170.     int 21h
  171.     lea dx, newline
  172.     int 21h
  173.     lea dx, choice_msg
  174.     int 21h
  175.    
  176.     ;get the mothre's blood type and store it in BL
  177.     mov ah, 01h
  178.     int 21h
  179.     mov bh, al    
  180.    
  181.     ;print the sons message
  182.     lea dx, sons    
  183.     mov ah, 09h
  184.     int 21h
  185.    
  186.     ;do some operations on the moms and dad blood types to figure out the sons blood types
  187.    ;figure out the dad's blood type
  188.    
  189.      cmp bl,'1'
  190.      je AB_blood  
  191.      
  192.      cmp bl,'2'
  193.      je A_blood  
  194.      
  195.      cmp bl,'3'
  196.      je B_blood    
  197.      
  198.      cmp bl,'4'
  199.      je O_blood    
  200.      
  201.      jmp wrong_input
  202.                          
  203.                    
  204.     ;doing that same for mom's blood and jump to a certain label to print a certain message
  205.                        
  206. AB_blood:
  207.       cmp bh,'1'
  208.       je AB_sons_blood  
  209.       cmp bh,'2'
  210.       je A_B_AB_sons_blood
  211.       cmp bh,'3'
  212.       je A_B_AB_sons_blood  
  213.       cmp bh,'4'
  214.       je A_B_sons_blood
  215.       jmp wrong_input
  216.      
  217. A_blood:
  218.       cmp bh,'1'
  219.       je A_B_AB_sons_blood  
  220.       cmp bh,'2'
  221.       je A_O_sons_blood
  222.       cmp bh,'3'
  223.       je A_B_AB_O_sons_blood  
  224.       cmp bh,'4'
  225.       je A_O_sons_blood
  226.       jmp wrong_input
  227.      
  228. B_blood:
  229.       cmp bh,'1'
  230.       je A_B_AB_sons_blood  
  231.       cmp bh,'2'
  232.       je A_B_AB_O_sons_blood
  233.       cmp bh,'3'
  234.       je B_O_sons_blood  
  235.       cmp bh,'4'
  236.       je B_O_sons_blood
  237.       jmp wrong_input
  238.      
  239. O_blood:
  240.       cmp bh,'1'
  241.       je A_B_sons_blood  
  242.       cmp bh,'2'
  243.       je A_O_sons_blood
  244.       cmp bh,'3'
  245.       je B_O_sons_blood  
  246.       cmp bh,'4'
  247.       je O_sons_blood
  248.       jmp wrong_input
  249.    
  250.    
  251.    
  252. choice2:  
  253.    ;print the message that asks about your blood type
  254.     lea dx, aau_
  255.     mov ah, 09h
  256.     int 21h  
  257.    ;print the bloods list
  258.     lea dx, bloods
  259.     int 21h
  260.    
  261.     ;read blood type number
  262.     mov ah, 01h
  263.     int 21h        
  264.    ;store it in BL
  265.     mov bl, al
  266.    
  267.     ;prints who to donate to message
  268.     lea dx, give_to
  269.     mov ah, 09h
  270.     int 21h;
  271.                
  272.     ;do the checking operation and give the user the result
  273.    
  274.     cmp bl,'1'
  275.     je AB_sons_blood  
  276.     cmp bl,'2'
  277.     je A_AB_sons_blood
  278.     cmp bl,'3'
  279.     je B_AB_sons_blood
  280.     cmp bl,'4'
  281.     je A_B_AB_O_sons_blood
  282.     jmp wrong_input
  283.    
  284.  
  285. choice3:
  286.    
  287.     ;print the message that asks about your blood type
  288.     lea dx, aau_
  289.     mov ah, 09h
  290.     int 21h  
  291.    ;print the bloods list
  292.     lea dx, bloods
  293.     int 21h
  294.    
  295.     ;read blood type number
  296.     mov ah, 01h
  297.     int 21h        
  298.    ;store it in BL
  299.     mov bl, al
  300.    
  301.     ;print receive from message
  302.     lea dx, rec_from
  303.     mov ah, 09h
  304.     int 21h
  305.    
  306.     ;do the operations and print out the result
  307.    
  308.      cmp bl,'1'
  309.      je A_B_AB_O_sons_blood  
  310.      cmp bl,'2'
  311.      je A_O_sons_blood
  312.      cmp bl,'3'
  313.      je B_O_sons_blood  
  314.      cmp bl,'4'
  315.      je O_sons_blood
  316.      jmp wrong_input
  317.          
  318.          
  319. halting:  
  320.    ;perform a clear halting
  321.     mov ah, 4ch
  322.     int 21h
  323.  
  324. wrong_input:
  325.    
  326.     ;prints the wrong input message
  327.     lea dx, wi
  328.     mov ah, 09h
  329.     int 21h  
  330.    ;wait for the user to press a key
  331.     mov ah, 01h
  332.     int 21h
  333.     jmp main
  334.  
  335. clear_screen:
  336.  
  337.     mov al, 03h
  338.     mov ah, 0h
  339.     int 10h
  340.     jmp back
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement