Advertisement
varun1729

Untitled

Dec 28th, 2022
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. 2's,1’s complement
  2. assume cs:code,ds:data
  3. data segment
  4. n1 dw 0005h
  5. data ends
  6. code segment
  7. start:mov ax,data
  8. mov ds,ax
  9. mov ax,n1
  10. not ax
  11. mov bx,ax
  12. inc ax
  13. int 03h
  14. code ends
  15. end start
  16.  
  17. factorial
  18. assume cs:code,ds:data
  19. data segment
  20. num dw 0003h
  21. data ends
  22. code segment
  23. start:mov ax,data
  24. mov ds,ax
  25. mov cx,num
  26. mov ax,cx
  27. dec cx
  28. fact:mul cx
  29. dec cx
  30. jnz fact
  31. int 03h
  32. code ends
  33. end start
  34. Multibyte addition
  35. Assume cs:code,ds:data
  36. Data segment
  37. Num1 db 01h,02h,03h,04h
  38. Num2 db 05h,06h,07h,08h
  39. Num3 db 04 dup(00)
  40. Data ends
  41. Code Segment
  42. Start:
  43. Mov ax,data
  44. Mov ds,ax
  45. Xor ax,ax
  46. Mov bx,ax
  47. Mov cl,al
  48. Mov dl,00h
  49. Mov cl,04h
  50. Lea si,num1
  51. Lea di,num2
  52. Lea bx,num3
  53. L1: mov al,[si]
  54. Adc al,[di]
  55. Mov cl,al
  56. Mov dl,00h
  57. Mov cl,04h
  58. Lea si,num1
  59. Lea di,num2
  60. L1: mov al,[si]
  61. Adc al,[di]
  62. Mov [bx],al
  63. Inc si
  64. Inc di
  65. Inc bx
  66. Loop l1
  67. Jnc l2
  68. Adc dl,00
  69. L2: mov [bx],dl
  70. Int 03h
  71. Code ends
  72. End start
  73.  
  74. Multibyte subtraction
  75. Assume ds:data,cs:code
  76. Data segment
  77. N1 db 55h,66h,77h,88h
  78. N2 db 11h,22h,33h,44h
  79. Result db 4h dup(00)
  80. Data ends
  81. Code segment
  82. Start:mov ax,data
  83. Mov ds,ax
  84. Mov si,offset N1
  85. Mov di,offset N2
  86. Mov bx,offset result
  87. Clc
  88. Mov cx,0004h
  89. Mov ax,0000h
  90. Back:mov al,[si]
  91. Mov dl,[di]
  92. Sbb al,dl
  93. Mov [bx],al
  94. Inc si
  95. Mov di
  96. Inc bx
  97. Loop back
  98. Mov ah,4Ch
  99. Int 21h
  100. Int 03h
  101. Code ends
  102. End start
  103.  
  104. Hardware add
  105. A1000
  106. Mov ax,0005h
  107. Mov bx,0005h
  108. Add ax,bx
  109. Int 03h
  110. G1000
  111. Hardware sub
  112. A1000
  113. Mov ax,0003h
  114. Mov bx,0003h
  115. Sub ax,bx
  116. Int 03h
  117. G1000
  118. Hardware mul
  119. A1000
  120. Mov ax,0002h
  121. Mov bx,0002h
  122. Mul bx
  123. Int 03h
  124. G1000
  125. Hardware div
  126. A1000
  127. Mov ax,0002h
  128. Mov bx,0002h
  129. Div bx
  130. Int 03h
  131. G1000
  132. Hardware fact
  133. A1000
  134. Mov ax,0001
  135. Mov cx,0003
  136. 1006:mul cx
  137. Dec cx
  138. Jnz 1006
  139. G1000
  140. Hardware sum
  141. M 1200 02
  142. M 1201 04
  143. A1000
  144. Mov ax,0000
  145. Mov cl,02
  146. Mov si,1200
  147. 1008:add al,[si]
  148. Inc si
  149. Dec cl
  150. Jnz 1008
  151. G1000
  152.  
  153.  
  154. smallest
  155. assume ds:data,cs:code
  156. data segment
  157. arr1 db 05h,04h,01h,02h,03h
  158. count db 05h
  159. data ends
  160. code segment
  161. start:mov ax,data
  162. mov ds,ax
  163. mov dl,count
  164. L2:mov cx,dx
  165. mov si,offset arr1
  166. L1:mov al,[si]
  167. cmp al,[si+1]
  168. jc continue
  169. xchg al,[si+1]
  170. mov [si],al
  171. continue:inc si
  172. loop L1
  173. dec dx
  174. jnz L2
  175. mov bx,offset arr1
  176. mov al,[bx]
  177. int 03h
  178. code ends
  179. end start
  180.  
  181. largest
  182. assume cs:code,ds:data
  183. data segment
  184. arr db 02h,09h,03h,06h,08h,07h
  185. count db 06h
  186. data ends
  187. code segment
  188. start:mov ax,data
  189. mov ds,ax
  190. mov si,offset arr
  191. mov cl,count
  192. mov al,[si]
  193. up:inc si
  194. cmp al,[si]
  195. jnb go
  196. mov al,[si]
  197. go:loop up
  198. int 03h
  199. code ends
  200. end start
  201.  
  202. search
  203. assume ds:data,cs:code
  204. data segment
  205. arr db 11h,21h,32h
  206. msg db 'FOUND','$'
  207. msg1 db 'NOT FOUND','$'
  208. count db 03h
  209. data ends
  210. code segment
  211. start:mov ax,data
  212. mov ds,ax
  213. mov es,ax
  214. mov cl,count
  215. mov si,offset arr
  216. cld
  217. mov al,32h
  218. repne scasb
  219. jz a2
  220. mov ah,09h
  221. lea dx,msg1
  222. int 21h
  223. jmp a3
  224. a2:mov ah,09h
  225. lea dx,msg
  226. int 21h
  227. a3:int 03h
  228. code ends
  229. end start
  230.  
  231. reverse
  232. assume ds:data,cs:code
  233. data segment
  234. stg db 'SVCET','$'
  235. stg1 db 05h dup(?),'$'
  236. count db 05h
  237. data ends
  238. code segment
  239. start:mov ax,data
  240. mov ds,ax
  241. mov es,ax
  242. mov cl,count
  243. mov si,offset stg
  244. mov di,offset stg1
  245. cld
  246. add si,04h
  247. a1:movsb
  248. dec si
  249. dec si
  250. dec cl
  251. jnz a1
  252. mov ah,09h
  253. lea dx,stg1
  254. int 21h
  255. int 03h
  256. code ends
  257. end start
  258.  
  259. ascending order
  260. assume ds:data,cs:code
  261. data segment
  262. arr db 05h,04h,01h,02h,03h
  263. count db 05h
  264. data ends
  265. code segment
  266. start:mov ax,data
  267. mov ds,ax
  268. mov dl,count
  269. L2:mov cx,dx
  270. mov si,offset arr
  271. L1:mov al,[si]
  272. cmp al,[si+1]
  273. jc continue
  274. xchg al,[si+1]
  275. mov [si],al
  276. continue:inc si
  277. loop L1
  278. dec dx
  279. jnz L2
  280. int 03h
  281. code ends
  282. end start
  283.  
  284. descending order
  285. assume data:ds,cs:code
  286. arr1 db 05h,04h,01h,02h,03h
  287. count db 05h
  288. data ends
  289. code segment
  290. start:mov ax,data
  291. mov ds,ax
  292. mov dl,count
  293. L2:mov cl,dl
  294. mov si,offset arr1
  295. L1:mov al,[si]
  296. cmp al,[si+1]
  297. jnc continue
  298. xchg al,[si+1]
  299. mov [si],al
  300. continue:inc si
  301. loop L1
  302. dec dl
  303. jnz L2
  304. int 03h
  305. code ends
  306. end start
  307.  
  308. search char
  309. assume cs:code,ds:data
  310. data segment
  311. str db 'VASAVI'
  312. size1 db 06h
  313. data ends
  314. code segment
  315. start:mov ax,data
  316. mov ds,ax
  317. mov es,ax
  318. CLD
  319. mov di,offset str
  320. mov cx,size1
  321. mov al,49
  322. REPNE SCASB str
  323. int 03h
  324. code ends
  325. end start
  326.  
  327. sum of array numbers
  328. assume ds:data,cs:code
  329. data segment
  330. arr db 02h,03h,04h,05h,01h
  331. count db 05h
  332. data ends
  333. code segment
  334. start:mov ax,data
  335. mov ds,ax
  336. mov al,0h
  337. mov cl,count
  338. mov si,offset arr
  339. again:mov bl,[si]
  340. add ax,bx
  341. inc si
  342. dec cl
  343. jnz again
  344. int 03h
  345. code ends
  346. end start
  347.  
  348.  
  349. signed multiplication
  350. assume ds:data,cs:code
  351. data segment
  352. n1 dw -0002h
  353. n2 dw 0004h
  354. data ends
  355. code segment
  356. start:mov ax,data
  357. mov ds,ax
  358. mov ax,n1
  359. mov bx,n2
  360. imul bx
  361. int 03h
  362. code ends
  363. end start
  364.  
  365. signed division
  366. assume ds:data,cs:code
  367. data segment
  368. n1 dw -0004h
  369. n2 dw 0002h
  370. data ends
  371. code segment
  372. start:mov ax,data
  373. mov ds,ax
  374. mov ax,n1
  375. mov bx,n2
  376. idiv bx
  377. int 03h
  378. code ends
  379. end start
  380.  
  381. multibyte addition
  382. assume cs:code,ds:data
  383. data segment
  384. arr1 dw 0005h,0001h,0004h,0001h
  385. arr2 dw 0004h,0002h,0003h,0002h
  386. arr3 dw 4 dup(0)
  387. data ends
  388. start:mov ax,data
  389. mov ds,ax
  390. lea si,arr1
  391. lea di,arr2
  392. lea bx,arr3
  393. mov cx,04h
  394. sum:mov ax,[si]
  395. adc ax,[di]
  396. mov [bx],ax
  397. inc si
  398. inc di
  399. inc dx
  400. jnz sum
  401. int 03h
  402. code ends
  403. end start
  404.  
  405. lcd
  406. A1000
  407. mov AL,90
  408. mov DX,FF36
  409. OUT DX,AL
  410. mov DX,FF30
  411. IN AL,DX
  412. MOV DX,FF32
  413. OUT DX,AL
  414. JMP 1106
  415.  
  416. seven segment
  417. A1110
  418. mov al,80h
  419. mov dx,ff36
  420. out dx,al
  421. mov al,01h
  422. mov dx,ff30
  423. out dx,al
  424. mov al,f8h
  425. mov dx,ff32
  426. out dx,al
  427. int 03h
  428.  
  429. Hello
  430. M1200 press enter
  431. 86
  432. 89
  433. C7
  434. C7
  435. C0
  436. Start:mov al,80h
  437. Mov dx,ff36h
  438. Out dx,al
  439. Lea si,1200
  440. Loop:mov cx,0005h
  441. Mov al,7F
  442. Mov dx,ff30
  443. Out dx,al
  444. Mov al,[si]
  445. Mov dx,ff32
  446. Out dx,al
  447. Inc si
  448. Call delay
  449. Dec cx
  450. Jnz loop
  451. Jmp start
  452. Delay:mov bx,ffff
  453. Loop1:dec bx
  454. Jnz loop1
  455. Ret
  456.  
  457. Factorial Procedure
  458. Data segment
  459. Num2 dw 0003h
  460. Data ends
  461. Code segment
  462. Start: mov ax,data
  463. Mov ds,ax
  464. Mov ax,0000h
  465. Call myproc
  466. Int 03h
  467. Myproc proc near
  468. Mov ax,00001h
  469. Mov cx,num2
  470. Fact: mul cx
  471. Loop fact
  472. Ret
  473. Myroc endp
  474. Code ends
  475. End start
  476.  
  477. Macro factorial
  478. Data segment
  479. Num1 dw 0004h
  480. Data ends
  481. Code Segment
  482. Start: mov ax,data
  483. Mov ds,ax
  484. Mov ax,0000h
  485. factMacro macro p1
  486. mov cx,p1
  487. mov ax,0001h
  488. fact: mul cx
  489. loop fact
  490. endm
  491. factMacro num1
  492. int 03h
  493. code ends
  494. End Start
  495.  
  496. 8051 addressing mode
  497. Register: mov a,b
  498. Direct: mov 30h,a
  499. Indirect: mov a,@r0
  500. Indexed: MOVC a,@a+pc
  501. 8086 addressing modes
  502. Assume cs:code
  503. Code segment
  504. Start:
  505. Mov ax,0005h ; immediate
  506. Mov bx,[2000] ; direct
  507. Mov dx,[bx] ; indirect
  508. Mov bx,ax ; register
  509. Code Ends
  510. End Start
  511.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement