An assembly language program that multiplies two numbers (one byte) stored in the memory and Print output on the monitor – IGNOU MCA Assignment 2015 – 16

By | August 18, 2015

BACHELOR OF COMPUTER APPLICATIONS

 

Course Code : BCSL-022
Course Title : Assembly Language Programming Lab
Assignment Number : BCA(II)/L-022/Assignment/2015
Maximum Marks : 50
Weightage : 25%

 

Write and run an assembly language program that multiplies two numbers (of size one byte only) stored in the memory. The result should be output on the computer monitor. 

 

DATA SEGMENT
NUM1 DB ?
NUM2 DB ?
RESULT DB ?
DIGIT1 DB ?
DIGIT2 DB ?
MSG1 DB 10,13,”ENTER FIRST 2 DIGIT NUMBER TO MULTIPLY : $”
MSG2 DB 10,13,”ENTER SECOND 2 DIGIT NUMBER TO MULTIPLY : $”
MSG3 DB 10,13,”RESULT OF MULTIPLICATION IS : $”
RES DB 10 DUP (‘$’)
DATA ENDS

CODE SEGMENT
ASSUME DS:DATA,CS:CODE
START:
MOV AX,DATA
MOV DS,AX

LEA DX,MSG1
MOV AH,9
INT 21H

MOV AH,1
INT 21H
SUB AL,30H
MOV DIGIT1,AL

MOV AH,1
INT 21H
SUB AL,30H
MOV DIGIT2,AL

MOV AH,0

MOV AL,DIGIT1

MOV CL,10
MUL CL

MOV AH,DIGIT2

ADD AL,AH

MOV NUM1,AL

LEA DX,MSG2
MOV AH,9
INT 21H

MOV AH,1
INT 21H
SUB AL,30H
MOV DIGIT1,AL

MOV AH,1
INT 21H
SUB AL,30H
MOV DIGIT2,AL

MOV AH,0

MOV AL,DIGIT1

MOV CL,10
MUL CL

MOV AH,DIGIT2

ADD AL,AH

MOV NUM2,AL

MOV AH,0

MOV BL,NUM1
MUL BL

LEA SI,RES
CALL HEX2DEC

LEA DX,MSG3
MOV AH,9
INT 21H

LEA DX,RES
MOV AH,9
INT 21H

MOV AH,4CH
INT 21H
CODE ENDS

HEX2DEC PROC NEAR
MOV CX,0
MOV BX,10

LOOP1: MOV DX,0
DIV BX
ADD DL,30H
PUSH DX
INC CX
CMP AX,9
JG LOOP1

ADD AL,30H
MOV [SI],AL

LOOP2: POP AX
INC SI
MOV [SI],AL
LOOP LOOP2
RET
HEX2DEC ENDP

END START

Program Code :

  1. DATA SEGMENT
  2. NUM1 DB ?
  3. NUM2 DB ?
  4. RESULT DB ?
  5. DIGIT1 DB ?
  6. DIGIT2 DB ?
  7. MSG1 DB 10,13,"ENTER FIRST 2 DIGIT NUMBER TO MULTIPLY : $"
  8. MSG2 DB 10,13,"ENTER SECOND 2 DIGIT NUMBER TO MULTIPLY : $"
  9. MSG3 DB 10,13,"RESULT OF MULTIPLICATION IS : $"
  10. RES DB 10 DUP ('$')
  11. DATA ENDS
  12. CODE SEGMENT
  13. ASSUME DS:DATA,CS:CODE
  14. START:
  15. MOV AX,DATA
  16. MOV DS,AX
  17. LEA DX,MSG1
  18. MOV AH,9
  19. INT 21H
  20. MOV AH,1
  21. INT 21H
  22. SUB AL,30H
  23. MOV DIGIT1,AL
  24. MOV AH,1
  25. INT 21H
  26. SUB AL,30H
  27. MOV DIGIT2,AL
  28. MOV AH,0
  29. MOV AL,DIGIT1
  30. MOV CL,10
  31. MUL CL
  32. MOV AH,DIGIT2
  33. ADD AL,AH
  34. MOV NUM1,AL
  35. LEA DX,MSG2
  36. MOV AH,9
  37. INT 21H
  38. MOV AH,1
  39. INT 21H
  40. SUB AL,30H
  41. MOV DIGIT1,AL
  42. MOV AH,1
  43. INT 21H
  44. SUB AL,30H
  45. MOV DIGIT2,AL
  46. MOV AH,0
  47. MOV AL,DIGIT1
  48. MOV CL,10
  49. MUL CL
  50. MOV AH,DIGIT2
  51. ADD AL,AH
  52. MOV NUM2,AL
  53. MOV AH,0
  54. MOV BL,NUM1
  55. MUL BL
  56. LEA SI,RES
  57. CALL HEX2DEC
  58. LEA DX,MSG3
  59. MOV AH,9
  60. INT 21H
  61. LEA DX,RES
  62. MOV AH,9
  63. INT 21H
  64. MOV AH,4CH
  65. INT 21H
  66. CODE ENDS
  67. HEX2DEC PROC NEAR
  68. MOV CX,0
  69. MOV BX,10
  70. LOOP1: MOV DX,0
  71. DIV BX
  72. ADD DL,30H
  73. PUSH DX
  74. INC CX
  75. CMP AX,9
  76. JG LOOP1
  77. ADD AL,30H
  78. MOV [SI],AL
  79. LOOP2: POP AX
  80. INC SI
  81. MOV [SI],AL
  82. LOOP LOOP2
  83. RET
  84. HEX2DEC ENDP
  85. END START

Screen shots :-

 Asm_program_Mult_Two_Numbers(8_Bit)

After Execution :

Asm_program_Mult_Two_Numbers(8_Bit)_Out