Advertisement
tsnaik

MFP lab 3

Jul 19th, 2015
544
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.11 KB | None | 0 0
  1. /*DARSHIL KE NOTES*/
  2.  
  3. add
  4. sub
  5. adc
  6. div
  7. mul-only one arg with multiplication
  8. imul-signed multiplication()
  9. idiv-signed division(2's complement)
  10. inc
  11. stc-set carry flag explicitly
  12. clc-clear carry flag explicitly
  13. rcr-rotates specified bits right side with carry.(ex: RCR AL,1;RCR AL,4(i.e.4times);RCR AL,CL(CL has some value))
  14. rcl-rotates left with carry.
  15. ROR-rotate right without carry.
  16. ROL-rotate left without carry.
  17. INC-increment by 1.
  18. DEC-decrement by 1.
  19. CMP- cmp ax,bx (eventually does ax-bx)
  20. JZ-
  21. JA-jump above-if in cmp ax,bx ax is greater then true.
  22. JB-jump below.if in cmp ax,bx ax is smaller then true.
  23.  
  24. QUE:-Find whether no is odd or eve. (dont use div)
  25.  
  26. note:uppar na ma remainder jaay.(ex:dx...ah)
  27.  
  28. bx -can be used as pointer,not dx
  29.  
  30. pointers-SI,DI,BX
  31.  
  32. offset array1
  33. byte ptr [SI]
  34.  
  35. length of array:b db ($-array)
  36.  
  37.  
  38.  
  39. */END OF DARSHIL KE NOTES*/
  40.  
  41.  
  42. aim: odd even
  43.  
  44.  
  45. data segment
  46.  
  47. d1 db 31
  48. msg1 db "even$"
  49. msg2 db "odd number$"
  50.  
  51. data ends
  52.  
  53. code segment
  54.  
  55. assume cs:code, ds:data
  56. MOV AX,data
  57. MOV DS,AX
  58. XOR AX,AX
  59. MOV AL,d1
  60. RCR AL,1
  61. JC odd
  62. MOV DX,offset msg1
  63. mov ah,09
  64. int 21h
  65. jmp exit
  66.  
  67. odd:mov ah,09
  68. mov dx,offset msg2
  69. int 21h
  70.  
  71. exit:int 3
  72.  
  73. code ends
  74. end
  75.  
  76.  
  77.  
  78. aim:prime
  79.  
  80.  
  81.  
  82. data segment
  83.  
  84. d1 db 9
  85. msg1 db "prime$"
  86. msg2 db "not prime$"
  87.  
  88. data ends
  89.  
  90. code segment
  91.  
  92. assume cs:code, ds:data
  93. MOV AX,data
  94. MOV DS,AX
  95. XOR AX,AX
  96.  
  97. MOV AL,d1
  98. MOV BL,AL
  99. MOV CL,1
  100.  
  101. AGAIN:
  102. MOV AH,00
  103. DIV CL
  104. CMP AH,00
  105. JZ NOT_PRIME
  106. INC CL
  107. CMP CL,BL
  108. JZ PRIME
  109. JMP AGAIN
  110.  
  111. NOT_PRIME:
  112. MOV AH,09
  113. MOV DX,OFFSET MSG2
  114. INT 21H
  115. JMP EXIT
  116.  
  117. PRIME:
  118. MOV AH,09
  119. MOV DX,OFFSET MSG1
  120. INT 21H
  121.  
  122. EXIT:
  123. INT 3
  124. code ends
  125. end
  126.  
  127.  
  128.  
  129. aim: find an even number from array
  130.  
  131.  
  132. data segment
  133.  
  134. array1 db 1,3,5,7,8,9,11
  135. b db ($-array1)
  136. data ends
  137.  
  138. code segment
  139.  
  140. assume cs:code, ds:data
  141. MOV AX,data
  142. MOV DS,AX
  143. XOR AX,AX
  144.  
  145. MOV BL,b
  146. MOV SI,offset array1
  147.  
  148. again:
  149. mov al,byte ptr[SI]
  150. rcr al,1
  151. jnc print
  152. inc SI
  153. jz exit
  154. jmp again
  155.  
  156. print:
  157. mov dx,SI
  158. add dl,30h
  159. mov ah,02
  160. int 21h
  161.  
  162. exit:int 3
  163.  
  164. code ends
  165. end
  166.  
  167.  
  168.  
  169.  
  170. aim: find minimum and maximum from the given array
  171. aim: find out GCD of 2 numbers
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement