Advertisement
tsnaik

MFP lab 2

Jul 12th, 2015
445
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;we cannot assign a direct memory value to the segment register.
  2.  
  3. ;file.asm is TASM directory
  4.  
  5.  
  6. Data segment
  7. a db 10
  8. b db 20     ;db stands for Define a Byte
  9.  
  10. Data ends
  11.  
  12. Code segment
  13.  
  14. assume CS:Code, DS:Data
  15. MOV AX,Data ;can't load directly. etle aavu karvanu
  16. MOV DS,AX
  17. XOR AX,AX   ;to make 0
  18. MOV AL,a
  19. MOV BL,b
  20. ADD BL,AL
  21. Int 3
  22. Code ends
  23. End
  24.  
  25.  
  26.  
  27.  
  28. ;*compile ASM file:
  29.  
  30. ;tasm file.asm
  31.  
  32.  
  33. ;*link:
  34.  
  35. ;tlink FILE.OBJ
  36.  
  37.  
  38. ;*know starting and ending address:
  39.  
  40. ;type FILE.MAP
  41.  
  42.  
  43. ;*to execute:
  44.  
  45. ;in DEBUG125 directory:
  46.  
  47. ;debug C:\TASM\file.exe
  48. ;-g=0010    //starting address retrieved from previous step
  49.  
  50.  
  51. ;*int21h
  52.  
  53. ;int21h is a function. with arguments (ah,(dl,dx,al))
  54. ;ah is like case switch. it can be 01,02,09
  55.  
  56. ;switch ah:
  57. ;case 01 to scan character
  58. ;like scanf(al)     //always al
  59.  
  60. ;case 02  to print character
  61. ;like print(dl)     //always dl
  62.  
  63. ;case 09 to print a string
  64. ;like print(dx)     //always dx
  65.  
  66.  
  67. ;*AIM: take capital A as an input and print small a.
  68.  
  69. data segment
  70. a db 20H
  71. data ends
  72.  
  73. code segment
  74. assume cs:code, ds:data
  75.  
  76. MOV AX,data
  77. MOV DS,AX
  78. XOR AX,AX
  79.  
  80. MOV AH,1
  81. Int 21H
  82. MOV DL,AL
  83. ADD DL,a
  84. MOV AH,2
  85. INT 21H
  86. INT 03H
  87. code ends
  88. end
  89.  
  90.  
  91. ;*printing new line. hex is 0A for new line
  92.  
  93. code segment
  94. assume cs:code
  95. mov dl,33H
  96. mov ah,02
  97. int 21h
  98. mov dl,0aH  //0 is important.
  99. int 21h
  100. mov dl,64H
  101. int 21h
  102. int 03h
  103. code ends
  104. end
  105.  
  106.  
  107. ;*print 2 strings in different lines.
  108.  
  109. data segment
  110. a db 'hey first$'
  111. b db 'hey second$'
  112. data ends
  113.  
  114.  
  115. code segment
  116. assume cs:code, ds:data
  117.  
  118. MOV AX,data
  119. MOV DS,AX
  120. XOR AX,AX
  121.  
  122.  
  123. mov dx,offset a
  124. mov ah,09h
  125. int 21h
  126.  
  127. mov dl,0aH
  128. mov ah,02h
  129. int 21h
  130.  
  131. mov dx,offset b
  132. mov ah,09h
  133. int 21h
  134.  
  135. int 03h
  136. code ends
  137. end
  138.  
  139.  
  140. ;*printing from halfway
  141.  
  142. data segment
  143. a db 'hey first$'
  144. b db 'hey second$'
  145. data ends
  146.  
  147.  
  148. code segment
  149. assume cs:code, ds:data
  150.  
  151. MOV AX,data
  152. MOV DS,AX
  153. XOR AX,AX
  154.  
  155.  
  156. mov dx,offset a
  157. add dx, 0004
  158. mov ah,09h
  159. int 21h
  160.  
  161. mov dl,0aH
  162. mov ah,02h
  163. int 21h
  164.  
  165. mov dx,offset b
  166. mov ah,09h
  167. int 21h
  168.  
  169. int 03h
  170. code ends
  171. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement