DCPU16 23
[COAL] Check if it is even or odd number Guest on 21st January 2021 07:37:52 PM
  1.                                                         ;write a program that checks wether the entered
  2. ;number is even or odd using div.
  3. display macro p1
  4.     mov ah,9
  5.     mov dx,offset p1
  6.     int 21h
  7. endm
  8. .model small
  9. .stack 100h
  10. .data
  11. msg1 db 10,13,'even number$'
  12. msg2 db 10,13,'Odd number$'
  13. msg3 db 'Please enter any number:$'
  14. .code
  15. main proc
  16.     mov ax,@data
  17.     mov ds,ax
  18.     display msg3
  19.     mov ah,1
  20.     int 21h
  21.     mov ah,0
  22.     mov bl,2
  23.     div bl  ;ah=reminder; al=quotient
  24.     cmp ah,0
  25.     je L1
  26.     jne L2
  27. L2:
  28.     display msg2
  29.     jmp end1
  30. L1:
  31.     display msg1
  32.     jmp end1
  33. end1:
  34.     mov ah,4ch
  35.     int 21h
  36.        
  37.     main endp
  38. end main

Coding Base is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.