Implementation of a program to make a calculator.

Experiment No.: – 13

Implementation of a program to make a calculator.

  1. Start.
  2. Initialize SI with 8500H.
  3. Initialize DI with 8600H.
  4. Copy the content of 6000H memory location to CX register. (Put the value 01H, 02H, 03H, 04H in 6000H memory location for addition, subtraction, multiplication and division respectively)
  5. Decrease CX.
  6. Jump if zero for addition.
  7. Decrease CX.
  8. Jump if zero for subtraction.
  9. Decrease CX.
  10. Jump if zero for multiplication.
  11. Decrease CX.
  12. Jump if zero for division.
  13. Addition: Copy the data of 6002H memory location to CX register.
  14. Decrease CX.
  15. Copy the content of SI memory location (i.e 1st data) to AX register.
  16. Increase two times the value of SI register.
  17. Start loop: Copy the content of SI memory location (i.e 2nd data) to BX register.
  18. Add with carry the content of AX and BX register.
  19. Copy the content of AX register to the value of DI register memory location (i.e 8600H).
  20. Increase two times the value of SI register.
  21. Decrease CX.
  22. Jump if not zero to loop (i.e step 17).
  23. End for addition program.
  24. Subtraction: Copy the data of 6002H memory location to CX register.
  25. Decrease CX.
  26. Copy the content of SI memory location (i.e 1st data) to AX register.
  27. Increase two times the value of SI register.
  28. Start loop: Copy the content of SI memory location (i.e 2nd data) to BX register.
  29. Subtract with borrow the content of AX and BX register.
  30. Copy the content of AX register to the value of DI register memory location (i.e 8600H).
  31. Increase two times the value of SI register.
  32. Decrease CX.
  33. Jump if not zero to loop (i.e step 28).
  34. End for subtraction program.
  35. Multiplication: Copy the data of 6002H memory location to CX register.
  36. Decrease CX.
  37. Copy the content of SI memory location (i.e 1st data) to AX register.
  38. Increase two times the value of SI register.
  39. Start loop: Copy the content of SI memory location (i.e 2nd data) to BX register.
  40. Multiply the content of AX with BX register.
  41. Copy the content of AX register to the value of DI register memory location (i.e 8600H).
  42. Increase two times the value of SI register.
  43. Decrease CX.
  44. Jump if not zero to loop (i.e step 39).
  45. Increase two times the value of DI register.(i. e 6004H location)
  46. Copy the content of DX register to the value of DI register memory location (i.e 8604H).
  47. End for multiplication program.
  48. Division: Copy the data of 6002H memory location to CX register.
  49. Decrease CX.
  50. Copy the content of SI memory location (i.e 1st data) to AX register.
  51. Increase two times the value of SI register.
  52. Start loop: Copy the content of SI memory location (i.e 2nd data) to BX register.
  53. Divide with carry the content of AX with BX register.
  54. Copy the content of AX register to the value of DI register memory location (i.e 8600H).
  55. Increase two times the value of SI register.
  56. Decrease CX.
  57. Jump if not zero to loop (i.e step 52).
  58. Increase two times the value of DI register.(i. e 6004H location)
  59. Copy the content of DX register to the 8604H memory location through DI register.
  60. End for division program.
\[\color\green{ Put\; 01H,\;02H,\;03H,\;04H\; into\;}\] \[\color\green{ 6000H\; memory\;location\;for}\] \[\color\red{Addition,\;Subtraction,\;Multiplication,\; and\;Division}\] \[\color\green{ Put\;number\; of\;data\; into\; 6002H\; memory\;location}\] \[\color\magenta{ Put\;input\;data\; into\; 8500H\; memory\;location\; onwards}\] \[\color\magenta{ Get\;output\; from\;8600H\; memory\;location\;onwards}\]

To be written by student.