Advertisement
jasonpogi1669

Lab Activity 4 (Subtract 2 numbers using two variables) using Assembly

Feb 26th, 2021
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. .model small
  2.  
  3. .data
  4.  
  5. message1 db 10, 13, "1st Number: $"
  6. message2 db 10, 13, "2nd Number: $"
  7. message3 db 10, 13, "Difference = $"
  8. line db 10, 13, "-------------$"
  9. num1 db ?
  10. num2 db ?
  11.  
  12. .code
  13.  
  14. main proc far
  15.  
  16. mov ax, @data
  17. mov ds, ax
  18.  
  19. mov num1, 5 ; store 5 in 'num1' variable
  20. mov num2, 4 ; store 4 in 'num2' variable
  21.  
  22. lea dx, message1 ; print 'message1' variable
  23. mov ah, 09h
  24. int 21h
  25.  
  26. mov ah, 2 ; print 'num1' variable
  27. mov dl, num1 ; move 'num1' to dl
  28. add dl, 48 ; add 48 to dl to make it decimal
  29. int 21h
  30.  
  31. lea dx, message2 ; print 'message2' variable
  32. mov ah, 09h
  33. int 21h
  34.  
  35. mov ah, 2 ; print 'num2' variable
  36. mov dl, num2 ; mov 'num2' to dl
  37. add dl, 48 ; add 48 to dl to make it decimal
  38. int 21h
  39.  
  40. lea dx, line ; print 'line' variable
  41. mov ah, 09h
  42. int 21h
  43.  
  44. lea dx, message3 ; print 'message3' variable
  45. mov ah, 09h
  46. int 21h
  47.  
  48. mov ah, 2
  49. mov dl, num1 ; move 'num1' to dl
  50. sub dl, num2 ; subtract 'num2' from dl
  51. add dl, 48 ; add 48 to dl to make it decimal
  52. int 21h
  53.  
  54. mov ah, 4ch ; end program
  55. int 21h
  56.  
  57.  
  58. endp
  59.  
  60. end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement