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.

2469 lines
55 KiB

  1. ! 1
  2. ! 1 # 1 "implementation/lsfs.c"
  3. ! 1 # 1 "implementation/../std_singos/stdio.h"
  4. ! 1 void print(string);
  5. !BCC_EOS
  6. ! 2 void* dump_ax_return(input);
  7. !BCC_EOS
  8. ! 3
  9. ! 4 void print(string)
  10. ! 5 char* string;
  11. export _print
  12. _print:
  13. !BCC_EOS
  14. ! 6 {
  15. ! 7 #asm
  16. !BCC_ASM
  17. _print.string set 2
  18. push bp
  19. mov bp,sp
  20. mov si,4[bp]
  21. call 0x0000:0x7C47
  22. pop bp
  23. ! 13 endasm
  24. !BCC_ENDASM
  25. ! 14 }
  26. ret
  27. ! 15
  28. ! 16 void print_stack(argument)
  29. ! 17 {
  30. export _print_stack
  31. _print_stack:
  32. ! 18 #asm
  33. !BCC_ASM
  34. _print_stack.argument set 2
  35. push bp
  36. mov bp,sp
  37. push ds
  38. push ax
  39. mov ax, ss
  40. mov ds, ax
  41. mov si,4[bp]
  42. call 0x0000:0x7C47
  43. pop ax
  44. pop ds
  45. pop bp
  46. ! 32 endasm
  47. !BCC_ENDASM
  48. ! 33 }
  49. ret
  50. ! 34
  51. ! 35 void* dump_ax_return(input)
  52. ! 36 void* input;
  53. export _dump_ax_return
  54. _dump_ax_return:
  55. !BCC_EOS
  56. ! 37 {
  57. ! 38 return input;
  58. push bp
  59. mov bp,sp
  60. push di
  61. push si
  62. mov ax,4[bp]
  63. pop si
  64. pop di
  65. pop bp
  66. ret
  67. !BCC_EOS
  68. ! 39 }
  69. ! 40
  70. ! 41 void dump_ax(input)
  71. ! 42 void* input;
  72. export _dump_ax
  73. _dump_ax:
  74. !BCC_EOS
  75. ! 43 {
  76. ! 44 dump_ax_return(input)
  77. push bp
  78. mov bp,sp
  79. push di
  80. push si
  81. ! 45 #asm
  82. ! Debug: list * void input = [S+6+2] (used reg = )
  83. push 4[bp]
  84. ! Debug: func () * void = dump_ax_return+0 (used reg = )
  85. call _dump_ax_return
  86. inc sp
  87. inc sp
  88. !BCC_EOS
  89. !BCC_ASM
  90. _dump_ax.input set 8
  91. .dump_ax.input set 4
  92. push bp
  93. mov bp,sp
  94. call 0x000:0x7C2A
  95. pop bp
  96. ! 50 endasm
  97. !BCC_ENDASM
  98. !BCC_EOS
  99. ! 51 }
  100. pop si
  101. pop di
  102. pop bp
  103. ret
  104. ! 52
  105. ! 53 void print_newline()
  106. ! 54 {
  107. export _print_newline
  108. _print_newline:
  109. ! 55 #asm
  110. !BCC_ASM
  111. printCRLF:
  112. mov ah, #0xE
  113. mov al, #13
  114. int #0x10
  115. mov al, #10
  116. int #0x10
  117. ret
  118. ! 63 endasm
  119. !BCC_ENDASM
  120. ! 64 }
  121. ret
  122. ! 65 # 1 "implementation/../std_singos/stdlib.h"
  123. ! 1 unsigned int global_heap_start = 0;
  124. .data
  125. export _global_heap_start
  126. _global_heap_start:
  127. .word 0
  128. !BCC_EOS
  129. ! 2 unsigned int global_heap_end = 0;
  130. export _global_heap_end
  131. _global_heap_end:
  132. .word 0
  133. !BCC_EOS
  134. ! 3 unsigned int global_heap_next = 0;
  135. export _global_heap_next
  136. _global_heap_next:
  137. .word 0
  138. !BCC_EOS
  139. ! 4
  140. ! 5 void* malloc(num_bytes);
  141. !BCC_EOS
  142. ! 6 void* calloc(number_elements, size);
  143. !BCC_EOS
  144. ! 7 int set_heap_settings(param_start, param_end);
  145. !BCC_EOS
  146. ! 8 unsigned int get_heap_next();
  147. !BCC_EOS
  148. ! 9
  149. ! 10 void* malloc(num_bytes)
  150. ! 11 int num_bytes;
  151. .text
  152. export _malloc
  153. _malloc:
  154. !BCC_EOS
  155. ! 12 {
  156. ! 13 unsigned int allocated_pointer = global_heap_next;
  157. push bp
  158. mov bp,sp
  159. push di
  160. push si
  161. dec sp
  162. dec sp
  163. ! Debug: eq unsigned int = [global_heap_next+0] to unsigned int allocated_pointer = [S+8-8] (used reg = )
  164. mov ax,[_global_heap_next]
  165. mov -6[bp],ax
  166. !BCC_EOS
  167. ! 14 global_heap_next = global_heap_next + num_bytes;
  168. ! Debug: add int num_bytes = [S+8+2] to unsigned int = [global_heap_next+0] (used reg = )
  169. mov ax,[_global_heap_next]
  170. add ax,4[bp]
  171. ! Debug: eq unsigned int = ax+0 to unsigned int = [global_heap_next+0] (used reg = )
  172. mov [_global_heap_next],ax
  173. !BCC_EOS
  174. ! 15 if (global_heap_next > global_heap_end)
  175. ! Debug: gt unsigned int = [global_heap_end+0] to unsigned int = [global_heap_next+0] (used reg = )
  176. mov ax,[_global_heap_next]
  177. cmp ax,[_global_heap_end]
  178. jbe .1
  179. .2:
  180. ! 16 {
  181. ! 17 return 0;
  182. xor ax,ax
  183. inc sp
  184. inc sp
  185. pop si
  186. pop di
  187. pop bp
  188. ret
  189. !BCC_EOS
  190. ! 18 }
  191. ! 19
  192. ! 20 return allocated_pointer;
  193. .1:
  194. mov ax,-6[bp]
  195. inc sp
  196. inc sp
  197. pop si
  198. pop di
  199. pop bp
  200. ret
  201. !BCC_EOS
  202. ! 21 }
  203. ! 22
  204. ! 23 void* calloc(number_elements, size)
  205. ! 24 unsigned int number_elements;
  206. export _calloc
  207. _calloc:
  208. !BCC_EOS
  209. ! 25 unsigned int size;
  210. !BCC_EOS
  211. ! 26 {
  212. ! 27 int i;
  213. !BCC_EOS
  214. ! 28 char* temp_pointer;
  215. !BCC_EOS
  216. ! 29 unsigned int num_bytes = number_elements * size;
  217. push bp
  218. mov bp,sp
  219. push di
  220. push si
  221. add sp,*-6
  222. ! Debug: mul unsigned int size = [S+$C+4] to unsigned int number_elements = [S+$C+2] (used reg = )
  223. mov ax,4[bp]
  224. mov cx,6[bp]
  225. imul cx
  226. ! Debug: eq unsigned int = ax+0 to unsigned int num_bytes = [S+$C-$C] (used reg = )
  227. mov -$A[bp],ax
  228. !BCC_EOS
  229. ! 30 void* allocated_pointer = global_heap_next;
  230. dec sp
  231. dec sp
  232. ! Debug: eq unsigned int = [global_heap_next+0] to * void allocated_pointer = [S+$E-$E] (used reg = )
  233. mov bx,[_global_heap_next]
  234. mov -$C[bp],bx
  235. !BCC_EOS
  236. ! 31 global_heap_next = global_heap_next + num_bytes;
  237. ! Debug: add unsigned int num_bytes = [S+$E-$C] to unsigned int = [global_heap_next+0] (used reg = )
  238. mov ax,[_global_heap_next]
  239. add ax,-$A[bp]
  240. ! Debug: eq unsigned int = ax+0 to unsigned int = [global_heap_next+0] (used reg = )
  241. mov [_global_heap_next],ax
  242. !BCC_EOS
  243. ! 32 if (global_heap_next > global_heap_end)
  244. ! Debug: gt unsigned int = [global_heap_end+0] to unsigned int = [global_heap_next+0] (used reg = )
  245. mov ax,[_global_heap_next]
  246. cmp ax,[_global_heap_end]
  247. jbe .3
  248. .4:
  249. ! 33 {
  250. ! 34 return 0;
  251. xor ax,ax
  252. add sp,*8
  253. pop si
  254. pop di
  255. pop bp
  256. ret
  257. !BCC_EOS
  258. ! 35 }
  259. ! 36
  260. ! 37
  261. ! 38 temp_pointer = allocated_pointer;
  262. .3:
  263. ! Debug: eq * void allocated_pointer = [S+$E-$E] to * char temp_pointer = [S+$E-$A] (used reg = )
  264. mov bx,-$C[bp]
  265. mov -8[bp],bx
  266. !BCC_EOS
  267. ! 39 for (i = 0; i < num_bytes; ++i)
  268. ! Debug: eq int = const 0 to int i = [S+$E-8] (used reg = )
  269. xor ax,ax
  270. mov -6[bp],ax
  271. !BCC_EOS
  272. !BCC_EOS
  273. ! 40 {
  274. jmp .7
  275. .8:
  276. ! 41 *temp_pointer = 0;
  277. mov bx,-8[bp]
  278. ! Debug: eq int = const 0 to char = [bx+0] (used reg = )
  279. xor al,al
  280. mov [bx],al
  281. !BCC_EOS
  282. ! 42 temp_pointer++;
  283. ! Debug: postinc * char temp_pointer = [S+$E-$A] (used reg = )
  284. mov bx,-8[bp]
  285. inc bx
  286. mov -8[bp],bx
  287. !BCC_EOS
  288. ! 43 }
  289. ! 44
  290. ! 45 return allocated_pointer;
  291. .6:
  292. ! Debug: preinc int i = [S+$E-8] (used reg = )
  293. mov ax,-6[bp]
  294. inc ax
  295. mov -6[bp],ax
  296. .7:
  297. ! Debug: lt unsigned int num_bytes = [S+$E-$C] to int i = [S+$E-8] (used reg = )
  298. mov ax,-6[bp]
  299. cmp ax,-$A[bp]
  300. jb .8
  301. .9:
  302. .5:
  303. mov ax,-$C[bp]
  304. add sp,*8
  305. pop si
  306. pop di
  307. pop bp
  308. ret
  309. !BCC_EOS
  310. ! 46 }
  311. ! 47
  312. ! 48 int set_heap_settings(param_start, param_end)
  313. ! Register BX used in function calloc
  314. ! 49 unsigned int param_start;
  315. export _set_heap_settings
  316. _set_heap_settings:
  317. !BCC_EOS
  318. ! 50 unsigned int param_end;
  319. !BCC_EOS
  320. ! 51 {
  321. ! 52 global_heap_start = param_start;
  322. push bp
  323. mov bp,sp
  324. push di
  325. push si
  326. ! Debug: eq unsigned int param_start = [S+6+2] to unsigned int = [global_heap_start+0] (used reg = )
  327. mov ax,4[bp]
  328. mov [_global_heap_start],ax
  329. !BCC_EOS
  330. ! 53 global_heap_next = param_start;
  331. ! Debug: eq unsigned int param_start = [S+6+2] to unsigned int = [global_heap_next+0] (used reg = )
  332. mov ax,4[bp]
  333. mov [_global_heap_next],ax
  334. !BCC_EOS
  335. ! 54 global_heap_end = param_end;
  336. ! Debug: eq unsigned int param_end = [S+6+4] to unsigned int = [global_heap_end+0] (used reg = )
  337. mov ax,6[bp]
  338. mov [_global_heap_end],ax
  339. !BCC_EOS
  340. ! 55 return 0;
  341. xor ax,ax
  342. pop si
  343. pop di
  344. pop bp
  345. ret
  346. !BCC_EOS
  347. ! 56 }
  348. ! 57
  349. ! 58 unsigned int get_heap_next()
  350. ! 59 {
  351. export _get_heap_next
  352. _get_heap_next:
  353. ! 60 return global_heap_n
  354. push bp
  355. mov bp,sp
  356. push di
  357. push si
  358. ! 60 ext;
  359. mov ax,[_global_heap_next]
  360. pop si
  361. pop di
  362. pop bp
  363. ret
  364. !BCC_EOS
  365. ! 61 # 19 "implementation/../main.h"
  366. ! 19 }
  367. ! 20 # 2 "implementation/../std_singos/string.h"
  368. ! 2 typedef struct Length_String {
  369. ! 3 short dynamic;
  370. !BCC_EOS
  371. ! 4 unsigned int length;
  372. !BCC_EOS
  373. ! 5 char *chars;
  374. !BCC_EOS
  375. ! 6 } Length_String;
  376. !BCC_EOS
  377. ! 7
  378. ! 8 typedef struct String_Array {
  379. ! 9 unsigned int length;
  380. !BCC_EOS
  381. ! 10 Length_String **strings;
  382. !BCC_EOS
  383. ! 11 } String_Array;
  384. !BCC_EOS
  385. ! 12
  386. ! 13 void strcpy (destination, destination_segment, source, source_segment );
  387. !BCC_EOS
  388. ! 14 int strlen (source, source_segment);
  389. !BCC_EOS
  390. ! 15 void memcpy (destination, destination_segment, source, source_segment, num_bytes );
  391. !BCC_EOS
  392. ! 16
  393. ! 17
  394. ! 18 String_Array *string_split_c(string, delim, keep_delim);
  395. !BCC_EOS
  396. ! 19 Length_String *make_length_string(length, chars);
  397. !BCC_EOS
  398. ! 20 Length_String *make_length_string_c(cstring);
  399. !BCC_EOS
  400. ! 21 String_Array *length_string_split(string, delim, keep_delim);
  401. !BCC_EOS
  402. ! 22 String_Array *create_length_string_array(array_size);
  403. !BCC_EOS
  404. ! 23 Length_String *create_length_string(length, chars);
  405. !BCC_EOS
  406. ! 24
  407. ! 25
  408. ! 26
  409. ! 27 int strlen (source, source_segment)
  410. ! 28 {
  411. export _strlen
  412. _strlen:
  413. ! 29 #asm
  414. !BCC_ASM
  415. _strlen.source set 2
  416. _strlen.source_segment set 4
  417. push bp
  418. mov bp,sp
  419. push ds
  420. push bx
  421. mov ax, 6[bp];
  422. mov ds, ax
  423. mov bx, 4[bp];
  424. label_strlen:
  425. mov cx, #0x0 ; Set counte to zero
  426. .label_strlen_loop:
  427. mov BYTE al, [bx]
  428. cmp al, #0x0
  429. je .label_strlen_done
  430. inc cx ; Count 1
  431. inc bx ; Look at next char
  432. jmp .label_strlen_loop
  433. .label_strlen_done:
  434. mov ax, cx
  435. pop bx
  436. pop ds
  437. pop bp
  438. ! 57 endasm
  439. !BCC_ENDASM
  440. ! 58 }
  441. ret
  442. ! 59
  443. ! 60 void strcpy (destination, destination_segment, source, source_segment )
  444. ! 61 char *destination;
  445. export _strcpy
  446. _strcpy:
  447. !BCC_EOS
  448. ! 62 int destination_segment;
  449. !BCC_EOS
  450. ! 63 char *source;
  451. !BCC_EOS
  452. ! 64 int source_segment;
  453. !BCC_EOS
  454. ! 65 {
  455. ! 66 #asm
  456. !BCC_ASM
  457. _strcpy.source set 6
  458. _strcpy.destination set 2
  459. _strcpy.source_segment set 8
  460. _strcpy.destination_segment set 4
  461. ; copy two strings
  462. ; IN si: the first (zero terminated) string
  463. ; IN di: the second (zero terminated) string
  464. ; OUT SF and ZF (same semantics as cmp)
  465. ! 72 76
  466. push bp
  467. mov bp,sp
  468. label_strcpy:
  469. push ax
  470. push bx
  471. push di
  472. push es
  473. push si
  474. push ds
  475. mov ax, 4[bp]; ;
  476. mov di, ax
  477. mov ax, 6[bp]; ;
  478. mov es, ax
  479. mov ax, 8[bp]; ;
  480. mov si, ax
  481. mov ax, 10[bp]; ;
  482. mov ds, ax
  483. mov cx, 0x050 ;TODO(Jrn) Hardcded number of bytes to copy
  484. .label_strcpy_loop:
  485. movsb
  486. cmp cx, 0x0
  487. je .label_strcpy_end
  488. dec cx
  489. jmp .label_strcpy_loop
  490. .label_strcpy_end:
  491. pop ds
  492. pop si
  493. pop es
  494. pop di
  495. pop bx
  496. pop ax
  497. pop bp
  498. ! 110 endasm
  499. !BCC_ENDASM
  500. ! 111 }
  501. ret
  502. ! 112
  503. ! 113 void memcpy (destination, destination_segment, source, source_segment, num_bytes)
  504. ! 114 void *destination;
  505. export _memcpy
  506. _memcpy:
  507. !BCC_EOS
  508. ! 115 int destination_segment;
  509. !BCC_EOS
  510. ! 116 void *source;
  511. !BCC_EOS
  512. ! 117 int source_segment;
  513. !BCC_EOS
  514. ! 118 int num_bytes;
  515. !BCC_EOS
  516. ! 119 {
  517. ! 120 #asm
  518. !BCC_ASM
  519. _memcpy.source set 6
  520. _memcpy.destination set 2
  521. _memcpy.num_bytes set $A
  522. _memcpy.source_segment set 8
  523. _memcpy.destination_segment set 4
  524. ; copy two strings
  525. ; IN si: the first (zero terminated) string
  526. ; IN di: the second (zero terminated) string
  527. ; OUT SF and ZF (same semantics as cmp)
  528. ! 126 131
  529. push bp
  530. mov bp,sp
  531. label_memcpy:
  532. push ax
  533. push bx
  534. push di
  535. push es
  536. push si
  537. push ds
  538. mov ax, 4[bp]; ;
  539. mov di, ax
  540. mov ax, 6[bp]; ;
  541. mov es, ax
  542. mov ax, 8[bp]; ;
  543. mov si, ax
  544. mov ax, 10[bp]; ;
  545. mov ds, ax
  546. mov cx, 12[bp];
  547. .label_memcpy_loop:
  548. movsb
  549. cmp cx, 0x0
  550. je .label_memcpy_end
  551. dec cx
  552. jmp .label_memcpy_loop
  553. .label_memcpy_end:
  554. pop ds
  555. pop si
  556. pop es
  557. pop di
  558. pop bx
  559. pop ax
  560. pop bp
  561. ! 165 endasm
  562. !BCC_ENDASM
  563. ! 166 }
  564. ret
  565. ! 167
  566. ! 168 int strcmp(source_1, source_2)
  567. ! 169 char* source_1;
  568. export _strcmp
  569. _strcmp:
  570. !BCC_EOS
  571. ! 170 char* source_2;
  572. !BCC_EOS
  573. ! 171 {
  574. ! 172 int i;
  575. !BCC_EOS
  576. ! 173 int count;
  577. !BCC_EOS
  578. ! 174
  579. ! 175 count = strlen(source_1);
  580. push bp
  581. mov bp,sp
  582. push di
  583. push si
  584. add sp,*-4
  585. ! Debug: list * char source_1 = [S+$A+2] (used reg = )
  586. push 4[bp]
  587. ! Debug: func () int = strlen+0 (used reg = )
  588. call _strlen
  589. inc sp
  590. inc sp
  591. ! Debug: eq int = ax+0 to int count = [S+$A-$A] (used reg = )
  592. mov -8[bp],ax
  593. !BCC_EOS
  594. ! 176 if (count != strlen(source_2))
  595. ! Debug: list * char source_2 = [S+$A+4] (used reg = )
  596. push 6[bp]
  597. ! Debug: func () int = strlen+0 (used reg = )
  598. call _strlen
  599. inc sp
  600. inc sp
  601. ! Debug: ne int = ax+0 to int count = [S+$A-$A] (used reg = )
  602. ! Debug: expression subtree swapping
  603. cmp ax,-8[bp]
  604. je .A
  605. .B:
  606. ! 177 {
  607. ! 178
  608. ! 179 }
  609. ! 180
  610. ! 181
  611. ! 182 for (i = 0; i < count; ++i)
  612. .A:
  613. ! Debug: eq int = const 0 to int i = [S+$A-8] (used reg = )
  614. xor ax,ax
  615. mov -6[bp],ax
  616. !BCC_EOS
  617. !BCC_EOS
  618. ! 183 {
  619. jmp .E
  620. .F:
  621. ! 184 if(source_1[i] != source_2[i])
  622. ! Debug: ptradd int i = [S+$A-8] to * char source_2 = [S+$A+4] (used reg = )
  623. mov ax,-6[bp]
  624. add ax,6[bp]
  625. mov bx,ax
  626. ! Debug: ptradd int i = [S+$A-8] to * char source_1 = [S+$A+2] (used reg = bx)
  627. mov ax,-6[bp]
  628. add ax,4[bp]
  629. mov si,ax
  630. ! Debug: ne char = [bx+0] to char = [si+0] (used reg = )
  631. mov al,[si]
  632. cmp al,[bx]
  633. je .10
  634. .11:
  635. ! 185 {
  636. ! 186 return -1;
  637. mov ax,*-1
  638. add sp,*4
  639. pop si
  640. pop di
  641. pop bp
  642. ret
  643. !BCC_EOS
  644. ! 187 }
  645. ! 188 }
  646. .10:
  647. ! 189
  648. ! 190 return 0;
  649. .D:
  650. ! Debug: preinc int i = [S+$A-8] (used reg = )
  651. mov ax,-6[bp]
  652. inc ax
  653. mov -6[bp],ax
  654. .E:
  655. ! Debug: lt int count = [S+$A-$A] to int i = [S+$A-8] (used reg = )
  656. mov ax,-6[bp]
  657. cmp ax,-8[bp]
  658. jl .F
  659. .12:
  660. .C:
  661. xor ax,ax
  662. add sp,*4
  663. pop si
  664. pop di
  665. pop bp
  666. ret
  667. !BCC_EOS
  668. ! 191 # 223
  669. ! 223
  670. ! 224 }
  671. ! 225
  672. ! 226 String_Array *string_split_c(string, delim, keep_delim)
  673. ! Register BX SI used in function strcmp
  674. ! 227 char *string;
  675. export _string_split_c
  676. _string_split_c:
  677. !BCC_EOS
  678. ! 228 char delim;
  679. !BCC_EOS
  680. ! 229 short keep_delim;
  681. !BCC_EOS
  682. ! 230 {
  683. ! 231 return length_string_split(make_length_string_c(string), delim, keep_delim);
  684. push bp
  685. mov bp,sp
  686. push di
  687. push si
  688. ! Debug: list short keep_delim = [S+6+6] (used reg = )
  689. push 8[bp]
  690. ! Debug: list char delim = [S+8+4] (used reg = )
  691. mov al,6[bp]
  692. xor ah,ah
  693. push ax
  694. ! Debug: list * char string = [S+$A+2] (used reg = )
  695. push 4[bp]
  696. ! Debug: func () * struct Length_String = make_length_string_c+0 (used reg = )
  697. call _make_length_string_c
  698. inc sp
  699. inc sp
  700. ! Debug: list * struct Length_String = ax+0 (used reg = )
  701. push ax
  702. ! Debug: func () * struct String_Array = length_string_split+0 (used reg = )
  703. call _length_string_split
  704. add sp,*6
  705. ! Debug: cast * struct String_Array = const 0 to * struct String_Array = ax+0 (used reg = )
  706. pop si
  707. pop di
  708. pop bp
  709. ret
  710. !BCC_EOS
  711. ! 232 }
  712. ! 233
  713. ! 234 Length_String *make_length_string_c(cstring)
  714. ! 235 char *cstring;
  715. export _make_length_string_c
  716. _make_length_string_c:
  717. !BCC_EOS
  718. ! 236 {
  719. ! 237 return make_length_string(strlen(cstring, 0x7e0), cstring);
  720. push bp
  721. mov bp,sp
  722. push di
  723. push si
  724. ! Debug: list * char cstring = [S+6+2] (used reg = )
  725. push 4[bp]
  726. ! Debug: list int = const $7E0 (used reg = )
  727. mov ax,#$7E0
  728. push ax
  729. ! Debug: list * char cstring = [S+$A+2] (used reg = )
  730. push 4[bp]
  731. ! Debug: func () int = strlen+0 (used reg = )
  732. call _strlen
  733. add sp,*4
  734. ! Debug: list int = ax+0 (used reg = )
  735. push ax
  736. ! Debug: func () * struct Length_String = make_length_string+0 (used reg = )
  737. call _make_length_string
  738. add sp,*4
  739. ! Debug: cast * struct Length_String = const 0 to * struct Length_String = ax+0 (used reg = )
  740. pop si
  741. pop di
  742. pop bp
  743. ret
  744. !BCC_EOS
  745. ! 238 }
  746. ! 239
  747. ! 240 Length_String *make_length_string(length, chars)
  748. ! 241 unsigned int length;
  749. export _make_length_string
  750. _make_length_string:
  751. !BCC_EOS
  752. ! 242 char *chars;
  753. !BCC_EOS
  754. ! 243 {
  755. ! 244
  756. ! 245 Length_String *legth_string = malloc
  757. ! 245 (sizeof(Length_String));
  758. push bp
  759. mov bp,sp
  760. push di
  761. push si
  762. dec sp
  763. dec sp
  764. ! Debug: list int = const 6 (used reg = )
  765. mov ax,*6
  766. push ax
  767. ! Debug: func () * void = malloc+0 (used reg = )
  768. call _malloc
  769. inc sp
  770. inc sp
  771. ! Debug: eq * void = ax+0 to * struct Length_String legth_string = [S+8-8] (used reg = )
  772. mov -6[bp],ax
  773. !BCC_EOS
  774. ! 246 char *copy = malloc(length + 1);
  775. dec sp
  776. dec sp
  777. ! Debug: add int = const 1 to unsigned int length = [S+$A+2] (used reg = )
  778. mov ax,4[bp]
  779. ! Debug: list unsigned int = ax+1 (used reg = )
  780. inc ax
  781. push ax
  782. ! Debug: func () * void = malloc+0 (used reg = )
  783. call _malloc
  784. inc sp
  785. inc sp
  786. ! Debug: eq * void = ax+0 to * char copy = [S+$A-$A] (used reg = )
  787. mov -8[bp],ax
  788. !BCC_EOS
  789. ! 247 memcpy(copy, 0x7e0, chars, 0x7e0, length);
  790. ! Debug: list unsigned int length = [S+$A+2] (used reg = )
  791. push 4[bp]
  792. ! Debug: list int = const $7E0 (used reg = )
  793. mov ax,#$7E0
  794. push ax
  795. ! Debug: list * char chars = [S+$E+4] (used reg = )
  796. push 6[bp]
  797. ! Debug: list int = const $7E0 (used reg = )
  798. mov ax,#$7E0
  799. push ax
  800. ! Debug: list * char copy = [S+$12-$A] (used reg = )
  801. push -8[bp]
  802. ! Debug: func () void = memcpy+0 (used reg = )
  803. call _memcpy
  804. add sp,*$A
  805. !BCC_EOS
  806. ! 248 copy[length] = '\0';
  807. ! Debug: ptradd unsigned int length = [S+$A+2] to * char copy = [S+$A-$A] (used reg = )
  808. mov ax,4[bp]
  809. add ax,-8[bp]
  810. mov bx,ax
  811. ! Debug: eq int = const 0 to char = [bx+0] (used reg = )
  812. xor al,al
  813. mov [bx],al
  814. !BCC_EOS
  815. ! 249
  816. ! 250 legth_string->dynamic = 0;
  817. mov bx,-6[bp]
  818. ! Debug: eq int = const 0 to short = [bx+0] (used reg = )
  819. xor ax,ax
  820. mov [bx],ax
  821. !BCC_EOS
  822. ! 251 legth_string->length = length;
  823. mov bx,-6[bp]
  824. ! Debug: eq unsigned int length = [S+$A+2] to unsigned int = [bx+2] (used reg = )
  825. mov ax,4[bp]
  826. mov 2[bx],ax
  827. !BCC_EOS
  828. ! 252 legth_string->chars = (char *)chars;
  829. mov bx,-6[bp]
  830. ! Debug: eq * char chars = [S+$A+4] to * char = [bx+4] (used reg = )
  831. mov si,6[bp]
  832. mov 4[bx],si
  833. !BCC_EOS
  834. ! 253
  835. ! 254 return legth_string;
  836. mov ax,-6[bp]
  837. add sp,*4
  838. pop si
  839. pop di
  840. pop bp
  841. ret
  842. !BCC_EOS
  843. ! 255 }
  844. ! 256
  845. ! 257 String_Array *length_string_split(string, delim, keep_delim)
  846. ! Register BX SI used in function make_length_string
  847. ! 258 Length_String *string;
  848. export _length_string_split
  849. _length_string_split:
  850. !BCC_EOS
  851. ! 259 char delim;
  852. !BCC_EOS
  853. ! 260 short keep_delim;
  854. !BCC_EOS
  855. ! 261 {
  856. ! 262 unsigned int i;
  857. !BCC_EOS
  858. ! 263 unsigned int last;
  859. !BCC_EOS
  860. ! 264
  861. ! 265 unsigned int count = 0;
  862. push bp
  863. mov bp,sp
  864. push di
  865. push si
  866. add sp,*-6
  867. ! Debug: eq int = const 0 to unsigned int count = [S+$C-$C] (used reg = )
  868. xor ax,ax
  869. mov -$A[bp],ax
  870. !BCC_EOS
  871. ! 266 unsigned int insert_index = 0;
  872. dec sp
  873. dec sp
  874. ! Debug: eq int = const 0 to unsigned int insert_index = [S+$E-$E] (used reg = )
  875. xor ax,ax
  876. mov -$C[bp],ax
  877. !BCC_EOS
  878. ! 267 String_Array *result;
  879. !BCC_EOS
  880. ! 268 int k;
  881. !BCC_EOS
  882. ! 269
  883. ! 270 i = 0;
  884. add sp,*-4
  885. ! Debug: eq int = const 0 to unsigned int i = [S+$12-8] (used reg = )
  886. xor ax,ax
  887. mov -6[bp],ax
  888. !BCC_EOS
  889. ! 271 last = 0;
  890. ! Debug: eq int = const 0 to unsigned int last = [S+$12-$A] (used reg = )
  891. xor ax,ax
  892. mov -8[bp],ax
  893. !BCC_EOS
  894. ! 272 while(i < string->length) {
  895. jmp .14
  896. .15:
  897. ! 273 if (string->chars[i] == delim) {
  898. mov bx,4[bp]
  899. ! Debug: ptradd unsigned int i = [S+$12-8] to * char = [bx+4] (used reg = )
  900. mov ax,-6[bp]
  901. add ax,4[bx]
  902. mov bx,ax
  903. ! Debug: logeq char delim = [S+$12+4] to char = [bx+0] (used reg = )
  904. mov al,[bx]
  905. cmp al,6[bp]
  906. jne .16
  907. .17:
  908. ! 274 if (i > last+1) {
  909. ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = )
  910. mov ax,-8[bp]
  911. ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = )
  912. inc ax
  913. cmp ax,-6[bp]
  914. jae .18
  915. .19:
  916. ! 275 ++count;
  917. ! Debug: preinc unsigned int count = [S+$12-$C] (used reg = )
  918. mov ax,-$A[bp]
  919. inc ax
  920. mov -$A[bp],ax
  921. !BCC_EOS
  922. ! 276 }
  923. ! 277 last = i;
  924. .18:
  925. ! Debug: eq unsigned int i = [S+$12-8] to unsigned int last = [S+$12-$A] (used reg = )
  926. mov ax,-6[bp]
  927. mov -8[bp],ax
  928. !BCC_EOS
  929. ! 278 }
  930. ! 279 ++i;
  931. .16:
  932. ! Debug: preinc unsigned int i = [S+$12-8] (used reg = )
  933. mov ax,-6[bp]
  934. inc ax
  935. mov -6[bp],ax
  936. !BCC_EOS
  937. ! 280 }
  938. ! 281 if (i > last+1) {
  939. .14:
  940. mov bx,4[bp]
  941. ! Debug: lt unsigned int = [bx+2] to unsigned int i = [S+$12-8] (used reg = )
  942. mov ax,-6[bp]
  943. cmp ax,2[bx]
  944. jb .15
  945. .1A:
  946. .13:
  947. ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = )
  948. mov ax,-8[bp]
  949. ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = )
  950. inc ax
  951. cmp ax,-6[bp]
  952. jae .1B
  953. .1C:
  954. ! 282 ++count;
  955. ! Debug: preinc unsigned int count = [S+$12-$C] (used reg = )
  956. mov ax,-$A[bp]
  957. inc ax
  958. mov -$A[bp],ax
  959. !BCC_EOS
  960. ! 283 }
  961. ! 284
  962. ! 285 result = create_length_string_array(count);
  963. .1B:
  964. ! Debug: list unsigned int count = [S+$12-$C] (used reg = )
  965. push -$A[bp]
  966. ! Debug: func () * struct String_Array = create_length_string_array+0 (used reg = )
  967. call _create_length_string_array
  968. inc sp
  969. inc sp
  970. ! Debug: eq * struct String_Array = ax+0 to * struct String_Array result = [S+$12-$10] (used reg = )
  971. mov -$E[bp],ax
  972. !BCC_EOS
  973. ! 286
  974. ! 287 if (keep_delim)
  975. mov ax,8[bp]
  976. test ax,ax
  977. je .1D
  978. .1E:
  979. ! 288 {
  980. ! 289 k = 0;
  981. ! Debug: eq int = const 0 to int k = [S+$12-$12] (used reg = )
  982. xor ax,ax
  983. mov -$10[bp],ax
  984. !BCC_EOS
  985. ! 290 }
  986. ! 291 else
  987. ! 292 {
  988. jmp .1F
  989. .1D:
  990. ! 293 k = 1;
  991. ! Debug: eq int = const 1 to int k = [S+$12-$12] (used reg = )
  992. mov ax,*1
  993. mov -$10[bp],ax
  994. !BCC_EOS
  995. ! 294 }
  996. ! 295
  997. ! 296 i = 0;
  998. .1F:
  999. ! Debug: eq int = const 0 to unsigned int i = [S+$12-8] (used reg = )
  1000. xor ax,ax
  1001. mov -6[bp],ax
  1002. !BCC_EOS
  1003. ! 297 last = 0;
  1004. ! Debug: eq int = const 0 to unsigned int last = [S+$12-$A] (used reg = )
  1005. xor ax,ax
  1006. mov -8[bp],ax
  1007. !BCC_EOS
  1008. ! 298 while(i < string->length) {
  1009. jmp .21
  1010. .22:
  1011. ! 299 if (string->chars[i] == delim) {
  1012. mov bx,4[bp]
  1013. ! Debug: ptradd unsigned int i = [S+$12-8] to * char = [bx+4] (used reg = )
  1014. mov ax,-6[bp]
  1015. add ax,4[bx]
  1016. mov bx,ax
  1017. ! Debug: logeq char delim = [S+$12+4] to char = [bx+0] (used reg = )
  1018. mov al,[bx]
  1019. cmp al,6[bp]
  1020. jne .23
  1021. .24:
  1022. ! 300 if (i > last+1) {
  1023. ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = )
  1024. mov ax,-8[bp]
  1025. ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = )
  1026. inc ax
  1027. cmp ax,-6[bp]
  1028. jae .25
  1029. .26:
  1030. ! 301 result->strings[insert_index++] = create_length_string(i-(last+k), string->chars+(last+k));
  1031. ! Debug: add int k = [S+$12-$12] to unsigned int last = [S+$12-$A] (used reg = )
  1032. mov ax,-8[bp]
  1033. add ax,-$10[bp]
  1034. mov bx,4[bp]
  1035. ! Debug: ptradd unsigned int = ax+0 to * char = [bx+4] (used reg = )
  1036. add ax,4[bx]
  1037. ! Debug: list * char = ax+0 (used reg = )
  1038. push ax
  1039. ! Debug: add int k = [S+$14-$12] to unsigned int last = [S+$14-$A] (used reg = )
  1040. mov ax,-8[bp]
  1041. add ax,-$10[bp]
  1042. ! Debug: sub unsigned int = ax+0 to unsigned int i = [S+$14-8] (used reg = )
  1043. push ax
  1044. mov ax,-6[bp]
  1045. sub ax,-$14[bp]
  1046. inc sp
  1047. inc sp
  1048. ! Debug: list unsigned int = ax+0 (used reg = )
  1049. push ax
  1050. ! Debug: func () * struct Length_String = create_length_string+0 (used reg = )
  1051. call _create_length_string
  1052. add sp,*4
  1053. push ax
  1054. ! Debug: postinc unsigned int insert_index = [S+$14-$E] (used reg = )
  1055. mov ax,-$C[bp]
  1056. inc ax
  1057. mov -$C[bp],ax
  1058. mov bx,-$E[bp]
  1059. ! Debug: ptradd unsigned int = ax-1 to * * struct Length_String = [bx+2] (used reg = )
  1060. dec ax
  1061. shl ax,*1
  1062. add ax,2[bx]
  1063. mov bx,ax
  1064. ! Debug: eq * struct Length_String (temp) = [S+$14-$14] to * struct Length_String = [bx+0] (used reg = )
  1065. mov si,-$12[bp]
  1066. mov [bx],si
  1067. inc sp
  1068. inc sp
  1069. !BCC_EOS
  1070. ! 302 }
  1071. ! 303 last = i;
  1072. .25:
  1073. ! Debug: eq unsigned int i = [S+$12-8] to unsigned int last = [S+$12-$A] (used reg = )
  1074. mov ax,-6[bp]
  1075. mov -8[bp],ax
  1076. !BCC_EOS
  1077. ! 304 }
  1078. ! 305 ++i;
  1079. .23:
  1080. ! Debug: preinc unsigned int i = [S+$12-8] (used reg = )
  1081. mov ax,-6[bp]
  1082. inc ax
  1083. mov -6[bp],ax
  1084. !BCC_EOS
  1085. ! 306 }
  1086. ! 307 if (i > last+1) {
  1087. .21:
  1088. mov bx,4[bp]
  1089. ! Debug: lt unsigned int = [bx+2] to unsigned int i = [S+$12-8] (used reg = )
  1090. mov ax,-6[bp]
  1091. cmp ax,2[bx]
  1092. jb .22
  1093. .27:
  1094. .20:
  1095. ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = )
  1096. mov ax,-8[bp]
  1097. ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = )
  1098. inc ax
  1099. cmp ax,-6[bp]
  1100. jae .28
  1101. .29:
  1102. ! 308 result->strings[insert_index++] = create_length_string(i-(last+k), ((string->chars)+(last+k)));
  1103. ! Debug: add int k = [S+$12-$12] to unsigned int last = [S+$12-$A] (used reg = )
  1104. mov ax,-8[bp]
  1105. add ax,-$10[bp]
  1106. mov bx,4[bp]
  1107. ! Debug: ptradd unsigned int = ax+0 to * char = [bx+4] (used reg = )
  1108. add ax,4[bx]
  1109. ! Debug: list * char = ax+0 (used reg = )
  1110. push ax
  1111. ! Debug: add int k = [S+$14-$12] to unsigned int last = [S+$14-$A] (used reg = )
  1112. mov ax,-8[bp]
  1113. add ax,-$10[bp]
  1114. ! Debug: sub unsigned int = ax+0 to unsigned int i = [S+$14-8] (used reg = )
  1115. push ax
  1116. mov ax,-6[bp]
  1117. sub ax,-$14[bp]
  1118. inc sp
  1119. inc sp
  1120. ! Debug: list unsigned int = ax+0 (used reg = )
  1121. push ax
  1122. ! Debug: func () * struct Length_String = create_length_string+0 (used reg = )
  1123. call _create_length_string
  1124. add sp,*4
  1125. push ax
  1126. ! Debug: postinc unsigned int insert_index = [S+$14-$E] (used reg = )
  1127. mov ax,-$C[bp]
  1128. inc ax
  1129. mov -$C[bp],ax
  1130. mov bx,-$E[bp]
  1131. ! Debug: ptradd unsigned int = ax-1 to * * struct Length_String = [bx+2] (used reg = )
  1132. dec ax
  1133. shl ax,*1
  1134. add ax,2[bx]
  1135. mov bx,ax
  1136. ! Debug: eq * struct Length_String (temp) = [S+$14-$14] to * struct Length_String = [bx+0] (used reg = )
  1137. mov si,-$12[bp]
  1138. mov [bx],si
  1139. inc sp
  1140. inc sp
  1141. !BCC_EOS
  1142. ! 309 }
  1143. ! 310
  1144. ! 311 return result;
  1145. .28:
  1146. mov ax,-$E[bp]
  1147. add sp,*$C
  1148. pop si
  1149. pop di
  1150. pop bp
  1151. ret
  1152. !BCC_EOS
  1153. ! 312
  1154. ! 313 }
  1155. ! 314
  1156. ! 315 String_Array *create_length_string_array(array_size)
  1157. ! Register BX SI used in function length_string_split
  1158. ! 316 int array_size;
  1159. export _create_length_string_array
  1160. _create_length_string_array:
  1161. !BCC_EOS
  1162. ! 317 {
  1163. ! 318 String_Array *result = malloc(sizeof(String_Array));
  1164. push bp
  1165. mov bp,sp
  1166. push di
  1167. push si
  1168. dec sp
  1169. dec sp
  1170. ! Debug: list int = const 4 (used reg = )
  1171. mov ax,*4
  1172. push ax
  1173. ! Debug: func () * void = malloc+0 (used reg = )
  1174. call _malloc
  1175. inc sp
  1176. inc sp
  1177. ! Debug: eq * void = ax+0 to * struct String_Array result = [S+8-8] (used reg = )
  1178. mov -6[bp],ax
  1179. !BCC_EOS
  1180. ! 319 result->length = array_size;
  1181. mov bx,-6[bp]
  1182. ! Debug: eq int array_size = [S+8+2] to unsigned int = [bx+0] (used reg = )
  1183. mov ax,4[bp]
  1184. mov [bx],ax
  1185. !BCC_EOS
  1186. ! 320 result->strings = malloc(array_size * sizeof(Length_String));
  1187. ! Debug: mul int = const 6 to int array_size = [S+8+2] (used reg = )
  1188. mov ax,4[bp]
  1189. mov dx,ax
  1190. shl ax,*1
  1191. add ax,dx
  1192. shl ax,*1
  1193. ! Debug: list int = ax+0 (used reg = )
  1194. push ax
  1195. ! Debug: func () * void = malloc+0 (used reg = )
  1196. call _malloc
  1197. inc sp
  1198. inc sp
  1199. mov bx,-6[bp]
  1200. ! Debug: eq * void = ax+0 to * * struct Length_String = [bx+2] (used reg = )
  1201. mov 2[bx],ax
  1202. !BCC_EOS
  1203. ! 321 return result;
  1204. mov ax,-6[bp]
  1205. inc sp
  1206. inc sp
  1207. pop si
  1208. pop di
  1209. pop bp
  1210. ret
  1211. !BCC_EOS
  1212. ! 322 }
  1213. ! 323
  1214. ! 324
  1215. ! 325 Length_String *create_length_string(length, chars)
  1216. ! Register BX used in function create_length_string_array
  1217. ! 326 unsigned int length;
  1218. export _create_length_string
  1219. _create_length_string:
  1220. !BCC_EOS
  1221. ! 327 char *chars;
  1222. !BCC_EOS
  1223. ! 328 {
  1224. ! 329
  1225. ! 330 Length_String *legth_string = malloc(sizeof(Length_String));
  1226. push bp
  1227. mov bp,sp
  1228. push di
  1229. push si
  1230. dec sp
  1231. dec sp
  1232. ! Debug: list int = const 6 (used reg = )
  1233. mov ax,*6
  1234. push ax
  1235. ! Debug: func () * void = malloc+0 (used reg = )
  1236. call _malloc
  1237. inc sp
  1238. inc sp
  1239. ! Debug: eq * void = ax+0 to * struct Length_String legth_string = [S+8-8] (used reg = )
  1240. mov -6[bp],ax
  1241. !BCC_EOS
  1242. ! 331 char *copy = malloc(length + 1);
  1243. dec sp
  1244. dec sp
  1245. ! Debug: add int = const 1 to unsigned int length = [S+$A+2] (used reg = )
  1246. mov ax,4[bp]
  1247. ! Debug: list unsigned int = ax+1 (used reg = )
  1248. inc ax
  1249. push ax
  1250. ! Debug: func () * void = malloc+0 (used reg = )
  1251. call _malloc
  1252. inc sp
  1253. inc sp
  1254. ! Debug: eq * void = ax+0 to * char copy = [S+$A-$A] (used reg = )
  1255. mov -8[bp],ax
  1256. !BCC_EOS
  1257. ! 332 memcpy(copy, 0x7e0, chars, 0x7e0, length);
  1258. ! Debug: list unsigned int length = [S+$A+2] (used reg = )
  1259. push 4[bp]
  1260. ! Debug: list int = const $7E0 (used reg = )
  1261. mov ax,#$7E0
  1262. push ax
  1263. ! Debug: list * char chars = [S+$E+4] (used reg = )
  1264. push 6[bp]
  1265. ! Debug: list int = const $7E0 (used reg = )
  1266. mov ax,#$7E0
  1267. push ax
  1268. ! Debug: list * char copy = [S+$12-$A] (used reg = )
  1269. push -8[bp]
  1270. ! Debug: func () void = memcpy+0 (used reg = )
  1271. call _memcpy
  1272. add sp,*$A
  1273. !BCC_EOS
  1274. ! 333 copy[length] = '\0';
  1275. ! Debug: ptradd unsigned int length = [S+$A+2] to * char copy = [S+$A-$A] (used reg = )
  1276. mov ax,4[bp]
  1277. add ax,-8[bp]
  1278. mov bx,ax
  1279. ! Debug: eq int = const 0 to char = [bx+0] (used reg = )
  1280. xor al,al
  1281. mov [bx],al
  1282. !BCC_EOS
  1283. ! 334
  1284. ! 335 legth_string->dynamic = 1;
  1285. mov bx,-6[bp]
  1286. ! Debug: eq int = const 1 to short = [bx+0] (used reg = )
  1287. mov ax,*1
  1288. mov [bx],ax
  1289. !BCC_EOS
  1290. ! 336 legth_string->length = length;
  1291. mov bx,-6[bp]
  1292. ! Debug: eq unsigned int length = [S+$A+2] to unsigned int = [bx+2] (used reg = )
  1293. mov ax,4[bp]
  1294. mov 2[bx],ax
  1295. !BCC_EOS
  1296. ! 337 legth_string->chars = copy;
  1297. mov bx,-6[bp]
  1298. ! Debug: eq * char copy = [S+$A-$A] to * char = [bx+4] (used reg = )
  1299. mov si,-8[bp]
  1300. mov 4[bx],si
  1301. !BCC_EOS
  1302. ! 338
  1303. ! 339 return legth_string;
  1304. mov ax,-6[bp]
  1305. add sp,*4
  1306. pop si
  1307. pop di
  1308. pop bp
  1309. ret
  1310. !BCC_EOS
  1311. ! 340 # 21
  1312. ! 20 "implementation/../main.h"
  1313. ! 21 }
  1314. ! 22 # 1 "implementation/../driver/disk.h"
  1315. ! 1 int data_from_disk(index, number_sectors, data_buffer, data_buffer_segment);
  1316. ! Register BX SI used in function create_length_string
  1317. !BCC_EOS
  1318. ! 2 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment);
  1319. !BCC_EOS
  1320. ! 3
  1321. ! 4 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment)
  1322. ! 5 long* index;
  1323. export _disk_service_read_data_from_disk
  1324. _disk_service_read_data_from_disk:
  1325. !BCC_EOS
  1326. ! 6 long number_sectors;
  1327. !BCC_EOS
  1328. ! 7 void* data_buffer;
  1329. !BCC_EOS
  1330. ! 8 int data_buffer_segment;
  1331. !BCC_EOS
  1332. ! 9 {
  1333. ! 10
  1334. ! 11 #asm
  1335. !BCC_ASM
  1336. _disk_service_read_data_from_disk.data_buffer set 8
  1337. _disk_service_read_data_from_disk.number_sectors set 4
  1338. _disk_service_read_data_from_disk.data_buffer_segment set $A
  1339. _disk_service_read_data_from_disk.index set 2
  1340. ! 13 define number_sectors 8[bp];
  1341. push bp
  1342. mov bp,sp
  1343. pusha
  1344. lsfs_load_data:
  1345. mov ax, 4[bp];
  1346. mov WORD [DAPACK.lba_addr_dw_low], ax
  1347. mov bx, 8[bp];
  1348. mov WORD [DAPACK.blkcnt], bx
  1349. mov cx, 12[bp];
  1350. mov WORD [DAPACK.db_addr_segment], cx
  1351. mov dx, 10[bp]; ;
  1352. mov WORD [DAPACK.db_addr_offset], dx
  1353. mov si, #DAPACK ; address of
  1354. mov ah, #0x42 ; READ
  1355. mov dl, [global_disk_identifier]
  1356. int #0x13
  1357. ;call 0x0000:0x7C2A
  1358. popa
  1359. pop bp
  1360. ret
  1361. DAPACK:
  1362. DAPACK.dap_Size: db 0x10
  1363. DAPACK.rev_byte: db 0x0
  1364. DAPACK.blkcnt: dw 0x0
  1365. DAPACK.db_addr_offset: dw 0x0
  1366. DAPACK.db_addr_segment: dw 0x0
  1367. DAPACK.lba_addr_dw_low: dd 0x0
  1368. DAPACK.lba_addr_dw_high: dd 0x0
  1369. global_disk_identifier: db 0x80
  1370. ! 51 endasm
  1371. !BCC_ENDASM
  1372. ! 52 }
  1373. ret
  1374. ! 53 # 25 "implementation/../main.h"
  1375. ! 25 void dump_ax(input);
  1376. !BCC_EOS
  1377. ! 26 void print_stack(argument);
  1378. !BCC_EOS
  1379. ! 27 void print_newline();
  1380. !BCC_EOS
  1381. ! 28
  1382. ! 29 typedef struct struct_partition_control partition_control;
  1383. !BCC_EOS
  1384. ! 30 typedef struct File_System_Control_Information FSCI;
  1385. !BCC_EOS
  1386. ! 31 typedef struct meta_information_format mif;
  1387. !BCC_EOS
  1388. ! 32 typedef struct tag_record tag_record;
  1389. !BCC_EOS
  1390. ! 33 typedef struct Parameter_Struct Parameter_Struct;
  1391. !BCC_EOS
  1392. ! 34
  1393. ! 35
  1394. ! 36 typedef enum Service_Action
  1395. ! 37 {
  1396. ! 38 SERIVCE_LOAD_DISK = 1,
  1397. ! 39 SERVICE_FIND_ENTRY = 2,
  1398. ! 40 SERIVCE_READ_DATA = 3,
  1399. ! 41 SERIVCE_WRITE_DATA = 4,
  1400. ! 42
  1401. ! 43 } Service_Action;
  1402. !BCC_EOS
  1403. ! 44
  1404. ! 45 struct File_System_Control_Information
  1405. ! 46 {
  1406. ! 47 char filesystem_information[256];
  1407. !BCC_EOS
  1408. ! 48 long master_table_index[2];
  1409. !BCC_EOS
  1410. ! 49 long this_partition_offset_on_disk[2];
  1411. !BCC_EOS
  1412. ! 50 long next_free_sector[2];
  1413. !BCC_EOS
  1414. ! 51 long next_uniqe_id[2];
  1415. !BCC_EOS
  1416. ! 52 long next_secto
  1417. ! 52 r_reuse_pointer[2];
  1418. !BCC_EOS
  1419. ! 53 long last_sector_index_on_partition[2];
  1420. !BCC_EOS
  1421. ! 54 long maximum_sectors_on_disk[2];
  1422. !BCC_EOS
  1423. ! 55 long sector_size_on_disk[2];
  1424. !BCC_EOS
  1425. ! 56 long not_used[48];
  1426. !BCC_EOS
  1427. ! 57
  1428. ! 58 };
  1429. !BCC_EOS
  1430. ! 59
  1431. ! 60
  1432. ! 61 struct Parameter_Struct
  1433. ! 62 {
  1434. ! 63 char* path;
  1435. !BCC_EOS
  1436. ! 64 char* new_path;
  1437. !BCC_EOS
  1438. ! 65 int buffer_segment;
  1439. !BCC_EOS
  1440. ! 66 int buffer_address;
  1441. !BCC_EOS
  1442. ! 67 int buffer_size;
  1443. !BCC_EOS
  1444. ! 68 int data_length;
  1445. !BCC_EOS
  1446. ! 69 int byte_offset_into_file;
  1447. !BCC_EOS
  1448. ! 70 short entry_kind;
  1449. !BCC_EOS
  1450. ! 71 };
  1451. !BCC_EOS
  1452. ! 72 # 5 "implementation/lsfs.h"
  1453. ! 5 typedef struct lsfs_file lsfs_file;
  1454. !BCC_EOS
  1455. ! 6 typedef struct Directory_Table Directory_Table;
  1456. !BCC_EOS
  1457. ! 7 typedef struct Table_Entry Table_Entry;
  1458. !BCC_EOS
  1459. ! 8
  1460. ! 9 int lsfs_disk_getattr(find_file, path);
  1461. !BCC_EOS
  1462. ! 10 int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry);
  1463. !BCC_EOS
  1464. ! 11 Directory_Table* lsfs_find_directory(path, drop_filename);
  1465. !BCC_EOS
  1466. ! 12
  1467. ! 13 typedef enum Table_Entry_Kind
  1468. ! 14 {
  1469. ! 15
  1470. ! 16 ENTRY_EMPTY = 0,
  1471. ! 17 ENTRY_FILE = 1,
  1472. ! 18 ENTRY_DIRECTORY = 2,
  1473. ! 19 } Table_Entry_Kind;
  1474. !BCC_EOS
  1475. ! 20
  1476. ! 21 struct Table_Entry
  1477. ! 22 {
  1478. ! 23 char filename[256];
  1479. !BCC_EOS
  1480. ! 24 long file_id[2];
  1481. !BCC_EOS
  1482. ! 25 long file_size[2];
  1483. !BCC_EOS
  1484. ! 26 void* ext_file_data_low;
  1485. !BCC_EOS
  1486. ! 27 void* ext_file_data_high;
  1487. !BCC_EOS
  1488. ! 28 long number_sector_s;
  1489. !BCC_EOS
  1490. ! 29 short entry_kind;
  1491. !BCC_EOS
  1492. ! 30 short extra_control_bits1;
  1493. !BCC_EOS
  1494. ! 31 short extra_control_bits2;
  1495. !BCC_EOS
  1496. ! 32 short extra_control_bits3;
  1497. !BCC_EOS
  1498. ! 33 long table_entry_sector_index[2];
  1499. !BCC_EOS
  1500. ! 34 long data_pointer[27 * 2];
  1501. !BCC_EOS
  1502. ! 35 };
  1503. !BCC_EOS
  1504. ! 36
  1505. ! 37 struct lsfs_file {
  1506. ! 38 long file_id[2];
  1507. !BCC_EOS
  1508. ! 39 long table_entry_pointer[2];
  1509. !BCC_EOS
  1510. ! 40 Table_Entry_Kind entry_kind;
  1511. !BCC_EOS
  1512. ! 41 char* filename;
  1513. !BCC_EOS
  1514. ! 42 long owner_id;
  1515. !BCC_EOS
  1516. ! 43 long size[2];
  1517. !BCC_EOS
  1518. ! 44 long creation_date[2];
  1519. !BCC_EOS
  1520. ! 45 long access_time[2];
  1521. !BCC_EOS
  1522. ! 46 long modification_time[2];
  1523. !BCC_EOS
  1524. ! 47 long number_sector;
  1525. !BCC_EOS
  1526. ! 48 long table_entry_sector_index[2];
  1527. !BCC_EOS
  1528. ! 49 long data_pointer[27 * 2];
  1529. !BCC_EOS
  1530. ! 50 };
  1531. !BCC_EOS
  1532. ! 51
  1533. ! 52 struct Directory_Table
  1534. ! 53 {
  1535. ! 54 Table_Entry entries[16 ];
  1536. !BCC_EOS
  1537. ! 55
  1538. ! 56 };
  1539. !BCC_EOS
  1540. ! 57 # 3 "implementation/lsfs.c"
  1541. ! 3 extern FSCI fsci;
  1542. !BCC_EOS
  1543. ! 4
  1544. ! 5 int lsfs_disk_getattr(find_file, path)
  1545. ! 6 lsfs_file* find_file;
  1546. export _lsfs_disk_getattr
  1547. _lsfs_disk_getattr:
  1548. !BCC_EOS
  1549. ! 7 char* path;
  1550. !BCC_EOS
  1551. ! 8 {
  1552. ! 9 int i;
  1553. !BCC_EOS
  1554. ! 10 String_Array *split_path = string_split_c(path, '/', 0 );
  1555. push bp
  1556. mov bp,sp
  1557. push di
  1558. push si
  1559. add sp,*-4
  1560. ! Debug: list int = const 0 (used reg = )
  1561. xor ax,ax
  1562. push ax
  1563. ! Debug: list int = const $2F (used reg = )
  1564. mov ax,*$2F
  1565. push ax
  1566. ! Debug: list * char path = [S+$E+4] (used reg = )
  1567. push 6[bp]
  1568. ! Debug: func () * struct String_Array = string_split_c+0 (used reg = )
  1569. call _string_split_c
  1570. add sp,*6
  1571. ! Debug: eq * struct String_Array = ax+0 to * struct String_Array split_path = [S+$A-$A] (used reg = )
  1572. mov -8[bp],ax
  1573. !BCC_EOS
  1574. ! 11 Length_String *filename = split_path->strings[split_path->length-1];
  1575. dec sp
  1576. dec sp
  1577. mov bx,-8[bp]
  1578. ! Debug: sub int = const 1 to unsigned int = [bx+0] (used reg = )
  1579. mov bx,[bx]
  1580. mov si,-8[bp]
  1581. ! Debug: ptradd unsigned int = bx-1 to * * struct Length_String = [si+2] (used reg = )
  1582. mov ax,bx
  1583. dec ax
  1584. shl ax,*1
  1585. add ax,2[si]
  1586. mov bx,ax
  1587. ! Debug: eq * struct Length_String = [bx+0] to * struct Length_String filename = [S+$C-$C] (used reg = )
  1588. mov bx,[bx]
  1589. mov -$A[bp],bx
  1590. !BCC_EOS
  1591. ! 12
  1592. ! 13
  1593. ! 14 Directory_Table *dir_table = lsfs_find_directory(path, 1 );
  1594. dec sp
  1595. dec sp
  1596. ! Debug: list int = const 1 (used reg = )
  1597. mov ax,*1
  1598. push ax
  1599. ! Debug: list * char path = [S+$10+4] (used reg = )
  1600. push 6[bp]
  1601. ! Debug: func () * struct Directory_Table = lsfs_find_directory+0 (used reg = )
  1602. call _lsfs_find_directory
  1603. add sp,*4
  1604. ! Debug: eq * struct Directory_Table = ax+0 to * struct Directory_Table dir_table = [S+$E-$E] (used reg = )
  1605. mov -$C[bp],ax
  1606. !BCC_EOS
  1607. ! 15
  1608. ! 16 for (i = 0; i < 16 ; ++i)
  1609. ! Debug: eq int = const 0 to int i = [S+$E-8] (used reg = )
  1610. xor ax,ax
  1611. mov -6[bp],ax
  1612. !BCC_EOS
  1613. !BCC_EOS
  1614. ! 17 {
  1615. br .2C
  1616. .2D:
  1617. ! 18 if(strcmp( filename
  1618. ! 18 ->chars, dir_table->entries[i].filename ) == 0) {
  1619. ! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = )
  1620. mov ax,-6[bp]
  1621. mov cx,#$200
  1622. imul cx
  1623. add ax,-$C[bp]
  1624. mov bx,ax
  1625. ! Debug: cast * char = const 0 to [$100] char = bx+0 (used reg = )
  1626. ! Debug: list * char = bx+0 (used reg = )
  1627. push bx
  1628. mov bx,-$A[bp]
  1629. ! Debug: list * char = [bx+4] (used reg = )
  1630. push 4[bx]
  1631. ! Debug: func () int = strcmp+0 (used reg = )
  1632. call _strcmp
  1633. add sp,*4
  1634. ! Debug: logeq int = const 0 to int = ax+0 (used reg = )
  1635. test ax,ax
  1636. bne .2E
  1637. .2F:
  1638. ! 19 find_file->file_id[0] = dir_table->entries[i].file_id;
  1639. ! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = )
  1640. mov ax,-6[bp]
  1641. mov cx,#$200
  1642. imul cx
  1643. add ax,-$C[bp]
  1644. mov bx,ax
  1645. ! Debug: ptradd int = const 0 to [2] long find_file = [S+$E+2] (used reg = bx)
  1646. mov si,4[bp]
  1647. ! Debug: eq [2] long = bx+$100 to long = [si+0] (used reg = )
  1648. mov ax,bx
  1649. add ax,#$100
  1650. xor bx,bx
  1651. mov [si],ax
  1652. mov 2[si],bx
  1653. !BCC_EOS
  1654. ! 20 find_file->entry_kind = dir_table->entries[i].entry_kind;
  1655. ! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = )
  1656. mov ax,-6[bp]
  1657. mov cx,#$200
  1658. imul cx
  1659. add ax,-$C[bp]
  1660. mov bx,ax
  1661. mov si,4[bp]
  1662. ! Debug: eq short = [bx+$118] to int = [si+$10] (used reg = )
  1663. mov bx,$118[bx]
  1664. mov $10[si],bx
  1665. !BCC_EOS
  1666. ! 21 find_file->table_entry_pointer[0] = i;
  1667. mov bx,4[bp]
  1668. ! Debug: ptradd int = const 0 to [2] long = bx+8 (used reg = )
  1669. ! Debug: eq int i = [S+$E-8] to long = [bx+8] (used reg = )
  1670. mov ax,-6[bp]
  1671. cwd
  1672. mov si,dx
  1673. mov 8[bx],ax
  1674. mov $A[bx],si
  1675. !BCC_EOS
  1676. ! 22 find_file->filename = dir_table->entries[i].filename;
  1677. ! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = )
  1678. mov ax,-6[bp]
  1679. mov cx,#$200
  1680. imul cx
  1681. add ax,-$C[bp]
  1682. mov bx,ax
  1683. mov si,4[bp]
  1684. ! Debug: eq [$100] char = bx+0 to * char = [si+$12] (used reg = )
  1685. mov $12[si],bx
  1686. !BCC_EOS
  1687. ! 23 find_file->table_entry_sector_index[0] = dir_table->entries[i].table_entry_sector_index;
  1688. ! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = )
  1689. mov ax,-6[bp]
  1690. mov cx,#$200
  1691. imul cx
  1692. add ax,-$C[bp]
  1693. mov bx,ax
  1694. mov si,4[bp]
  1695. ! Debug: ptradd int = const 0 to [2] long = si+$3C (used reg = bx)
  1696. ! Debug: eq [2] long = bx+$120 to long = [si+$3C] (used reg = )
  1697. mov ax,bx
  1698. add ax,#$120
  1699. xor bx,bx
  1700. mov $3C[si],ax
  1701. mov $3E[si],bx
  1702. !BCC_EOS
  1703. ! 24 find_file->owner_id = 1;
  1704. mov bx,4[bp]
  1705. ! Debug: eq int = const 1 to long = [bx+$14] (used reg = )
  1706. mov ax,*1
  1707. xor si,si
  1708. mov $14[bx],ax
  1709. mov $16[bx],si
  1710. !BCC_EOS
  1711. ! 25 find_file->size[0] = dir_table->entries[i].file_size;
  1712. ! Debug: ptradd int i = [S+$E-8] to [$10] struct Table_Entry dir_table = [S+$E-$E] (used reg = )
  1713. mov ax,-6[bp]
  1714. mov cx,#$200
  1715. imul cx
  1716. add ax,-$C[bp]
  1717. mov bx,ax
  1718. mov si,4[bp]
  1719. ! Debug: ptradd int = const 0 to [2] long = si+$18 (used reg = bx)
  1720. ! Debug: eq [2] long = bx+$108 to long = [si+$18] (used reg = )
  1721. mov ax,bx
  1722. add ax,#$108
  1723. xor bx,bx
  1724. mov $18[si],ax
  1725. mov $1A[si],bx
  1726. !BCC_EOS
  1727. ! 26 find_file->creation_date[0] = 0;
  1728. mov bx,4[bp]
  1729. ! Debug: ptradd int = const 0 to [2] long = bx+$20 (used reg = )
  1730. ! Debug: eq int = const 0 to long = [bx+$20] (used reg = )
  1731. xor ax,ax
  1732. xor si,si
  1733. mov $20[bx],ax
  1734. mov $22[bx],si
  1735. !BCC_EOS
  1736. ! 27 find_file->access_time[0] = 0;
  1737. mov bx,4[bp]
  1738. ! Debug: ptradd int = const 0 to [2] long = bx+$28 (used reg = )
  1739. ! Debug: eq int = const 0 to long = [bx+$28] (used reg = )
  1740. xor ax,ax
  1741. xor si,si
  1742. mov $28[bx],ax
  1743. mov $2A[bx],si
  1744. !BCC_EOS
  1745. ! 28 find_file->modification_time[0] = 0;
  1746. mov bx,4[bp]
  1747. ! Debug: ptradd int = const 0 to [2] long = bx+$30 (used reg = )
  1748. ! Debug: eq int = const 0 to long = [bx+$30] (used reg = )
  1749. xor ax,ax
  1750. xor si,si
  1751. mov $30[bx],ax
  1752. mov $32[bx],si
  1753. !BCC_EOS
  1754. ! 29 memcpy(find_file->data_pointer, dir_table->entries[i].data_pointer, 27 * 8);
  1755. ! Debug: list int = const $D8 (used reg = )
  1756. mov ax,#$D8
  1757. push ax
  1758. ! Debug: ptradd int i = [S+$10-8] to [$10] struct Table_Entry dir_table = [S+$10-$E] (used reg = )
  1759. mov ax,-6[bp]
  1760. mov cx,#$200
  1761. imul cx
  1762. add ax,-$C[bp]
  1763. mov bx,ax
  1764. ! Debug: cast * long = const 0 to [$36] long = bx+$128 (used reg = )
  1765. ! Debug: list * long = bx+$128 (used reg = )
  1766. add bx,#$128
  1767. push bx
  1768. mov bx,4[bp]
  1769. ! Debug: cast * long = const 0 to [$36] long = bx+$44 (used reg = )
  1770. ! Debug: list * long = bx+$44 (used reg = )
  1771. add bx,*$44
  1772. push bx
  1773. ! Debug: func () void = memcpy+0 (used reg = )
  1774. call _memcpy
  1775. add sp,*6
  1776. !BCC_EOS
  1777. ! 30 find_file->number_sector = 1;
  1778. mov bx,4[bp]
  1779. ! Debug: eq int = const 1 to long = [bx+$38] (used reg = )
  1780. mov ax,*1
  1781. xor si,si
  1782. mov $38[bx],ax
  1783. mov $3A[bx],si
  1784. !BCC_EOS
  1785. ! 31 return 1;
  1786. mov ax,*1
  1787. add sp,*8
  1788. pop si
  1789. pop di
  1790. pop bp
  1791. ret
  1792. !BCC_EOS
  1793. ! 32 }
  1794. ! 33 }
  1795. .2E:
  1796. ! 34 return 0;
  1797. .2B:
  1798. ! Debug: preinc int i = [S+$E-8] (used reg = )
  1799. mov ax,-6[bp]
  1800. inc ax
  1801. mov -6[bp],ax
  1802. .2C:
  1803. ! Debug: lt int = const $10 to int i = [S+$E-8] (used reg = )
  1804. mov ax,-6[bp]
  1805. cmp ax,*$10
  1806. blt .2D
  1807. .31:
  1808. .2A:
  1809. xor ax,ax
  1810. add sp,*8
  1811. pop si
  1812. pop di
  1813. pop bp
  1814. ret
  1815. !BCC_EOS
  1816. ! 35 }
  1817. ! 36
  1818. ! 37 Directory_Table* lsfs_find_directory(path, drop_filename)
  1819. ! Register BX SI used in function lsfs_disk_getattr
  1820. ! 38 char *path;
  1821. export _lsfs_find_directory
  1822. _lsfs_find_directory:
  1823. !BCC_EOS
  1824. ! 39 short drop_filename;
  1825. !BCC_EOS
  1826. ! 40 {
  1827. ! 41 int number_of_traversal;
  1828. !BCC_EOS
  1829. ! 42 int i, j;
  1830. !BCC_EOS
  1831. ! 43 String_Array *split_path;
  1832. !BCC_EOS
  1833. ! 44 Directory_Table *dir_table = calloc(1, sizeof(Directory_Table));
  1834. push bp
  1835. mov bp,sp
  1836. push di
  1837. push si
  1838. add sp,*-$A
  1839. ! Debug: list int = const $2000 (used reg = )
  1840. mov ax,#$2000
  1841. push ax
  1842. ! Debug: list int = const 1 (used reg = )
  1843. mov ax,*1
  1844. push ax
  1845. ! Debug: func () * void = calloc+0 (used reg = )
  1846. call _calloc
  1847. add sp,*4
  1848. ! Debug: eq * void = ax+0 to * struct Directory_Table dir_table = [S+$10-$10] (used reg = )
  1849. mov -$E[bp],ax
  1850. !BCC_EOS
  1851. ! 45
  1852. ! 46 disk_service_read_data_from_disk(fsci.master_table_index[0], 16 , dir_table, 0x7e0);
  1853. ! Debug: list int = const $7E0 (used reg = )
  1854. mov ax,#$7E0
  1855. push ax
  1856. ! Debug: list * struct Directory_Table dir_table = [S+$12-$10] (used reg = )
  1857. push -$E[bp]
  1858. ! Debug: list int = const $10 (used reg = )
  1859. mov ax,*$10
  1860. push ax
  1861. ! Debug: list long = [fsci+$100] (used reg = )
  1862. push [_fsci+$102]
  1863. push [_fsci+$100]
  1864. ! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = )
  1865. call _disk_service_read_data_from_disk
  1866. add sp,*$A
  1867. !BCC_EOS
  1868. ! 47 split_path = string_split_c(path, '/', 0 );
  1869. ! Debug: list int = const 0 (used reg = )
  1870. xor ax,ax
  1871. push ax
  1872. ! Debug: list int = const $2F (used reg = )
  1873. mov ax,*$2F
  1874. push ax
  1875. ! Debug: list * char path = [S+$14+2] (used reg = )
  1876. push 4[bp]
  1877. ! Debug: func () * struct String_Array = string_split_c+0 (used reg = )
  1878. call _string_split_c
  1879. add sp,*6
  1880. ! Debug: eq * struct String_Array = ax+0 to * struct String_Array split_path = [S+$10-$E] (used reg = )
  1881. mov -$C[bp],ax
  1882. !BCC_EOS
  1883. ! 48
  1884. ! 49 number_of_traversal = split_path->length;
  1885. mov bx,-$C[bp]
  1886. ! Debug: eq unsigned int = [bx+0] to int number_of_traversal = [S+$10-8] (used reg = )
  1887. mov bx,[bx]
  1888. mov -6[bp],bx
  1889. !BCC_EOS
  1890. ! 50
  1891. ! 51 if (drop_filename)
  1892. mov ax,6[bp]
  1893. test ax,ax
  1894. je .32
  1895. .33:
  1896. ! 52 {
  1897. ! 53 number_of_traversal -= 1;
  1898. ! Debug: subab int = const 1 to int number_of_traversal = [S+$10-8] (used reg = )
  1899. mov ax,-6[bp]
  1900. dec ax
  1901. mov -6[bp],ax
  1902. !BCC_EOS
  1903. ! 54 }
  1904. ! 55
  1905. ! 56
  1906. ! 57 for (i = 0; i < number_of_traversal; ++i)
  1907. .32:
  1908. ! Debug: eq int = const 0 to int i = [S+$10-$A] (used reg = )
  1909. xor ax,ax
  1910. mov -8[bp],ax
  1911. !BCC_EOS
  1912. !BCC_EOS
  1913. ! 58 {
  1914. jmp .36
  1915. .37:
  1916. ! 59 for (j = 0; j < 16 ; ++j)
  1917. ! Debug: eq int = const 0 to int j = [S+$10-$C] (used reg = )
  1918. xor ax,ax
  1919. mov -$A[bp],ax
  1920. !BCC_EOS
  1921. !BCC_EOS
  1922. ! 60 {
  1923. jmp .3A
  1924. .3B:
  1925. ! 61 if (strcmp(dir_table->entries[j].filename, split_path->strings[i]->chars) == 0)
  1926. mov bx,-$C[bp]
  1927. ! Debug: ptradd int i = [S+$10-$A] to * * struct Length_String = [bx+2] (used reg = )
  1928. mov ax,-8[bp]
  1929. shl ax,*1
  1930. add ax,2[bx]
  1931. mov bx,ax
  1932. mov bx,[bx]
  1933. ! Debug: list * char = [bx+4] (used reg = )
  1934. push 4[bx]
  1935. ! Debug: ptradd int j = [S+$12-$C] to [$10] struct Table_Entry dir_table = [S+$12-$10] (used reg = )
  1936. mov ax,-$A[bp]
  1937. mov cx,#$200
  1938. imul cx
  1939. add ax,-$E[bp]
  1940. mov bx,ax
  1941. ! Debug: cast * char = const 0 to [$100] char = bx+0 (used reg = )
  1942. ! Debug: list * char = bx+0 (used reg = )
  1943. push bx
  1944. ! Debug: func () int = strcmp+0 (used reg = )
  1945. call _strcmp
  1946. add sp,*4
  1947. ! Debug: logeq int = const 0 to int = ax+0 (used reg = )
  1948. test ax,ax
  1949. jne .3C
  1950. .3D:
  1951. ! 62 {
  1952. ! 63 int index_sector = dir_table->entries[j].data_pointer[0];
  1953. dec sp
  1954. dec sp
  1955. ! Debug: ptradd int j = [S+$12-$C] to [$10] struct Table_Entry dir_table = [S+$12-$10] (used reg = )
  1956. mov ax,-$A[bp]
  1957. mov cx,#$200
  1958. imul cx
  1959. add ax,-$E[bp]
  1960. mov bx,ax
  1961. ! Debug: ptradd int = const 0 to [$36] long = bx+$128 (used reg = )
  1962. ! Debug: eq long = [bx+$128] to int index_sector = [S+$12-$12] (used reg = )
  1963. mov bx,$128[bx]
  1964. mov -$10[bp],bx
  1965. !BCC_EOS
  1966. ! 64
  1967. ! 65 disk_service_read_data_from_disk(index_sector, 16 , dir_table);
  1968. ! Debug: list * struct Directory_Table dir_table = [S+$12-$10] (used reg = )
  1969. push -$E[bp]
  1970. ! Debug: list int = const $10 (used reg = )
  1971. mov ax,*$10
  1972. push ax
  1973. ! Debug: list int index_sector = [S+$16-$12] (used reg = )
  1974. push -$10[bp]
  1975. ! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = )
  1976. call _disk_service_read_data_from_disk
  1977. add sp,*6
  1978. !BCC_EOS
  1979. ! 66 break;
  1980. inc sp
  1981. inc sp
  1982. jmp .38
  1983. !BCC_EOS
  1984. ! 67 }
  1985. inc sp
  1986. inc sp
  1987. ! 68 }
  1988. .3C:
  1989. ! 69 }
  1990. .39:
  1991. ! Debug: preinc int j = [S+$10-$C] (used reg = )
  1992. mov ax,-$A[bp]
  1993. inc ax
  1994. mov -$A[bp],ax
  1995. .3A:
  1996. ! Debug: lt int = const $10 to int j = [S+$10-$C] (used reg = )
  1997. mov ax,-$A[bp]
  1998. cmp ax,*$10
  1999. jl .3B
  2000. .3E:
  2001. .38:
  2002. ! 70 return dir_table;
  2003. .35:
  2004. ! Debug: preinc int i = [S+$10-$A] (used reg = )
  2005. mov ax,-8[bp]
  2006. inc ax
  2007. mov -8[bp],ax
  2008. .36:
  2009. ! Debug: lt int number_of_traversal = [S+$10-8] to int i = [S+$10-$A] (used reg = )
  2010. mov ax,-8[bp]
  2011. cmp ax,-6[bp]
  2012. jl .37
  2013. .3F:
  2014. .34:
  2015. mov ax,-$E[bp]
  2016. add sp,*$A
  2017. pop si
  2018. pop di
  2019. pop bp
  2020. ret
  2021. !BCC_EOS
  2022. ! 71 }
  2023. ! 72
  2024. ! 73 int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry, data_segment)
  2025. ! Register BX used in function lsfs_find_directory
  2026. ! 74 lsfs_file *file;
  2027. export _lsfs_disk_read_data_from_file
  2028. _lsfs_disk_read_data_from_file:
  2029. !BCC_EOS
  2030. ! 75 int buffer_size;
  2031. !BCC_EOS
  2032. ! 76 char *data;
  2033. !BCC_EOS
  2034. ! 77 long offset_to_next_entry;
  2035. !BCC_EOS
  2036. ! 78 unsigned int data_segment;
  2037. !BCC_EOS
  2038. ! 79 {
  2039. ! 80 int integer_file_size = file->size;
  2040. push bp
  2041. mov bp,sp
  2042. push di
  2043. push si
  2044. dec sp
  2045. dec sp
  2046. mov bx,4[bp]
  2047. ! Debug: eq [2] long = bx+$18 to int integer_file_size = [S+8-8] (used reg = )
  2048. add bx,*$18
  2049. mov -6[bp],bx
  2050. !BCC_EOS
  2051. ! 81 int integer_o
  2052. ! 81 ffset = offset_to_next_entry;
  2053. dec sp
  2054. dec sp
  2055. ! Debug: eq long offset_to_next_entry = [S+$A+8] to int integer_offset = [S+$A-$A] (used reg = )
  2056. mov ax,$A[bp]
  2057. mov -8[bp],ax
  2058. !BCC_EOS
  2059. ! 82 int integer_datapointer = 0;
  2060. dec sp
  2061. dec sp
  2062. ! Debug: eq int = const 0 to int integer_datapointer = [S+$C-$C] (used reg = )
  2063. xor ax,ax
  2064. mov -$A[bp],ax
  2065. !BCC_EOS
  2066. ! 83 int data_length = integer_file_size - integer_offset;
  2067. dec sp
  2068. dec sp
  2069. ! Debug: sub int integer_offset = [S+$E-$A] to int integer_file_size = [S+$E-8] (used reg = )
  2070. mov ax,-6[bp]
  2071. sub ax,-8[bp]
  2072. ! Debug: eq int = ax+0 to int data_length = [S+$E-$E] (used reg = )
  2073. mov -$C[bp],ax
  2074. !BCC_EOS
  2075. ! 84 int amount_read = 0;
  2076. dec sp
  2077. dec sp
  2078. ! Debug: eq int = const 0 to int amount_read = [S+$10-$10] (used reg = )
  2079. xor ax,ax
  2080. mov -$E[bp],ax
  2081. !BCC_EOS
  2082. ! 85 int amount_to_read = 0;
  2083. dec sp
  2084. dec sp
  2085. ! Debug: eq int = const 0 to int amount_to_read = [S+$12-$12] (used reg = )
  2086. xor ax,ax
  2087. mov -$10[bp],ax
  2088. !BCC_EOS
  2089. ! 86 int remaining_offset = offset_to_next_entry;
  2090. dec sp
  2091. dec sp
  2092. ! Debug: eq long offset_to_next_entry = [S+$14+8] to int remaining_offset = [S+$14-$14] (used reg = )
  2093. mov ax,$A[bp]
  2094. mov -$12[bp],ax
  2095. !BCC_EOS
  2096. ! 87
  2097. ! 88
  2098. ! 89
  2099. ! 90
  2100. ! 91
  2101. ! 92 int data_pointer_index = 0;
  2102. dec sp
  2103. dec sp
  2104. ! Debug: eq int = const 0 to int data_pointer_index = [S+$16-$16] (used reg = )
  2105. xor ax,ax
  2106. mov -$14[bp],ax
  2107. !BCC_EOS
  2108. ! 93
  2109. ! 94 if (data_length > buffer_size)
  2110. ! Debug: gt int buffer_size = [S+$16+4] to int data_length = [S+$16-$E] (used reg = )
  2111. mov ax,-$C[bp]
  2112. cmp ax,6[bp]
  2113. jle .40
  2114. .41:
  2115. ! 95 {
  2116. ! 96 data_length = buffer_size;
  2117. ! Debug: eq int buffer_size = [S+$16+4] to int data_length = [S+$16-$E] (used reg = )
  2118. mov ax,6[bp]
  2119. mov -$C[bp],ax
  2120. !BCC_EOS
  2121. ! 97 }
  2122. ! 98
  2123. ! 99 while(data_length > 0)
  2124. .40:
  2125. ! 100 {
  2126. br .43
  2127. .44:
  2128. ! 101
  2129. ! 102 if (remaining_offset == 0)
  2130. ! Debug: logeq int = const 0 to int remaining_offset = [S+$16-$14] (used reg = )
  2131. mov ax,-$12[bp]
  2132. test ax,ax
  2133. bne .45
  2134. .46:
  2135. ! 103 {
  2136. ! 104 char *tmp_buffer = calloc(4 , 512 );
  2137. dec sp
  2138. dec sp
  2139. ! Debug: list int = const $200 (used reg = )
  2140. mov ax,#$200
  2141. push ax
  2142. ! Debug: list int = const 4 (used reg = )
  2143. mov ax,*4
  2144. push ax
  2145. ! Debug: func () * void = calloc+0 (used reg = )
  2146. call _calloc
  2147. add sp,*4
  2148. ! Debug: eq * void = ax+0 to * char tmp_buffer = [S+$18-$18] (used reg = )
  2149. mov -$16[bp],ax
  2150. !BCC_EOS
  2151. ! 105
  2152. ! 106
  2153. ! 107 if (data_length < (4 * 512 ))
  2154. ! Debug: lt int = const $800 to int data_length = [S+$18-$E] (used reg = )
  2155. mov ax,-$C[bp]
  2156. cmp ax,#$800
  2157. jge .47
  2158. .48:
  2159. ! 108 {
  2160. ! 109 amount_to_read = data_length;
  2161. ! Debug: eq int data_length = [S+$18-$E] to int amount_to_read = [S+$18-$12] (used reg = )
  2162. mov ax,-$C[bp]
  2163. mov -$10[bp],ax
  2164. !BCC_EOS
  2165. ! 110 }
  2166. ! 111 else
  2167. ! 112 {
  2168. jmp .49
  2169. .47:
  2170. ! 113 amount_to_read = (4 * 512 );
  2171. ! Debug: eq int = const $800 to int amount_to_read = [S+$18-$12] (used reg = )
  2172. mov ax,#$800
  2173. mov -$10[bp],ax
  2174. !BCC_EOS
  2175. ! 114 }
  2176. ! 115
  2177. ! 116 integer_datapointer = file->data_pointer[data_pointer_index];
  2178. .49:
  2179. mov bx,4[bp]
  2180. ! Debug: ptradd int data_pointer_index = [S+$18-$16] to [$36] long = bx+$44 (used reg = )
  2181. mov ax,-$14[bp]
  2182. shl ax,*1
  2183. shl ax,*1
  2184. add bx,ax
  2185. ! Debug: eq long = [bx+$44] to int integer_datapointer = [S+$18-$C] (used reg = )
  2186. mov bx,$44[bx]
  2187. mov -$A[bp],bx
  2188. !BCC_EOS
  2189. ! 117 if (integer_datapointer == 0)
  2190. ! Debug: logeq int = const 0 to int integer_datapointer = [S+$18-$C] (used reg = )
  2191. mov ax,-$A[bp]
  2192. test ax,ax
  2193. jne .4A
  2194. .4B:
  2195. ! 118 {
  2196. ! 119 break;
  2197. inc sp
  2198. inc sp
  2199. br .42
  2200. !BCC_EOS
  2201. ! 120 }
  2202. ! 121 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], 4 , tmp_buffer, 0x7e0);
  2203. .4A:
  2204. ! Debug: list int = const $7E0 (used reg = )
  2205. mov ax,#$7E0
  2206. push ax
  2207. ! Debug: list * char tmp_buffer = [S+$1A-$18] (used reg = )
  2208. push -$16[bp]
  2209. ! Debug: list int = const 4 (used reg = )
  2210. mov ax,*4
  2211. push ax
  2212. mov bx,4[bp]
  2213. ! Debug: ptradd int data_pointer_index = [S+$1E-$16] to [$36] long = bx+$44 (used reg = )
  2214. mov ax,-$14[bp]
  2215. shl ax,*1
  2216. shl ax,*1
  2217. add bx,ax
  2218. ! Debug: list long = [bx+$44] (used reg = )
  2219. push $46[bx]
  2220. push $44[bx]
  2221. ! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = )
  2222. call _disk_service_read_data_from_disk
  2223. add sp,*$A
  2224. !BCC_EOS
  2225. ! 122 memcpy((data + amount_read), data_segment, tmp_buffer, 0x7e0, amount_to_read);
  2226. ! Debug: list int amount_to_read = [S+$18-$12] (used reg = )
  2227. push -$10[bp]
  2228. ! Debug: list int = const $7E0 (used reg = )
  2229. mov ax,#$7E0
  2230. push ax
  2231. ! Debug: list * char tmp_buffer = [S+$1C-$18] (used reg = )
  2232. push -$16[bp]
  2233. ! Debug: list unsigned int data_segment = [S+$1E+$C] (used reg = )
  2234. push $E[bp]
  2235. ! Debug: ptradd int amount_read = [S+$20-$10] to * char data = [S+$20+6] (used reg = )
  2236. mov ax,-$E[bp]
  2237. add ax,8[bp]
  2238. ! Debug: list * char = ax+0 (used reg = )
  2239. push ax
  2240. ! Debug: func () void = memcpy+0 (used reg = )
  2241. call _memcpy
  2242. add sp,*$A
  2243. !BCC_EOS
  2244. ! 123 data_length -= amount_to_read;
  2245. ! Debug: subab int amount_to_read = [S+$18-$12] to int data_length = [S+$18-$E] (used reg = )
  2246. mov ax,-$C[bp]
  2247. sub ax,-$10[bp]
  2248. mov -$C[bp],ax
  2249. !BCC_EOS
  2250. ! 124 amount_read += amount_to_read;
  2251. ! Debug: addab int amount_to_read = [S+$18-$12] to int amount_read = [S+$18-$10] (used reg = )
  2252. mov ax,-$E[bp]
  2253. add ax,-$10[bp]
  2254. mov -$E[bp],ax
  2255. !BCC_EOS
  2256. ! 125 data_pointer_index = data_pointer_index + 2;
  2257. ! Debug: add int = const 2 to int data_pointer_index = [S+$18-$16] (used reg = )
  2258. mov ax,-$14[bp]
  2259. ! Debug: eq int = ax+2 to int data_pointer_index = [S+$18-$16] (used reg = )
  2260. inc ax
  2261. inc ax
  2262. mov -$14[bp],ax
  2263. !BCC_EOS
  2264. ! 126
  2265. ! 127 }
  2266. inc sp
  2267. inc sp
  2268. ! 128 else if (remaining_offset < (4 * 512 ))
  2269. br .4C
  2270. .45:
  2271. ! Debug: lt int = const $800 to int remaining_offset = [S+$16-$14] (used reg = )
  2272. mov ax,-$12[bp]
  2273. cmp ax,#$800
  2274. bge .4D
  2275. .4E:
  2276. ! 129 {
  2277. ! 130 char *tmp_buffer = calloc(1, (4 * 512 ));
  2278. dec sp
  2279. dec sp
  2280. ! Debug: list int = const $800 (used reg = )
  2281. mov ax,#$800
  2282. push ax
  2283. ! Debug: list int = const 1 (used reg = )
  2284. mov ax,*1
  2285. push ax
  2286. ! Debug: func () * void = calloc+0 (used reg = )
  2287. call _calloc
  2288. add sp,*4
  2289. ! Debug: eq * void = ax+0 to * char tmp_buffer = [S+$18-$18] (used reg = )
  2290. mov -$16[bp],ax
  2291. !BCC_EOS
  2292. ! 131
  2293. ! 132
  2294. ! 133 if (data_length < ((4 * 512 ) - remaining_offset) )
  2295. ! Debug: sub int remaining_offset = [S+$18-$14] to int = const $800 (used reg = )
  2296. mov ax,#$800
  2297. sub ax,-$12[bp]
  2298. ! Debug: lt int = ax+0 to int data_length = [S+$18-$E] (used reg = )
  2299. cmp ax,-$C[bp]
  2300. jle .4F
  2301. .50:
  2302. ! 134 {
  2303. ! 135 amount_to_read = data_length;
  2304. ! Debug: eq int data_length = [S+$18-$E] to int amount_to_read = [S+$18-$12] (used reg = )
  2305. mov ax,-$C[bp]
  2306. mov -$10[bp],ax
  2307. !BCC_EOS
  2308. ! 136 }
  2309. ! 137 else
  2310. ! 138 {
  2311. jmp .51
  2312. .4F:
  2313. ! 139 amount_to_read = ((4 * 512 ) - remaining_offset);
  2314. ! Debug: sub int remaining_offset = [S+$18-$14] to int = const $800 (used reg = )
  2315. mov ax,#$800
  2316. sub ax,-$12[bp]
  2317. ! Debug: eq int = ax+0 to int amount_to_read = [S+$18-$12] (used reg = )
  2318. mov -$10[bp],ax
  2319. !BCC_EOS
  2320. ! 140 }
  2321. ! 141
  2322. ! 142 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], 4 , tmp_buffer, 0x7e0);
  2323. .51:
  2324. ! Debug: list int = const $7E0 (used reg = )
  2325. mov ax,#$7E0
  2326. push ax
  2327. ! Debug: list * char tmp_buffer = [S+$1A-$18] (used reg = )
  2328. push -$16[bp]
  2329. ! Debug: list int = const 4 (used reg = )
  2330. mov ax,*4
  2331. push ax
  2332. mov bx,4[bp]
  2333. ! Debug: ptradd int data_pointer_index = [S+$1E-$16] to [$36] long = bx+$44 (used reg = )
  2334. mov ax,-$14[bp]
  2335. shl ax,*1
  2336. shl ax,*1
  2337. add bx,ax
  2338. ! Debug: list long = [bx+$44] (used reg = )
  2339. push $46[bx]
  2340. push $44[bx]
  2341. ! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = )
  2342. call _disk_service_read_data_from_disk
  2343. add sp,*$A
  2344. !BCC_EOS
  2345. ! 143
  2346. ! 144 memcpy(data, data_segment, (tmp_buffer + remaining_offset), 0x7e0, amount_to_read);
  2347. ! Debug: list int amount_to_read = [S+$18-$12] (used reg = )
  2348. push -$10[bp]
  2349. ! Debug: list int = const $7E0 (used reg = )
  2350. mov ax,#$7E0
  2351. push ax
  2352. ! Debug: ptradd int remaining_offset = [S+$1C-$14] to * char tmp_buffer = [S+$1C-$18] (used reg = )
  2353. mov ax,-$12[bp]
  2354. add ax,-$16[bp]
  2355. ! Debug: list * char = ax+0 (used reg = )
  2356. push ax
  2357. ! Debug: list unsigned int data_segment = [S+$1E+$C] (used reg = )
  2358. push $E[bp]
  2359. ! Debug: list * char data = [S+$20+6] (used reg = )
  2360. push 8[bp]
  2361. ! Debug: func () void = memcpy+0 (used reg = )
  2362. call _memcpy
  2363. add sp,*$A
  2364. !BCC_EOS
  2365. ! 145 data_length -= amount_to_read;
  2366. ! Debug: subab int amount_to_read = [S+$18-$12] to int data_length = [S+$18-$E] (used reg = )
  2367. mov ax,-$C[bp]
  2368. sub ax,-$10[bp]
  2369. mov -$C[bp],ax
  2370. !BCC_EOS
  2371. ! 146 amount_read += amount_to_read;
  2372. ! Debug: addab int amount_to_read = [S+$18-$12] to int amount_read = [S+$18-$10] (used reg = )
  2373. mov ax,-$E[bp]
  2374. add ax,-$10[bp]
  2375. mov -$E[bp],ax
  2376. !BCC_EOS
  2377. ! 147 remaining_offset -= amount_to_read;
  2378. ! Debug: subab int amount_to_read = [S+$18-$12] to int remaining_offset = [S+$18-$14] (used reg = )
  2379. mov ax,-$12[bp]
  2380. sub ax,-$10[bp]
  2381. mov -$12[bp],ax
  2382. !BCC_EOS
  2383. ! 148
  2384. ! 149 data_pointer_index = data_
  2385. ! 149 pointer_index + 2;
  2386. ! Debug: add int = const 2 to int data_pointer_index = [S+$18-$16] (used reg = )
  2387. mov ax,-$14[bp]
  2388. ! Debug: eq int = ax+2 to int data_pointer_index = [S+$18-$16] (used reg = )
  2389. inc ax
  2390. inc ax
  2391. mov -$14[bp],ax
  2392. !BCC_EOS
  2393. ! 150
  2394. ! 151 }
  2395. inc sp
  2396. inc sp
  2397. ! 152 else
  2398. ! 153 {
  2399. jmp .52
  2400. .4D:
  2401. ! 154
  2402. ! 155 remaining_offset -= (4 * 512 );
  2403. ! Debug: subab int = const $800 to int remaining_offset = [S+$16-$14] (used reg = )
  2404. mov ax,-$12[bp]
  2405. add ax,#-$800
  2406. mov -$12[bp],ax
  2407. !BCC_EOS
  2408. ! 156 data_pointer_index++;
  2409. ! Debug: postinc int data_pointer_index = [S+$16-$16] (used reg = )
  2410. mov ax,-$14[bp]
  2411. inc ax
  2412. mov -$14[bp],ax
  2413. !BCC_EOS
  2414. ! 157 }
  2415. ! 158
  2416. ! 159 }
  2417. .52:
  2418. .4C:
  2419. ! 160 # 164
  2420. ! 164
  2421. ! 165 return amount_read;
  2422. .43:
  2423. ! Debug: gt int = const 0 to int data_length = [S+$16-$E] (used reg = )
  2424. mov ax,-$C[bp]
  2425. test ax,ax
  2426. bgt .44
  2427. .53:
  2428. .42:
  2429. mov ax,-$E[bp]
  2430. add sp,*$10
  2431. pop si
  2432. pop di
  2433. pop bp
  2434. ret
  2435. !BCC_EOS
  2436. ! 166
  2437. ! 167 }
  2438. ! 168
  2439. ! Register BX used in function lsfs_disk_read_data_from_file
  2440. .data
  2441. .bss
  2442. ! 0 errors detected