Contains the source code from the course work throughout my undergraduate Computer Engineering degree at Brigham Young University. There is a mixture of Go, Python, C, C++, Java, VHDL, Verilog, Matlab, Bash, Assembly, etc..
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

clib.s 19KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111
  1. CPU 8086
  2. ORG 0h
  3. InterruptVectorTable:
  4. ; Internal x86 Interrupts:
  5. dd 0 ; Reserved (Div err) ; Int 00h
  6. dd 0 ; Reserved (Step) ; Int 01h
  7. dd 0 ; Reserved (NMI) ; Int 02h
  8. dd 0 ; Reserved (Break) ; Int 03h
  9. dd 0 ; Reserved (Overflow) ; Int 04h
  10. dd 0 ; Int 05h
  11. dd 0 ; Int 06h
  12. dd 0 ; Int 07h
  13. ; Hardware Interrupts:
  14. dd RESET ; Reset ; Int 08h (IRQ 0)
  15. dd TICK ; Tick ; Int 09h (IRQ 1)
  16. dd KEYBOARD ; Keyboard ; Int 0Ah (IRQ 2)
  17. dd 0 ; Simptris Game Over ; Int 0Bh (IRQ 3)
  18. dd 0 ; Simptris New Piece ; Int 0Ch (IRQ 4)
  19. dd 0 ; Simptris Received ; Int 0Dh (IRQ 5)
  20. dd 0 ; Simptris Touchdown ; Int 0Eh (IRQ 6)
  21. dd 0 ; Simptris Clear ; Int 0Fh (IRQ 7)
  22. ; Software Interrupts:
  23. dd 0 ; Reserved (PC BIOS) ; Int 10h
  24. dd 0 ; Int 11h
  25. dd 0 ; Int 12h
  26. dd 0 ; Int 13h
  27. dd 0 ; Int 14h
  28. dd 0 ; Int 15h
  29. dd 0 ; Int 16h
  30. dd 0 ; Int 17h
  31. dd 0 ; Int 18h
  32. dd 0 ; Int 19h
  33. dd 0 ; Int 1Ah
  34. dd 0 ; Int 1Bh
  35. dd 0 ; Int 1Ch
  36. dd 0 ; Int 1Dh
  37. dd 0 ; Int 1Eh
  38. dd 0 ; Int 1Fh
  39. dd TRAP ; Int 20h
  40. dd 0 ; Reserved (DOS) ; Int 21h
  41. dd 0 ; Simptris Services ; Int 22h
  42. dd 0 ; Int 23h
  43. dd 0 ; Int 24h
  44. dd 0 ; Int 25h
  45. dd 0 ; Int 26h
  46. dd 0 ; Int 27h
  47. dd 0 ; Int 28h
  48. dd 0 ; Int 29h
  49. dd 0 ; Int 2Ah
  50. dd 0 ; Int 2Bh
  51. dd 0 ; Int 2Ch
  52. dd 0 ; Int 2Dh
  53. dd 0 ; Int 2Eh
  54. dd 0 ; Int 2Fh
  55. KeyBuffer: ; Address 0xC0
  56. dw 0
  57. NewPieceType: ; Address 0xC2
  58. dw 0
  59. NewPieceID: ; Address 0xC4
  60. dw 0
  61. NewPieceOrientation: ; Address 0xC6
  62. dw 0
  63. NewPieceColumn: ; Address 0xC8
  64. dw 0
  65. TouchdownID: ; Address 0xCA
  66. dw 0
  67. ScreenBitMap0: ; Address 0xCC
  68. dw 0
  69. ScreenBitMap1:
  70. dw 0
  71. ScreenBitMap2:
  72. dw 0
  73. ScreenBitMap3:
  74. dw 0
  75. ScreenBitMap4:
  76. dw 0
  77. ScreenBitMap5:
  78. dw 0
  79. TIMES 100h-($-$$) db 0 ; Fill up to (but not including) address 100h with 0
  80. jmp main
  81. ; This file contains support routines for 32-bit on the 8086.
  82. ; It is intended for use code generated by the C86 compiler.
  83. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
  84. SR_asldiv: ; l1 /= l2
  85. push bp
  86. mov bp,sp
  87. push bx
  88. mov bx,[bp+4] ; Get address of l1 (was push3)
  89. push word [bp+8] ; Push hi l2 (was push1)
  90. push word [bp+6] ; Push lo l2 (was push2)
  91. push word [bx+2] ; Push hi l1
  92. push word [bx] ; Push lo l1
  93. call SR_ldiv
  94. mov bx,[bp+4] ; Restore l1 address
  95. mov [bx+2],dx ; Store result
  96. mov [bx],ax
  97. pop bx
  98. pop bp
  99. ret
  100. SR_aslmod: ; l1 %= l2
  101. push bp
  102. mov bp,sp
  103. push bx
  104. mov bx,[bp+4] ; Get address of l1 (was push3)
  105. push word [bp+8] ; Push hi l2 (was push1)
  106. push word [bp+6] ; Push lo l2 (was push2)
  107. push word [bx+2] ; Push hi l1
  108. push word [bx] ; Push lo l1
  109. call SR_lmod
  110. mov bx,[bp+4] ; Restore l1 address
  111. mov [bx+2],dx ; Store result
  112. mov [bx],ax
  113. pop bx
  114. pop bp
  115. ret
  116. SR_aslmul: ; l1 *= l2
  117. push bp
  118. mov bp,sp
  119. push bx
  120. mov bx,[bp+4] ; Get address of l1 (was push3)
  121. push word [bp+8] ; Push hi l2 (was push1)
  122. push word [bp+6] ; Push lo l2 (was push2)
  123. push word [bx+2] ; Push hi l1
  124. push word [bx] ; Push lo l1
  125. call SR_lmul
  126. add sp,8
  127. mov bx,[bp+4] ; Restore l1 address
  128. mov [bx+2],dx ; Store result
  129. mov [bx],ax
  130. pop bx
  131. pop bp
  132. ret
  133. SR_aslshl: ; l1 <<= l2
  134. push bp
  135. mov bp,sp
  136. push bx
  137. mov bx,[bp+4] ; Get address of l1 (was push3)
  138. push word [bp+8] ; Push hi l2 (was push1)
  139. push word [bp+6] ; Push lo l2 (was push2)
  140. push word [bx+2] ; Push hi l1
  141. push word [bx] ; Push lo l1
  142. call SR_lshl
  143. add sp,8
  144. mov bx,[bp+4] ; Restore l1 address
  145. mov [bx+2],dx ; Store result
  146. mov [bx],ax
  147. pop bx
  148. pop bp
  149. ret
  150. SR_aslshr: ; l1 >>= l2
  151. push bp
  152. mov bp,sp
  153. push bx
  154. mov bx,[bp+4] ; Get address of l1 (was push3)
  155. push word [bp+8] ; Push hi l2 (was push1)
  156. push word [bp+6] ; Push lo l2 (was push2)
  157. push word [bx+2] ; Push hi l1
  158. push word [bx] ; Push lo l1
  159. call SR_lshr
  160. add sp,8
  161. mov bx,[bp+4] ; Restore l1 address
  162. mov [bx+2],dx ; Store result
  163. mov [bx],ax
  164. pop bx
  165. pop bp
  166. ret
  167. SR_asuldiv: ; u1 /= u2
  168. push bp
  169. mov bp,sp
  170. push bx
  171. mov bx,[bp+4] ; Get address of u1 (was push3)
  172. push word [bp+8] ; Push hi u2 (was push1)
  173. push word [bp+6] ; Push lo u2 (was push2)
  174. push word [bx+2] ; Push hi u1
  175. push word [bx] ; Push lo u1
  176. call SR_uldiv
  177. mov bx,[bp+4] ; Restore u1 address
  178. mov [bx+2],dx ; Store result
  179. mov [bx],ax
  180. pop bx
  181. pop bp
  182. ret
  183. SR_asilmod: ; u1 %= u2
  184. push bp
  185. mov bp,sp
  186. push bx
  187. mov bx,[bp+4] ; Get address of u1 (was push3)
  188. push word [bp+8] ; Push hi u2 (was push1)
  189. push word [bp+6] ; Push lo u2 (was push2)
  190. push word [bx+2] ; Push hi u1
  191. push word [bx] ; Push lo u1
  192. call SR_ilmod
  193. mov bx,[bp+4] ; Restore u1 address
  194. mov [bx+2],dx ; Store result
  195. mov [bx],ax
  196. pop bx
  197. pop bp
  198. ret
  199. SR_asulmul: ; u1 *= u2
  200. push bp
  201. mov bp,sp
  202. push bx
  203. mov bx,[bp+4] ; Get address of u1 (was push3)
  204. push word [bp+8] ; Push hi u2 (was push1)
  205. push word [bp+6] ; Push lo u2 (was push2)
  206. push word [bx+2] ; Push hi u1
  207. push word [bx] ; Push lo u1
  208. call SR_ulmul
  209. add sp,8
  210. mov bx,[bp+4] ; Restore u1 address
  211. mov [bx+2],dx ; Store result
  212. mov [bx],ax
  213. pop bx
  214. pop bp
  215. ret
  216. SR_asulshl: ; u1 << u2
  217. push bp
  218. mov bp,sp
  219. push bx
  220. mov bx,[bp+4] ; Get address of u1 (was push3)
  221. push word [bp+8] ; Push hi u2 (was push1)
  222. push word [bp+6] ; Push lo u2 (was push2)
  223. push word [bx+2] ; Push hi u1
  224. push word [bx] ; Push lo u1
  225. call SR_ulshl
  226. add sp,8
  227. mov bx,[bp+4] ; Restore u1 address
  228. mov [bx+2],dx ; Store result
  229. mov [bx],ax
  230. pop bx
  231. pop bp
  232. ret
  233. SR_asulshr: ; u1 >> u2
  234. push bp
  235. mov bp,sp
  236. push bx
  237. mov bx,[bp+4] ; Get address of u1 (was push3)
  238. push word [bp+8] ; Push hi u2 (was push1)
  239. push word [bp+6] ; Push lo u2 (was push2)
  240. push word [bx+2] ; Push hi u1
  241. push word [bx] ; Push lo u1
  242. call SR_ulshr
  243. add sp,8
  244. mov bx,[bp+4] ; Restore u1 address
  245. mov [bx+2],dx ; Store result
  246. mov [bx],ax
  247. pop bx
  248. pop bp
  249. ret
  250. ; Main 32-bit routines begin here:
  251. SR_ldiv: ; N_LDIV@
  252. pop cx
  253. push cs
  254. push cx
  255. ; LDIV@
  256. xor cx,cx
  257. jmp LSR_01
  258. SR_uldiv: ; N_LUDIV@
  259. pop cx
  260. push cs
  261. push cx
  262. ; F_LUDIV@
  263. mov cx,0001
  264. jmp LSR_01
  265. SR_lmod: ; N_LMOD@
  266. pop cx
  267. push cs
  268. push cx
  269. ; F_LMOD@
  270. mov cx,0002
  271. jmp LSR_01
  272. SR_ilmod: ; N_LUMOD@
  273. pop cx
  274. push cs
  275. push cx
  276. ; LUMOD@
  277. mov cx,0003
  278. LSR_01:
  279. push bp
  280. push si
  281. push di
  282. mov bp,sp
  283. mov di,cx
  284. mov ax,[bp+0Ah]
  285. mov dx,[bp+0Ch]
  286. mov bx,[bp+0Eh]
  287. mov cx,[bp+10h]
  288. or cx,cx
  289. jne LSR_02
  290. or dx,dx
  291. je LSR_10
  292. or bx,bx
  293. je LSR_10
  294. LSR_02:
  295. test di,0001
  296. jne LSR_04
  297. or dx,dx
  298. jns LSR_03
  299. neg dx
  300. neg ax
  301. sbb dx,0000
  302. or di,000Ch
  303. LSR_03:
  304. or cx,cx
  305. jns LSR_04
  306. neg cx
  307. neg bx
  308. sbb cx,0000
  309. xor di,0004
  310. LSR_04:
  311. mov bp,cx
  312. mov cx,0020h
  313. push di
  314. xor di,di
  315. xor si,si
  316. LSR_05:
  317. shl ax,1
  318. rcl dx,1
  319. rcl si,1
  320. rcl di,1
  321. cmp di,bp
  322. jb LSR_07
  323. ja LSR_06
  324. cmp si,bx
  325. jb LSR_07
  326. LSR_06:
  327. sub si,bx
  328. sbb di,bp
  329. inc ax
  330. LSR_07:
  331. loop LSR_05
  332. pop bx
  333. test bx,0002
  334. je LSR_08
  335. mov ax,si
  336. mov dx,di
  337. shr bx,1
  338. LSR_08:
  339. test bx,0004h
  340. je LSR_09
  341. neg dx
  342. neg ax
  343. sbb dx,0000
  344. LSR_09:
  345. pop di
  346. pop si
  347. pop bp
  348. retf 0008
  349. LSR_10:
  350. div bx
  351. test di,0002
  352. je LSR_11
  353. xchg dx,ax
  354. LSR_11:
  355. xor dx,dx
  356. jmp LSR_09
  357. SR_lshl: ; N_LXLSH@
  358. SR_ulshl:
  359. ; r = a << b
  360. pop bx
  361. push cs
  362. push bx
  363. push bp
  364. mov bp,sp
  365. push cx ; C86 doesn't expect use of cx or bx
  366. mov ax, [bp+6] ; pop loword(a)
  367. mov dx, [bp+8] ; pop hiword(a)
  368. mov cx, [bp+10] ; pop word(b)
  369. ; LXLSH@
  370. cmp cl,10h
  371. jnb LSR_12
  372. mov bx,ax
  373. shl ax,cl
  374. shl dx,cl
  375. neg cl
  376. add cl,10h
  377. shr bx,cl
  378. or dx,bx
  379. pop cx
  380. pop bp
  381. retf
  382. LSR_12:
  383. sub cl,10h
  384. xchg dx,ax
  385. xor ax,ax
  386. shl dx,cl
  387. pop cx
  388. pop bp
  389. retf
  390. SR_lshr: ; N_LXRSH@
  391. ; r = a >> b
  392. pop bx
  393. push cs
  394. push bx
  395. push bp
  396. mov bp,sp
  397. push cx ; C86 doesn't expect use of cx or bx
  398. mov ax, [bp+6] ; pop loword(a)
  399. mov dx, [bp+8] ; pop hiword(a)
  400. mov cx, [bp+10] ; pop word(b)
  401. ; LXRSH@
  402. cmp cl,10h
  403. jnb LSR_13
  404. mov bx,dx
  405. shr ax,cl
  406. sar dx,cl
  407. neg cl
  408. add cl,10h
  409. shl bx,cl
  410. or ax,bx
  411. pop cx
  412. pop bp
  413. retf
  414. LSR_13:
  415. sub cl,10h
  416. xchg dx,ax
  417. cwd
  418. sar ax,cl
  419. pop cx
  420. pop bp
  421. retf
  422. SR_ulshr: ; N_LXURSH@
  423. ; r = a >> b
  424. pop bx
  425. push cs
  426. push bx
  427. push bp
  428. mov bp,sp
  429. push cx ; C86 doesn't expect use of cx or bx
  430. mov ax, [bp+6] ; pop loword(a)
  431. mov dx, [bp+8] ; pop hiword(a)
  432. mov cx, [bp+10] ; pop word(b)
  433. ; LXURSH@
  434. cmp cl,10h
  435. jnb LSR_14
  436. mov bx,dx
  437. shr ax,cl
  438. shr dx,cl
  439. neg cl
  440. add cl,10h
  441. shl bx,cl
  442. or ax,bx
  443. pop cx
  444. pop bp
  445. retf
  446. LSR_14:
  447. sub cl,10h
  448. xchg dx,ax
  449. xor dx,dx
  450. shr ax,cl
  451. pop cx
  452. pop bp
  453. retf
  454. SR_lmul: ; N_LXMUL@
  455. SR_ulmul:
  456. ; r = a * b
  457. push bp
  458. push si
  459. mov bp,sp
  460. push cx ; C86 doesn't expect use of cx or bx
  461. push bx
  462. mov bx, [bp+6] ; pop loword(a)
  463. mov cx, [bp+8] ; pop hiword(a)
  464. mov ax, [bp+10] ; pop loword(b)
  465. mov dx, [bp+12] ; pop hiword(b)
  466. xchg si,ax
  467. xchg dx,ax
  468. test ax,ax
  469. je LSR_15
  470. mul bx
  471. LSR_15:
  472. jcxz LSR_16
  473. xchg cx,ax
  474. mul si
  475. add ax,cx
  476. LSR_16:
  477. xchg si,ax
  478. mul bx
  479. add dx,si
  480. pop bx
  481. pop cx
  482. pop si
  483. pop bp
  484. ret
  485. ; Generated by c86 (BYU-NASM) 5.1 (beta) from clib.c
  486. CPU 8086
  487. ALIGN 2
  488. jmp main ; Jump to program start
  489. new_line:
  490. db 13,10,36
  491. ALIGN 2
  492. signalEOI:
  493. jmp L_clib_1
  494. L_clib_2:
  495. mov al, 0x20
  496. out 0x20, al
  497. mov sp, bp
  498. pop bp
  499. ret
  500. L_clib_1:
  501. push bp
  502. mov bp, sp
  503. jmp L_clib_2
  504. ALIGN 2
  505. exit:
  506. jmp L_clib_4
  507. L_clib_5:
  508. mov ah, 4Ch
  509. mov al, [bp+4]
  510. int 21h
  511. mov sp, bp
  512. pop bp
  513. ret
  514. L_clib_4:
  515. push bp
  516. mov bp, sp
  517. jmp L_clib_5
  518. ALIGN 2
  519. print:
  520. jmp L_clib_7
  521. L_clib_8:
  522. mov ah, 40h
  523. mov bx, 1
  524. mov cx, [bp+6]
  525. mov dx, [bp+4]
  526. int 21h
  527. mov sp, bp
  528. pop bp
  529. ret
  530. L_clib_7:
  531. push bp
  532. mov bp, sp
  533. jmp L_clib_8
  534. ALIGN 2
  535. printChar:
  536. jmp L_clib_10
  537. L_clib_11:
  538. mov ah, 2
  539. mov dl, [bp+4]
  540. int 21h
  541. mov sp, bp
  542. pop bp
  543. ret
  544. L_clib_10:
  545. push bp
  546. mov bp, sp
  547. jmp L_clib_11
  548. ALIGN 2
  549. printNewLine:
  550. jmp L_clib_13
  551. L_clib_14:
  552. mov ah, 9
  553. mov dx, new_line
  554. int 21h
  555. mov sp, bp
  556. pop bp
  557. ret
  558. L_clib_13:
  559. push bp
  560. mov bp, sp
  561. jmp L_clib_14
  562. ALIGN 2
  563. printString:
  564. jmp L_clib_16
  565. L_clib_17:
  566. xor si,si
  567. mov bx, [bp+4]
  568. jmp printString2
  569. printString1:
  570. inc si
  571. printString2:
  572. cmp byte [bx+si],0
  573. jne printString1
  574. mov dx, bx
  575. mov cx, si
  576. mov ah, 40h
  577. mov bx, 1
  578. int 21h
  579. mov sp, bp
  580. pop bp
  581. ret
  582. L_clib_16:
  583. push bp
  584. mov bp, sp
  585. push cx
  586. jmp L_clib_17
  587. ALIGN 2
  588. printInt:
  589. jmp L_clib_19
  590. L_clib_20:
  591. mov word [bp-2], 0
  592. mov word [bp-4], 10000
  593. cmp word [bp+4], 0
  594. jge L_clib_21
  595. mov byte [bp-10], 45
  596. inc word [bp-2]
  597. mov ax, word [bp+4]
  598. neg ax
  599. mov word [bp+4], ax
  600. L_clib_21:
  601. mov ax, word [bp+4]
  602. test ax, ax
  603. jne L_clib_22
  604. mov word [bp-4], 1
  605. jmp L_clib_23
  606. L_clib_22:
  607. jmp L_clib_25
  608. L_clib_24:
  609. mov ax, word [bp-4]
  610. cwd
  611. mov cx, 10
  612. idiv cx
  613. mov word [bp-4], ax
  614. L_clib_25:
  615. mov ax, word [bp+4]
  616. cwd
  617. idiv word [bp-4]
  618. test ax, ax
  619. je L_clib_24
  620. L_clib_26:
  621. L_clib_23:
  622. jmp L_clib_28
  623. L_clib_27:
  624. mov ax, word [bp+4]
  625. xor dx, dx
  626. div word [bp-4]
  627. add al, 48
  628. mov si, word [bp-2]
  629. lea dx, [bp-10]
  630. add si, dx
  631. mov byte [si], al
  632. inc word [bp-2]
  633. mov ax, word [bp+4]
  634. xor dx, dx
  635. div word [bp-4]
  636. mov ax, dx
  637. mov word [bp+4], ax
  638. mov ax, word [bp-4]
  639. cwd
  640. mov cx, 10
  641. idiv cx
  642. mov word [bp-4], ax
  643. mov ax, word [bp-4]
  644. mov word [bp-4], ax
  645. L_clib_28:
  646. cmp word [bp-4], 0
  647. jg L_clib_27
  648. L_clib_29:
  649. push word [bp-2]
  650. lea ax, [bp-10]
  651. push ax
  652. call print
  653. add sp, 4
  654. mov sp, bp
  655. pop bp
  656. ret
  657. L_clib_19:
  658. push bp
  659. mov bp, sp
  660. sub sp, 10
  661. jmp L_clib_20
  662. ALIGN 2
  663. printLong:
  664. jmp L_clib_31
  665. L_clib_32:
  666. mov word [bp-2], 0
  667. mov word [bp-6], 51712
  668. mov word [bp-4], 15258
  669. cmp word [bp+6], 0
  670. jg L_clib_33
  671. jl L_clib_34
  672. cmp word [bp+4], 0
  673. jae L_clib_33
  674. L_clib_34:
  675. mov byte [bp-17], 45
  676. inc word [bp-2]
  677. mov ax, word [bp+4]
  678. mov dx, word [bp+6]
  679. neg ax
  680. adc dx, 0
  681. neg dx
  682. mov word [bp+4], ax
  683. mov word [bp+6], dx
  684. L_clib_33:
  685. mov ax, word [bp+4]
  686. mov dx, word [bp+6]
  687. or dx, ax
  688. jne L_clib_35
  689. mov word [bp-6], 1
  690. mov word [bp-4], 0
  691. jmp L_clib_36
  692. L_clib_35:
  693. jmp L_clib_38
  694. L_clib_37:
  695. mov ax, 10
  696. xor dx, dx
  697. push dx
  698. push ax
  699. lea ax, [bp-6]
  700. push ax
  701. call SR_asldiv
  702. L_clib_38:
  703. push word [bp-4]
  704. push word [bp-6]
  705. push word [bp+6]
  706. push word [bp+4]
  707. call SR_ldiv
  708. or dx, ax
  709. je L_clib_37
  710. L_clib_39:
  711. L_clib_36:
  712. jmp L_clib_41
  713. L_clib_40:
  714. push word [bp-4]
  715. push word [bp-6]
  716. push word [bp+6]
  717. push word [bp+4]
  718. call SR_uldiv
  719. add al, 48
  720. mov si, word [bp-2]
  721. lea dx, [bp-17]
  722. add si, dx
  723. mov byte [si], al
  724. inc word [bp-2]
  725. push word [bp-4]
  726. push word [bp-6]
  727. push word [bp+6]
  728. push word [bp+4]
  729. call SR_lmod
  730. mov word [bp+4], ax
  731. mov word [bp+6], dx
  732. mov ax, 10
  733. xor dx, dx
  734. push dx
  735. push ax
  736. lea ax, [bp-6]
  737. push ax
  738. call SR_asldiv
  739. L_clib_41:
  740. cmp word [bp-4], 0
  741. jg L_clib_40
  742. jne L_clib_43
  743. cmp word [bp-6], 0
  744. ja L_clib_40
  745. L_clib_43:
  746. L_clib_42:
  747. push word [bp-2]
  748. lea ax, [bp-17]
  749. push ax
  750. call print
  751. add sp, 4
  752. mov sp, bp
  753. pop bp
  754. ret
  755. L_clib_31:
  756. push bp
  757. mov bp, sp
  758. sub sp, 18
  759. jmp L_clib_32
  760. ALIGN 2
  761. printUInt:
  762. jmp L_clib_45
  763. L_clib_46:
  764. mov word [bp-2], 0
  765. mov word [bp-4], 10000
  766. mov ax, word [bp+4]
  767. test ax, ax
  768. jne L_clib_47
  769. mov word [bp-4], 1
  770. jmp L_clib_48
  771. L_clib_47:
  772. jmp L_clib_50
  773. L_clib_49:
  774. mov ax, word [bp-4]
  775. xor dx, dx
  776. mov cx, 10
  777. div cx
  778. mov word [bp-4], ax
  779. L_clib_50:
  780. mov ax, word [bp+4]
  781. xor dx, dx
  782. div word [bp-4]
  783. test ax, ax
  784. je L_clib_49
  785. L_clib_51:
  786. L_clib_48:
  787. jmp L_clib_53
  788. L_clib_52:
  789. mov ax, word [bp+4]
  790. xor dx, dx
  791. div word [bp-4]
  792. add al, 48
  793. mov si, word [bp-2]
  794. lea dx, [bp-10]
  795. add si, dx
  796. mov byte [si], al
  797. inc word [bp-2]
  798. mov ax, word [bp+4]
  799. xor dx, dx
  800. div word [bp-4]
  801. mov word [bp+4], dx
  802. mov ax, word [bp-4]
  803. xor dx, dx
  804. mov cx, 10
  805. div cx
  806. mov word [bp-4], ax
  807. L_clib_53:
  808. mov ax, word [bp-4]
  809. test ax, ax
  810. jne L_clib_52
  811. L_clib_54:
  812. push word [bp-2]
  813. lea ax, [bp-10]
  814. push ax
  815. call print
  816. add sp, 4
  817. mov sp, bp
  818. pop bp
  819. ret
  820. L_clib_45:
  821. push bp
  822. mov bp, sp
  823. sub sp, 10
  824. jmp L_clib_46
  825. ALIGN 2
  826. printULong:
  827. jmp L_clib_56
  828. L_clib_57:
  829. mov word [bp-2], 0
  830. mov word [bp-6], 51712
  831. mov word [bp-4], 15258
  832. mov ax, word [bp+4]
  833. mov dx, word [bp+6]
  834. or dx, ax
  835. jne L_clib_58
  836. mov word [bp-6], 1
  837. mov word [bp-4], 0
  838. jmp L_clib_59
  839. L_clib_58:
  840. jmp L_clib_61
  841. L_clib_60:
  842. mov ax, 10
  843. xor dx, dx
  844. push dx
  845. push ax
  846. lea ax, [bp-6]
  847. push ax
  848. call SR_asuldiv
  849. L_clib_61:
  850. push word [bp-4]
  851. push word [bp-6]
  852. push word [bp+6]
  853. push word [bp+4]
  854. call SR_uldiv
  855. or dx, ax
  856. je L_clib_60
  857. L_clib_62:
  858. L_clib_59:
  859. jmp L_clib_64
  860. L_clib_63:
  861. push word [bp-4]
  862. push word [bp-6]
  863. push word [bp+6]
  864. push word [bp+4]
  865. call SR_uldiv
  866. add al, 48
  867. mov si, word [bp-2]
  868. lea dx, [bp-17]
  869. add si, dx
  870. mov byte [si], al
  871. inc word [bp-2]
  872. push word [bp-4]
  873. push word [bp-6]
  874. lea ax, [bp+4]
  875. push ax
  876. call SR_asilmod
  877. mov ax, 10
  878. xor dx, dx
  879. push dx
  880. push ax
  881. lea ax, [bp-6]
  882. push ax
  883. call SR_asuldiv
  884. L_clib_64:
  885. mov ax, word [bp-6]
  886. mov dx, word [bp-4]
  887. or dx, ax
  888. jne L_clib_63
  889. L_clib_65:
  890. push word [bp-2]
  891. lea ax, [bp-17]
  892. push ax
  893. call print
  894. add sp, 4
  895. mov sp, bp
  896. pop bp
  897. ret
  898. L_clib_56:
  899. push bp
  900. mov bp, sp
  901. sub sp, 18
  902. jmp L_clib_57
  903. ALIGN 2
  904. printByte:
  905. jmp L_clib_67
  906. L_clib_68:
  907. mov al, byte [bp+4]
  908. cbw
  909. mov cx, 4
  910. sar ax, cl
  911. and ax, 15
  912. mov byte [bp-1], al
  913. cmp byte [bp-1], 9
  914. jle L_clib_69
  915. mov al, byte [bp-1]
  916. cbw
  917. sub ax, 10
  918. add ax, 65
  919. jmp L_clib_70
  920. L_clib_69:
  921. mov al, byte [bp-1]
  922. cbw
  923. add ax, 48
  924. L_clib_70:
  925. mov byte [bp-3], al
  926. mov al, byte [bp+4]
  927. and al, 15
  928. mov byte [bp-1], al
  929. cmp byte [bp-1], 9
  930. jle L_clib_71
  931. mov al, byte [bp-1]
  932. cbw
  933. sub ax, 10
  934. add ax, 65
  935. jmp L_clib_72
  936. L_clib_71:
  937. mov al, byte [bp-1]
  938. cbw
  939. add ax, 48
  940. L_clib_72:
  941. mov byte [bp-2], al
  942. mov ax, 2
  943. push ax
  944. lea ax, [bp-3]
  945. push ax
  946. call print
  947. add sp, 4
  948. mov sp, bp
  949. pop bp
  950. ret
  951. L_clib_67:
  952. push bp
  953. mov bp, sp
  954. sub sp, 4
  955. jmp L_clib_68
  956. ALIGN 2
  957. printWord:
  958. jmp L_clib_74
  959. L_clib_75:
  960. mov word [bp-2], 3
  961. jmp L_clib_77
  962. L_clib_76:
  963. mov ax, word [bp+4]
  964. and ax, 15
  965. mov byte [bp-3], al
  966. cmp byte [bp-3], 9
  967. jle L_clib_80
  968. mov al, byte [bp-3]
  969. cbw
  970. sub ax, 10
  971. add ax, 65
  972. jmp L_clib_81
  973. L_clib_80:
  974. mov al, byte [bp-3]
  975. cbw
  976. add ax, 48
  977. L_clib_81:
  978. mov si, word [bp-2]
  979. lea dx, [bp-7]
  980. add si, dx
  981. mov byte [si], al
  982. mov ax, word [bp+4]
  983. mov cx, 4
  984. sar ax, cl
  985. mov word [bp+4], ax
  986. L_clib_79:
  987. dec word [bp-2]
  988. L_clib_77:
  989. cmp word [bp-2], 0
  990. jge L_clib_76
  991. L_clib_78:
  992. mov ax, 4
  993. push ax
  994. lea ax, [bp-7]
  995. push ax
  996. call print
  997. add sp, 4
  998. mov sp, bp
  999. pop bp
  1000. ret
  1001. L_clib_74:
  1002. push bp
  1003. mov bp, sp
  1004. sub sp, 8
  1005. jmp L_clib_75
  1006. ALIGN 2
  1007. printDWord:
  1008. jmp L_clib_83
  1009. L_clib_84:
  1010. lea ax, [bp+4]
  1011. mov si, ax
  1012. mov ax, word [si]
  1013. mov word [bp-6], ax
  1014. lea ax, [bp+4]
  1015. mov si, ax
  1016. add si, 2
  1017. mov ax, word [si]
  1018. mov word [bp-8], ax
  1019. mov word [bp-2], 3
  1020. jmp L_clib_86
  1021. L_clib_85:
  1022. mov ax, word [bp-6]
  1023. and ax, 15
  1024. mov byte [bp-3], al
  1025. cmp byte [bp-3], 9
  1026. jle L_clib_89
  1027. mov al, byte [bp-3]
  1028. cbw
  1029. sub ax, 10
  1030. add ax, 65
  1031. jmp L_clib_90
  1032. L_clib_89:
  1033. mov al, byte [bp-3]
  1034. cbw
  1035. add ax, 48
  1036. L_clib_90:
  1037. mov dx, word [bp-2]
  1038. add dx, 4
  1039. mov si, dx
  1040. lea dx, [bp-16]
  1041. add si, dx
  1042. mov byte [si], al
  1043. mov ax, word [bp-6]
  1044. mov cx, 4
  1045. sar ax, cl
  1046. mov word [bp-6], ax
  1047. mov ax, word [bp-8]
  1048. and ax, 15
  1049. mov byte [bp-3], al
  1050. cmp byte [bp-3], 9
  1051. jle L_clib_91
  1052. mov al, byte [bp-3]
  1053. cbw
  1054. sub ax, 10
  1055. add ax, 65
  1056. jmp L_clib_92
  1057. L_clib_91:
  1058. mov al, byte [bp-3]
  1059. cbw
  1060. add ax, 48
  1061. L_clib_92:
  1062. mov si, word [bp-2]
  1063. lea dx, [bp-16]
  1064. add si, dx
  1065. mov byte [si], al
  1066. mov ax, word [bp-8]
  1067. mov cx, 4
  1068. sar ax, cl
  1069. mov word [bp-8], ax
  1070. L_clib_88:
  1071. dec word [bp-2]
  1072. L_clib_86:
  1073. cmp word [bp-2], 0
  1074. jge L_clib_85
  1075. L_clib_87:
  1076. mov ax, 8
  1077. push ax
  1078. lea ax, [bp-16]
  1079. push ax
  1080. call print
  1081. add sp, 4
  1082. mov sp, bp
  1083. pop bp
  1084. ret
  1085. L_clib_83:
  1086. push bp
  1087. mov bp, sp
  1088. sub sp, 16
  1089. jmp L_clib_84