Advertisement
green1ant

laba1

Mar 10th, 2019
223
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.         org 100h
  2.  
  3. Start:
  4.  
  5. Greeting:
  6.         mov     ah, $09
  7.         mov     dx, greeting
  8.         int 21h
  9.  
  10. Input:
  11.         mov     ah, $0A
  12.         mov     dx, inputString
  13.         int 21h
  14.  
  15.         ;go next line
  16.         mov     ah, $09
  17.         mov     dx, nextLine
  18.         int 21h
  19.  
  20. CheckLength:
  21.         cmp     [inputString + 1], 4
  22.         jle     PrintNo
  23.  
  24. CheckEquality:
  25.         mov     dh, [inputString + 3]   ;dh!
  26.         cmp     dh, [inputString + 5]   ;dh!
  27.         jne     PrintNo
  28.  
  29. CheckLetter:
  30.         mov     ch, [inputString + 3]
  31.         cmp     ch, 'A'
  32.         jb      PrintNo
  33.         cmp     ch, 'z'
  34.         jg      PrintNo
  35.         cmp     ch, 'Z'
  36.         jb      CheckDigit
  37.         cmp     ch, 'a'
  38.         jg      CheckDigit
  39.  
  40. CheckDigit:
  41.         movsx   si, [inputString + 1]   ;store length here
  42.         mov     ch, [inputString + si]
  43.         cmp     ch, '0'
  44.         jb      PrintNo
  45.         cmp     ch, '9'
  46.         jg      PrintNo
  47.  
  48.         ;if everything was right
  49.         jmp     PrintYes
  50.  
  51. PrintNo:
  52.         mov     ah, $09
  53.         mov     dx, ansNo
  54.         int 21h
  55.         jmp Exit
  56.  
  57. PrintYes:
  58.         mov     ah, $09
  59.         mov     dx, ansYes
  60.         int 21h
  61.         jmp Exit
  62.  
  63. Exit:
  64.         mov     ah, $09
  65.         mov     dx, pressAnyKey
  66.         int 21h
  67.         mov     ah, $08
  68.         int 21h
  69.         ret
  70.  
  71. greeting        db "Enter your string:", 13, 10, "$"
  72. inputString     db 11, 0, 10 dup (?)
  73. nextLine        db 13, 10, "$"
  74. ansYes          db "Yes!", 13, 10, "$"
  75. ansNo           db "No!", 13, 10, "$"
  76. pressAnyKey     db 13, 10, "Press any key to exit...$"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement