您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

1846 行
40 KiB

  1. ! 1
  2. ! 1 # 1 "implementation/lsfs.c"
  3. ! 1 # 4 "implementation/lsfs.h"
  4. ! 4 typedef struct lsfs_file lsfs_file;
  5. !BCC_EOS
  6. ! 5 # 1 "implementation/../std_singos/stdio.h"
  7. ! 1 void print(string);
  8. !BCC_EOS
  9. ! 2 void* dump_ax_return(input);
  10. !BCC_EOS
  11. ! 3
  12. ! 4 void print(string)
  13. ! 5 char* string;
  14. export _print
  15. _print:
  16. !BCC_EOS
  17. ! 6 {
  18. ! 7 #asm
  19. !BCC_ASM
  20. _print.string set 2
  21. push bp
  22. mov bp,sp
  23. mov si,4[bp]
  24. call 0x0000:0x7C47
  25. pop bp
  26. ! 13 endasm
  27. !BCC_ENDASM
  28. ! 14 }
  29. ret
  30. ! 15
  31. ! 16 void print_stack(argument)
  32. ! 17 {
  33. export _print_stack
  34. _print_stack:
  35. ! 18 #asm
  36. !BCC_ASM
  37. _print_stack.argument set 2
  38. push bp
  39. mov bp,sp
  40. push ds
  41. push ax
  42. mov ax, ss
  43. mov ds, ax
  44. mov si,4[bp]
  45. call 0x0000:0x7C47
  46. pop ax
  47. pop ds
  48. pop bp
  49. ! 32 endasm
  50. !BCC_ENDASM
  51. ! 33 }
  52. ret
  53. ! 34
  54. ! 35 void* dump_ax_return(input)
  55. ! 36 void* input;
  56. export _dump_ax_return
  57. _dump_ax_return:
  58. !BCC_EOS
  59. ! 37 {
  60. ! 38 return input;
  61. push bp
  62. mov bp,sp
  63. push di
  64. push si
  65. mov ax,4[bp]
  66. pop si
  67. pop di
  68. pop bp
  69. ret
  70. !BCC_EOS
  71. ! 39 }
  72. ! 40
  73. ! 41 void dump_ax(input)
  74. ! 42 void* input;
  75. export _dump_ax
  76. _dump_ax:
  77. !BCC_EOS
  78. ! 43 {
  79. ! 44 dump_ax_return(input)
  80. push bp
  81. mov bp,sp
  82. push di
  83. push si
  84. ! 45 #asm
  85. ! Debug: list * void input = [S+6+2] (used reg = )
  86. push 4[bp]
  87. ! Debug: func () * void = dump_ax_return+0 (used reg = )
  88. call _dump_ax_return
  89. inc sp
  90. inc sp
  91. !BCC_EOS
  92. !BCC_ASM
  93. _dump_ax.input set 8
  94. .dump_ax.input set 4
  95. push bp
  96. mov bp,sp
  97. call 0x000:0x7C2A
  98. pop bp
  99. ! 50 endasm
  100. !BCC_ENDASM
  101. !BCC_EOS
  102. ! 51 }
  103. pop si
  104. pop di
  105. pop bp
  106. ret
  107. ! 52
  108. ! 53 void print_newline()
  109. ! 54 {
  110. export _print_newline
  111. _print_newline:
  112. ! 55 #asm
  113. !BCC_ASM
  114. printCRLF:
  115. mov ah, #0xE
  116. mov al, #13
  117. int #0x10
  118. mov al, #10
  119. int #0x10
  120. ret
  121. ! 63 endasm
  122. !BCC_ENDASM
  123. ! 64 }
  124. ret
  125. ! 65 # 1 "implementation/../std_singos/stdlib.h"
  126. ! 1 unsigned int global_heap_start = 0;
  127. .data
  128. export _global_heap_start
  129. _global_heap_start:
  130. .word 0
  131. !BCC_EOS
  132. ! 2 unsigned int global_heap_end = 0;
  133. export _global_heap_end
  134. _global_heap_end:
  135. .word 0
  136. !BCC_EOS
  137. ! 3 unsigned int global_heap_next = 0;
  138. export _global_heap_next
  139. _global_heap_next:
  140. .word 0
  141. !BCC_EOS
  142. ! 4
  143. ! 5 void* malloc(num_bytes);
  144. !BCC_EOS
  145. ! 6 void* calloc(number_elements, size);
  146. !BCC_EOS
  147. ! 7 int set_heap_settings(param_start, param_end);
  148. !BCC_EOS
  149. ! 8 unsigned int get_heap_next();
  150. !BCC_EOS
  151. ! 9
  152. ! 10 void* malloc(num_bytes)
  153. ! 11 int num_bytes;
  154. .text
  155. export _malloc
  156. _malloc:
  157. !BCC_EOS
  158. ! 12 {
  159. ! 13 unsigned int allocated_pointer = global_heap_next;
  160. push bp
  161. mov bp,sp
  162. push di
  163. push si
  164. dec sp
  165. dec sp
  166. ! Debug: eq unsigned int = [global_heap_next+0] to unsigned int allocated_pointer = [S+8-8] (used reg = )
  167. mov ax,[_global_heap_next]
  168. mov -6[bp],ax
  169. !BCC_EOS
  170. ! 14 global_heap_next = global_heap_next + num_bytes;
  171. ! Debug: add int num_bytes = [S+8+2] to unsigned int = [global_heap_next+0] (used reg = )
  172. mov ax,[_global_heap_next]
  173. add ax,4[bp]
  174. ! Debug: eq unsigned int = ax+0 to unsigned int = [global_heap_next+0] (used reg = )
  175. mov [_global_heap_next],ax
  176. !BCC_EOS
  177. ! 15 if (global_heap_next > global_heap_end)
  178. ! Debug: gt unsigned int = [global_heap_end+0] to unsigned int = [global_heap_next+0] (used reg = )
  179. mov ax,[_global_heap_next]
  180. cmp ax,[_global_heap_end]
  181. jbe .1
  182. .2:
  183. ! 16 {
  184. ! 17 return 0;
  185. xor ax,ax
  186. inc sp
  187. inc sp
  188. pop si
  189. pop di
  190. pop bp
  191. ret
  192. !BCC_EOS
  193. ! 18 }
  194. ! 19
  195. ! 20 return allocated_pointer;
  196. .1:
  197. mov ax,-6[bp]
  198. inc sp
  199. inc sp
  200. pop si
  201. pop di
  202. pop bp
  203. ret
  204. !BCC_EOS
  205. ! 21 }
  206. ! 22
  207. ! 23 void* calloc(number_elements, size)
  208. ! 24 unsigned int number_elements;
  209. export _calloc
  210. _calloc:
  211. !BCC_EOS
  212. ! 25 unsigned int size;
  213. !BCC_EOS
  214. ! 26 {
  215. ! 27 int i;
  216. !BCC_EOS
  217. ! 28 char* temp_pointer;
  218. !BCC_EOS
  219. ! 29 unsigned int num_bytes = number_elements * size;
  220. push bp
  221. mov bp,sp
  222. push di
  223. push si
  224. add sp,*-6
  225. ! Debug: mul unsigned int size = [S+$C+4] to unsigned int number_elements = [S+$C+2] (used reg = )
  226. mov ax,4[bp]
  227. mov cx,6[bp]
  228. imul cx
  229. ! Debug: eq unsigned int = ax+0 to unsigned int num_bytes = [S+$C-$C] (used reg = )
  230. mov -$A[bp],ax
  231. !BCC_EOS
  232. ! 30 void* allocated_pointer = global_heap_next;
  233. dec sp
  234. dec sp
  235. ! Debug: eq unsigned int = [global_heap_next+0] to * void allocated_pointer = [S+$E-$E] (used reg = )
  236. mov bx,[_global_heap_next]
  237. mov -$C[bp],bx
  238. !BCC_EOS
  239. ! 31 global_heap_next = global_heap_next + num_bytes;
  240. ! Debug: add unsigned int num_bytes = [S+$E-$C] to unsigned int = [global_heap_next+0] (used reg = )
  241. mov ax,[_global_heap_next]
  242. add ax,-$A[bp]
  243. ! Debug: eq unsigned int = ax+0 to unsigned int = [global_heap_next+0] (used reg = )
  244. mov [_global_heap_next],ax
  245. !BCC_EOS
  246. ! 32 if (global_heap_next > global_heap_end)
  247. ! Debug: gt unsigned int = [global_heap_end+0] to unsigned int = [global_heap_next+0] (used reg = )
  248. mov ax,[_global_heap_next]
  249. cmp ax,[_global_heap_end]
  250. jbe .3
  251. .4:
  252. ! 33 {
  253. ! 34 return 0;
  254. xor ax,ax
  255. add sp,*8
  256. pop si
  257. pop di
  258. pop bp
  259. ret
  260. !BCC_EOS
  261. ! 35 }
  262. ! 36
  263. ! 37
  264. ! 38 temp_pointer = allocated_pointer;
  265. .3:
  266. ! Debug: eq * void allocated_pointer = [S+$E-$E] to * char temp_pointer = [S+$E-$A] (used reg = )
  267. mov bx,-$C[bp]
  268. mov -8[bp],bx
  269. !BCC_EOS
  270. ! 39 for (i = 0; i < num_bytes; ++i)
  271. ! Debug: eq int = const 0 to int i = [S+$E-8] (used reg = )
  272. xor ax,ax
  273. mov -6[bp],ax
  274. !BCC_EOS
  275. !BCC_EOS
  276. ! 40 {
  277. jmp .7
  278. .8:
  279. ! 41 *temp_pointer = 0;
  280. mov bx,-8[bp]
  281. ! Debug: eq int = const 0 to char = [bx+0] (used reg = )
  282. xor al,al
  283. mov [bx],al
  284. !BCC_EOS
  285. ! 42 temp_pointer++;
  286. ! Debug: postinc * char temp_pointer = [S+$E-$A] (used reg = )
  287. mov bx,-8[bp]
  288. inc bx
  289. mov -8[bp],bx
  290. !BCC_EOS
  291. ! 43 }
  292. ! 44
  293. ! 45 return allocated_pointer;
  294. .6:
  295. ! Debug: preinc int i = [S+$E-8] (used reg = )
  296. mov ax,-6[bp]
  297. inc ax
  298. mov -6[bp],ax
  299. .7:
  300. ! Debug: lt unsigned int num_bytes = [S+$E-$C] to int i = [S+$E-8] (used reg = )
  301. mov ax,-6[bp]
  302. cmp ax,-$A[bp]
  303. jb .8
  304. .9:
  305. .5:
  306. mov ax,-$C[bp]
  307. add sp,*8
  308. pop si
  309. pop di
  310. pop bp
  311. ret
  312. !BCC_EOS
  313. ! 46 }
  314. ! 47
  315. ! 48 int set_heap_settings(param_start, param_end)
  316. ! Register BX used in function calloc
  317. ! 49 unsigned int param_start;
  318. export _set_heap_settings
  319. _set_heap_settings:
  320. !BCC_EOS
  321. ! 50 unsigned int param_end;
  322. !BCC_EOS
  323. ! 51 {
  324. ! 52 global_heap_start = param_start;
  325. push bp
  326. mov bp,sp
  327. push di
  328. push si
  329. ! Debug: eq unsigned int param_start = [S+6+2] to unsigned int = [global_heap_start+0] (used reg = )
  330. mov ax,4[bp]
  331. mov [_global_heap_start],ax
  332. !BCC_EOS
  333. ! 53 global_heap_next = param_start;
  334. ! Debug: eq unsigned int param_start = [S+6+2] to unsigned int = [global_heap_next+0] (used reg = )
  335. mov ax,4[bp]
  336. mov [_global_heap_next],ax
  337. !BCC_EOS
  338. ! 54 global_heap_end = param_end;
  339. ! Debug: eq unsigned int param_end = [S+6+4] to unsigned int = [global_heap_end+0] (used reg = )
  340. mov ax,6[bp]
  341. mov [_global_heap_end],ax
  342. !BCC_EOS
  343. ! 55 re
  344. ! 55 turn 0;
  345. xor ax,ax
  346. pop si
  347. pop di
  348. pop bp
  349. ret
  350. !BCC_EOS
  351. ! 56 }
  352. ! 57
  353. ! 58 unsigned int get_heap_next()
  354. ! 59 {
  355. export _get_heap_next
  356. _get_heap_next:
  357. ! 60 return global_heap_next;
  358. push bp
  359. mov bp,sp
  360. push di
  361. push si
  362. mov ax,[_global_heap_next]
  363. pop si
  364. pop di
  365. pop bp
  366. ret
  367. !BCC_EOS
  368. ! 61 # 16 "implementation/../main.h"
  369. ! 16 }
  370. ! 17 # 2 "implementation/../std_singos/string.h"
  371. ! 2 typedef struct Length_String {
  372. ! 3 short dynamic;
  373. !BCC_EOS
  374. ! 4 unsigned int length;
  375. !BCC_EOS
  376. ! 5 char *chars;
  377. !BCC_EOS
  378. ! 6 } Length_String;
  379. !BCC_EOS
  380. ! 7
  381. ! 8 typedef struct String_Array {
  382. ! 9 unsigned int length;
  383. !BCC_EOS
  384. ! 10 Length_String **strings;
  385. !BCC_EOS
  386. ! 11 } String_Array;
  387. !BCC_EOS
  388. ! 12
  389. ! 13 void strcpy (destination, destination_segment, source, source_segment );
  390. !BCC_EOS
  391. ! 14 int strlen (source, source_segment);
  392. !BCC_EOS
  393. ! 15 void memcpy (destination, destination_segment, source, source_segment, num_bytes );
  394. !BCC_EOS
  395. ! 16
  396. ! 17
  397. ! 18 String_Array *string_split_c(string, delim, keep_delim);
  398. !BCC_EOS
  399. ! 19 Length_String *make_length_string(length, chars);
  400. !BCC_EOS
  401. ! 20 Length_String *make_length_string_c(cstring);
  402. !BCC_EOS
  403. ! 21 String_Array *length_string_split(string, delim, keep_delim);
  404. !BCC_EOS
  405. ! 22 String_Array *create_length_string_array(array_size);
  406. !BCC_EOS
  407. ! 23 Length_String *create_length_string(length, chars);
  408. !BCC_EOS
  409. ! 24
  410. ! 25
  411. ! 26
  412. ! 27 int strlen (source, source_segment)
  413. ! 28 {
  414. export _strlen
  415. _strlen:
  416. ! 29 #asm
  417. !BCC_ASM
  418. _strlen.source set 2
  419. _strlen.source_segment set 4
  420. push bp
  421. mov bp,sp
  422. push ds
  423. push bx
  424. mov ax, 6[bp];
  425. mov ds, ax
  426. mov bx, 4[bp];
  427. label_strlen:
  428. mov cx, #0x0 ; Set counte to zero
  429. .label_strlen_loop:
  430. mov BYTE al, [bx]
  431. cmp al, #0x0
  432. je .label_strlen_done
  433. inc cx ; Count 1
  434. inc bx ; Look at next char
  435. jmp .label_strlen_loop
  436. .label_strlen_done:
  437. mov ax, cx
  438. pop bx
  439. pop ds
  440. pop bp
  441. ! 57 endasm
  442. !BCC_ENDASM
  443. ! 58 }
  444. ret
  445. ! 59
  446. ! 60 void strcpy (destination, destination_segment, source, source_segment )
  447. ! 61 char *destination;
  448. export _strcpy
  449. _strcpy:
  450. !BCC_EOS
  451. ! 62 int destination_segment;
  452. !BCC_EOS
  453. ! 63 char *source;
  454. !BCC_EOS
  455. ! 64 int source_segment;
  456. !BCC_EOS
  457. ! 65 {
  458. ! 66 #asm
  459. !BCC_ASM
  460. _strcpy.source set 6
  461. _strcpy.destination set 2
  462. _strcpy.source_segment set 8
  463. _strcpy.destination_segment set 4
  464. ; copy two strings
  465. ; IN si: the first (zero terminated) string
  466. ; IN di: the second (zero terminated) string
  467. ; OUT SF and ZF (same semantics as cmp)
  468. ! 72 76
  469. push bp
  470. mov bp,sp
  471. label_strcpy:
  472. push ax
  473. push bx
  474. push di
  475. push es
  476. push si
  477. push ds
  478. mov ax, 4[bp]; ;
  479. mov di, ax
  480. mov ax, 6[bp]; ;
  481. mov es, ax
  482. mov ax, 8[bp]; ;
  483. mov si, ax
  484. mov ax, 10[bp]; ;
  485. mov ds, ax
  486. mov cx, 0x050 ;TODO(Jrn) Hardcded number of bytes to copy
  487. .label_strcpy_loop:
  488. movsb
  489. cmp cx, 0x0
  490. je .label_strcpy_end
  491. dec cx
  492. jmp .label_strcpy_loop
  493. .label_strcpy_end:
  494. pop ds
  495. pop si
  496. pop es
  497. pop di
  498. pop bx
  499. pop ax
  500. pop bp
  501. ! 110 endasm
  502. !BCC_ENDASM
  503. ! 111 }
  504. ret
  505. ! 112
  506. ! 113 void memcpy (destination, destination_segment, source, source_segment, num_bytes)
  507. ! 114 void *destination;
  508. export _memcpy
  509. _memcpy:
  510. !BCC_EOS
  511. ! 115 int destination_segment;
  512. !BCC_EOS
  513. ! 116 void *source;
  514. !BCC_EOS
  515. ! 117 int source_segment;
  516. !BCC_EOS
  517. ! 118 int num_bytes;
  518. !BCC_EOS
  519. ! 119 {
  520. ! 120 #asm
  521. !BCC_ASM
  522. _memcpy.source set 6
  523. _memcpy.destination set 2
  524. _memcpy.num_bytes set $A
  525. _memcpy.source_segment set 8
  526. _memcpy.destination_segment set 4
  527. ; copy two strings
  528. ; IN si: the first (zero terminated) string
  529. ; IN di: the second (zero terminated) string
  530. ; OUT SF and ZF (same semantics as cmp)
  531. ! 126 131
  532. push bp
  533. mov bp,sp
  534. label_memcpy:
  535. push ax
  536. push bx
  537. push di
  538. push es
  539. push si
  540. push ds
  541. mov ax, 4[bp]; ;
  542. mov di, ax
  543. mov ax, 6[bp]; ;
  544. mov es, ax
  545. mov ax, 8[bp]; ;
  546. mov si, ax
  547. mov ax, 10[bp]; ;
  548. mov ds, ax
  549. mov cx, 12[bp];
  550. .label_memcpy_loop:
  551. movsb
  552. cmp cx, 0x0
  553. je .label_memcpy_end
  554. dec cx
  555. jmp .label_memcpy_loop
  556. .label_memcpy_end:
  557. pop ds
  558. pop si
  559. pop es
  560. pop di
  561. pop bx
  562. pop ax
  563. pop bp
  564. ! 165 endasm
  565. !BCC_ENDASM
  566. ! 166 }
  567. ret
  568. ! 167
  569. ! 168 String_Array *string_split_c(string, delim, keep_delim)
  570. ! 169 char *string;
  571. export _string_split_c
  572. _string_split_c:
  573. !BCC_EOS
  574. ! 170 char delim;
  575. !BCC_EOS
  576. ! 171 short keep_delim;
  577. !BCC_EOS
  578. ! 172 {
  579. ! 173 return length_string_split(make_length_string_c(string), delim, keep_delim);
  580. push bp
  581. mov bp,sp
  582. push di
  583. push si
  584. ! Debug: list short keep_delim = [S+6+6] (used reg = )
  585. push 8[bp]
  586. ! Debug: list char delim = [S+8+4] (used reg = )
  587. mov al,6[bp]
  588. xor ah,ah
  589. push ax
  590. ! Debug: list * char string = [S+$A+2] (used reg = )
  591. push 4[bp]
  592. ! Debug: func () * struct Length_String = make_length_string_c+0 (used reg = )
  593. call _make_length_string_c
  594. inc sp
  595. inc sp
  596. ! Debug: list * struct Length_String = ax+0 (used reg = )
  597. push ax
  598. ! Debug: func () * struct String_Array = length_string_split+0 (used reg = )
  599. call _length_string_split
  600. add sp,*6
  601. ! Debug: cast * struct String_Array = const 0 to * struct String_Array = ax+0 (used reg = )
  602. pop si
  603. pop di
  604. pop bp
  605. ret
  606. !BCC_EOS
  607. ! 174 }
  608. ! 175
  609. ! 176 Length_String *make_length_string_c(cstring)
  610. ! 177 char *cstring;
  611. export _make_length_string_c
  612. _make_length_string_c:
  613. !BCC_EOS
  614. ! 178 {
  615. ! 179 return make_length_string(strlen(cstring, 0x7e0), cstring);
  616. push bp
  617. mov bp,sp
  618. push di
  619. push si
  620. ! Debug: list * char cstring = [S+6+2] (used reg = )
  621. push 4[bp]
  622. ! Debug: list int = const $7E0 (used reg = )
  623. mov ax,#$7E0
  624. push ax
  625. ! Debug: list * char cstring = [S+$A+2] (used reg = )
  626. push 4[bp]
  627. ! Debug: func () int = strlen+0 (used reg = )
  628. call _strlen
  629. add sp,*4
  630. ! Debug: list int = ax+0 (used reg = )
  631. push ax
  632. ! Debug: func () * struct Length_String = make_length_string+0 (used reg = )
  633. call _make_length_string
  634. add sp,*4
  635. ! Debug: cast * struct Length_String = const 0 to * struct Length_String = ax+0 (used reg = )
  636. pop si
  637. pop di
  638. pop bp
  639. ret
  640. !BCC_EOS
  641. ! 180 }
  642. ! 181
  643. ! 182 Length_String *make_length_string(length, chars)
  644. ! 183 unsigned int length;
  645. export _make_length_string
  646. _make_length_string:
  647. !BCC_EOS
  648. ! 184 char *chars;
  649. !BCC_EOS
  650. ! 185 {
  651. ! 186
  652. ! 187 Length_String *legth_string = malloc(sizeof(Length_String));
  653. push bp
  654. mov bp,sp
  655. push di
  656. push si
  657. dec sp
  658. dec sp
  659. ! Debug: list int = const 6 (used reg = )
  660. mov ax,*6
  661. push ax
  662. ! Debug: func () * void = malloc+0 (used reg = )
  663. call _malloc
  664. inc sp
  665. inc sp
  666. ! Debug: eq * void = ax+0 to * struct Length_String legth_string = [S+8-8] (used reg = )
  667. mov -6[bp],ax
  668. !BCC_EOS
  669. ! 188 char *copy = malloc(length + 1);
  670. dec sp
  671. dec sp
  672. ! Debug: add int = const 1 to unsigned int length = [S+$A+2] (used reg = )
  673. mov ax,4[bp]
  674. ! Debug: list unsigned int = ax+1 (used reg = )
  675. inc ax
  676. push ax
  677. ! Debug: func () * void = malloc+0 (used reg = )
  678. call _malloc
  679. inc sp
  680. inc sp
  681. ! Debug: eq * void = ax+0 to * char copy = [S+$A-$A] (used reg = )
  682. mov -8[bp],ax
  683. !BCC_EOS
  684. ! 189 memcpy(copy, 0x7e0, chars, 0x7e0, length);
  685. ! Debug: list unsigned int length = [S+$A+2] (used reg = )
  686. push 4[bp]
  687. ! Debug: list int = const $7E0 (used reg = )
  688. mov ax,#$7E0
  689. push ax
  690. ! Debug: list * char chars = [S+$E+4] (used reg = )
  691. push 6[bp]
  692. ! Debug: list int = const $7E0 (used reg = )
  693. mov ax,#$7E0
  694. push ax
  695. ! Debug: list * char copy = [S+$12-$A] (used reg = )
  696. push -8[bp]
  697. ! Debug: func () void = memcpy+0 (used reg = )
  698. call _memcpy
  699. add sp,*$A
  700. !BCC_EOS
  701. ! 190 copy[length] = '\0';
  702. ! Debug: ptradd unsigned int length = [S+$A+2] to * char copy = [S+$A-$A] (used reg = )
  703. mov ax,4[bp]
  704. add ax,-8[bp]
  705. mov bx,ax
  706. ! Debug: eq int = const 0 to char = [bx+0] (used reg = )
  707. xor al,al
  708. mov [bx],al
  709. !BCC_EOS
  710. ! 191
  711. ! 192 legth_string->dynamic = 0;
  712. mov bx,-6[bp]
  713. ! Debug: eq int = const 0 to short = [bx+0] (used reg = )
  714. xor ax,ax
  715. mov [bx],ax
  716. !BCC_EOS
  717. ! 193 legth_string->length = length;
  718. mov bx,-6[bp]
  719. ! Debug: eq unsigned int length = [S+$A+2] to unsigned int = [bx+2] (used reg = )
  720. mov ax,4[bp]
  721. mov 2[bx],ax
  722. !BCC_EOS
  723. ! 194 legth_string->chars = (char *)chars;
  724. mov bx,-6[bp]
  725. ! Debug: eq * char chars = [S+$A+4] to * char = [bx+4] (used reg = )
  726. mov si,6[bp]
  727. mov 4[bx],si
  728. !BCC_EOS
  729. ! 195
  730. ! 196 return legth_string
  731. ! 196 ;
  732. mov ax,-6[bp]
  733. add sp,*4
  734. pop si
  735. pop di
  736. pop bp
  737. ret
  738. !BCC_EOS
  739. ! 197 }
  740. ! 198
  741. ! 199 String_Array *length_string_split(string, delim, keep_delim)
  742. ! Register BX SI used in function make_length_string
  743. ! 200 Length_String *string;
  744. export _length_string_split
  745. _length_string_split:
  746. !BCC_EOS
  747. ! 201 char delim;
  748. !BCC_EOS
  749. ! 202 short keep_delim;
  750. !BCC_EOS
  751. ! 203 {
  752. ! 204 unsigned int i;
  753. !BCC_EOS
  754. ! 205 unsigned int last;
  755. !BCC_EOS
  756. ! 206
  757. ! 207 unsigned int count = 0;
  758. push bp
  759. mov bp,sp
  760. push di
  761. push si
  762. add sp,*-6
  763. ! Debug: eq int = const 0 to unsigned int count = [S+$C-$C] (used reg = )
  764. xor ax,ax
  765. mov -$A[bp],ax
  766. !BCC_EOS
  767. ! 208 unsigned int insert_index = 0;
  768. dec sp
  769. dec sp
  770. ! Debug: eq int = const 0 to unsigned int insert_index = [S+$E-$E] (used reg = )
  771. xor ax,ax
  772. mov -$C[bp],ax
  773. !BCC_EOS
  774. ! 209 String_Array *result;
  775. !BCC_EOS
  776. ! 210 int k;
  777. !BCC_EOS
  778. ! 211
  779. ! 212 i = 0;
  780. add sp,*-4
  781. ! Debug: eq int = const 0 to unsigned int i = [S+$12-8] (used reg = )
  782. xor ax,ax
  783. mov -6[bp],ax
  784. !BCC_EOS
  785. ! 213 last = 0;
  786. ! Debug: eq int = const 0 to unsigned int last = [S+$12-$A] (used reg = )
  787. xor ax,ax
  788. mov -8[bp],ax
  789. !BCC_EOS
  790. ! 214 while(i < string->length) {
  791. jmp .B
  792. .C:
  793. ! 215 if (string->chars[i] == delim) {
  794. mov bx,4[bp]
  795. ! Debug: ptradd unsigned int i = [S+$12-8] to * char = [bx+4] (used reg = )
  796. mov ax,-6[bp]
  797. add ax,4[bx]
  798. mov bx,ax
  799. ! Debug: logeq char delim = [S+$12+4] to char = [bx+0] (used reg = )
  800. mov al,[bx]
  801. cmp al,6[bp]
  802. jne .D
  803. .E:
  804. ! 216 if (i > last+1) {
  805. ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = )
  806. mov ax,-8[bp]
  807. ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = )
  808. inc ax
  809. cmp ax,-6[bp]
  810. jae .F
  811. .10:
  812. ! 217 ++count;
  813. ! Debug: preinc unsigned int count = [S+$12-$C] (used reg = )
  814. mov ax,-$A[bp]
  815. inc ax
  816. mov -$A[bp],ax
  817. !BCC_EOS
  818. ! 218 }
  819. ! 219 last = i;
  820. .F:
  821. ! Debug: eq unsigned int i = [S+$12-8] to unsigned int last = [S+$12-$A] (used reg = )
  822. mov ax,-6[bp]
  823. mov -8[bp],ax
  824. !BCC_EOS
  825. ! 220 }
  826. ! 221 ++i;
  827. .D:
  828. ! Debug: preinc unsigned int i = [S+$12-8] (used reg = )
  829. mov ax,-6[bp]
  830. inc ax
  831. mov -6[bp],ax
  832. !BCC_EOS
  833. ! 222 }
  834. ! 223 if (i > last+1) {
  835. .B:
  836. mov bx,4[bp]
  837. ! Debug: lt unsigned int = [bx+2] to unsigned int i = [S+$12-8] (used reg = )
  838. mov ax,-6[bp]
  839. cmp ax,2[bx]
  840. jb .C
  841. .11:
  842. .A:
  843. ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = )
  844. mov ax,-8[bp]
  845. ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = )
  846. inc ax
  847. cmp ax,-6[bp]
  848. jae .12
  849. .13:
  850. ! 224 ++count;
  851. ! Debug: preinc unsigned int count = [S+$12-$C] (used reg = )
  852. mov ax,-$A[bp]
  853. inc ax
  854. mov -$A[bp],ax
  855. !BCC_EOS
  856. ! 225 }
  857. ! 226
  858. ! 227 result = create_length_string_array(count);
  859. .12:
  860. ! Debug: list unsigned int count = [S+$12-$C] (used reg = )
  861. push -$A[bp]
  862. ! Debug: func () * struct String_Array = create_length_string_array+0 (used reg = )
  863. call _create_length_string_array
  864. inc sp
  865. inc sp
  866. ! Debug: eq * struct String_Array = ax+0 to * struct String_Array result = [S+$12-$10] (used reg = )
  867. mov -$E[bp],ax
  868. !BCC_EOS
  869. ! 228
  870. ! 229 if (keep_delim)
  871. mov ax,8[bp]
  872. test ax,ax
  873. je .14
  874. .15:
  875. ! 230 {
  876. ! 231 k = 0;
  877. ! Debug: eq int = const 0 to int k = [S+$12-$12] (used reg = )
  878. xor ax,ax
  879. mov -$10[bp],ax
  880. !BCC_EOS
  881. ! 232 }
  882. ! 233 else
  883. ! 234 {
  884. jmp .16
  885. .14:
  886. ! 235 k = 1;
  887. ! Debug: eq int = const 1 to int k = [S+$12-$12] (used reg = )
  888. mov ax,*1
  889. mov -$10[bp],ax
  890. !BCC_EOS
  891. ! 236 }
  892. ! 237
  893. ! 238 i = 0;
  894. .16:
  895. ! Debug: eq int = const 0 to unsigned int i = [S+$12-8] (used reg = )
  896. xor ax,ax
  897. mov -6[bp],ax
  898. !BCC_EOS
  899. ! 239 last = 0;
  900. ! Debug: eq int = const 0 to unsigned int last = [S+$12-$A] (used reg = )
  901. xor ax,ax
  902. mov -8[bp],ax
  903. !BCC_EOS
  904. ! 240 while(i < string->length) {
  905. jmp .18
  906. .19:
  907. ! 241 if (string->chars[i] == delim) {
  908. mov bx,4[bp]
  909. ! Debug: ptradd unsigned int i = [S+$12-8] to * char = [bx+4] (used reg = )
  910. mov ax,-6[bp]
  911. add ax,4[bx]
  912. mov bx,ax
  913. ! Debug: logeq char delim = [S+$12+4] to char = [bx+0] (used reg = )
  914. mov al,[bx]
  915. cmp al,6[bp]
  916. jne .1A
  917. .1B:
  918. ! 242 if (i > last+1) {
  919. ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = )
  920. mov ax,-8[bp]
  921. ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = )
  922. inc ax
  923. cmp ax,-6[bp]
  924. jae .1C
  925. .1D:
  926. ! 243 result->strings[insert_index++] = create_length_string(i-(last+k), string->chars+(last+k));
  927. ! Debug: add int k = [S+$12-$12] to unsigned int last = [S+$12-$A] (used reg = )
  928. mov ax,-8[bp]
  929. add ax,-$10[bp]
  930. mov bx,4[bp]
  931. ! Debug: ptradd unsigned int = ax+0 to * char = [bx+4] (used reg = )
  932. add ax,4[bx]
  933. ! Debug: list * char = ax+0 (used reg = )
  934. push ax
  935. ! Debug: add int k = [S+$14-$12] to unsigned int last = [S+$14-$A] (used reg = )
  936. mov ax,-8[bp]
  937. add ax,-$10[bp]
  938. ! Debug: sub unsigned int = ax+0 to unsigned int i = [S+$14-8] (used reg = )
  939. push ax
  940. mov ax,-6[bp]
  941. sub ax,-$14[bp]
  942. inc sp
  943. inc sp
  944. ! Debug: list unsigned int = ax+0 (used reg = )
  945. push ax
  946. ! Debug: func () * struct Length_String = create_length_string+0 (used reg = )
  947. call _create_length_string
  948. add sp,*4
  949. push ax
  950. ! Debug: postinc unsigned int insert_index = [S+$14-$E] (used reg = )
  951. mov ax,-$C[bp]
  952. inc ax
  953. mov -$C[bp],ax
  954. mov bx,-$E[bp]
  955. ! Debug: ptradd unsigned int = ax-1 to * * struct Length_String = [bx+2] (used reg = )
  956. dec ax
  957. shl ax,*1
  958. add ax,2[bx]
  959. mov bx,ax
  960. ! Debug: eq * struct Length_String (temp) = [S+$14-$14] to * struct Length_String = [bx+0] (used reg = )
  961. mov si,-$12[bp]
  962. mov [bx],si
  963. inc sp
  964. inc sp
  965. !BCC_EOS
  966. ! 244 }
  967. ! 245 last = i;
  968. .1C:
  969. ! Debug: eq unsigned int i = [S+$12-8] to unsigned int last = [S+$12-$A] (used reg = )
  970. mov ax,-6[bp]
  971. mov -8[bp],ax
  972. !BCC_EOS
  973. ! 246 }
  974. ! 247 ++i;
  975. .1A:
  976. ! Debug: preinc unsigned int i = [S+$12-8] (used reg = )
  977. mov ax,-6[bp]
  978. inc ax
  979. mov -6[bp],ax
  980. !BCC_EOS
  981. ! 248 }
  982. ! 249 if (i > last+1) {
  983. .18:
  984. mov bx,4[bp]
  985. ! Debug: lt unsigned int = [bx+2] to unsigned int i = [S+$12-8] (used reg = )
  986. mov ax,-6[bp]
  987. cmp ax,2[bx]
  988. jb .19
  989. .1E:
  990. .17:
  991. ! Debug: add int = const 1 to unsigned int last = [S+$12-$A] (used reg = )
  992. mov ax,-8[bp]
  993. ! Debug: gt unsigned int = ax+1 to unsigned int i = [S+$12-8] (used reg = )
  994. inc ax
  995. cmp ax,-6[bp]
  996. jae .1F
  997. .20:
  998. ! 250 result->strings[insert_index++] = create_length_string(i-(last+k), ((string->chars)+(last+k)));
  999. ! Debug: add int k = [S+$12-$12] to unsigned int last = [S+$12-$A] (used reg = )
  1000. mov ax,-8[bp]
  1001. add ax,-$10[bp]
  1002. mov bx,4[bp]
  1003. ! Debug: ptradd unsigned int = ax+0 to * char = [bx+4] (used reg = )
  1004. add ax,4[bx]
  1005. ! Debug: list * char = ax+0 (used reg = )
  1006. push ax
  1007. ! Debug: add int k = [S+$14-$12] to unsigned int last = [S+$14-$A] (used reg = )
  1008. mov ax,-8[bp]
  1009. add ax,-$10[bp]
  1010. ! Debug: sub unsigned int = ax+0 to unsigned int i = [S+$14-8] (used reg = )
  1011. push ax
  1012. mov ax,-6[bp]
  1013. sub ax,-$14[bp]
  1014. inc sp
  1015. inc sp
  1016. ! Debug: list unsigned int = ax+0 (used reg = )
  1017. push ax
  1018. ! Debug: func () * struct Length_String = create_length_string+0 (used reg = )
  1019. call _create_length_string
  1020. add sp,*4
  1021. push ax
  1022. ! Debug: postinc unsigned int insert_index = [S+$14-$E] (used reg = )
  1023. mov ax,-$C[bp]
  1024. inc ax
  1025. mov -$C[bp],ax
  1026. mov bx,-$E[bp]
  1027. ! Debug: ptradd unsigned int = ax-1 to * * struct Length_String = [bx+2] (used reg = )
  1028. dec ax
  1029. shl ax,*1
  1030. add ax,2[bx]
  1031. mov bx,ax
  1032. ! Debug: eq * struct Length_String (temp) = [S+$14-$14] to * struct Length_String = [bx+0] (used reg = )
  1033. mov si,-$12[bp]
  1034. mov [bx],si
  1035. inc sp
  1036. inc sp
  1037. !BCC_EOS
  1038. ! 251 }
  1039. ! 252
  1040. ! 253 return result;
  1041. .1F:
  1042. mov ax,-$E[bp]
  1043. add sp,*$C
  1044. pop si
  1045. pop di
  1046. pop bp
  1047. ret
  1048. !BCC_EOS
  1049. ! 254
  1050. ! 255 }
  1051. ! 256
  1052. ! 257 String_Array *create_length_string_array(array_size)
  1053. ! Register BX SI used in function length_string_split
  1054. ! 258 int array_size;
  1055. export _create_length_string_array
  1056. _create_length_string_array:
  1057. !BCC_EOS
  1058. ! 259 {
  1059. ! 260 String_Array *result = malloc(sizeof(String_Array));
  1060. push bp
  1061. mov bp,sp
  1062. push di
  1063. push si
  1064. dec sp
  1065. dec sp
  1066. ! Debug: list int = const 4 (used reg = )
  1067. mov ax,*4
  1068. push ax
  1069. ! Debug: func () * void = malloc+0 (used reg = )
  1070. call _malloc
  1071. inc sp
  1072. inc sp
  1073. ! Debug: eq * void = ax+0 to * struct String_Array result = [S+8-8] (used reg = )
  1074. mov -6[bp],ax
  1075. !BCC_EOS
  1076. ! 261 result->length = array_size;
  1077. mov bx,-6[bp]
  1078. ! Debug: eq int array_size = [S+8+2] to unsigned int = [bx+0] (used reg = )
  1079. mov ax,4[bp]
  1080. mov [bx],ax
  1081. !BCC_EOS
  1082. ! 262 result->strings = malloc(array_size * sizeof(Length_String));
  1083. ! Debug: mul int = const 6 to int array_size = [S+8+2] (used reg = )
  1084. mov ax,4[bp]
  1085. mov dx,ax
  1086. shl ax,*1
  1087. add ax,dx
  1088. shl ax,*1
  1089. ! Debug: list int = ax+0 (used reg = )
  1090. push ax
  1091. ! Debug: func () * void = malloc+0 (used reg = )
  1092. call _malloc
  1093. inc sp
  1094. inc sp
  1095. mov bx,-6[bp]
  1096. ! Debug: eq * void = ax+0 to * * struct Length_String = [bx+2] (used reg = )
  1097. mov 2[bx],ax
  1098. !BCC_EOS
  1099. ! 263 return result;
  1100. mov ax,-6[bp]
  1101. inc sp
  1102. inc sp
  1103. pop si
  1104. pop di
  1105. pop bp
  1106. ret
  1107. !BCC_EOS
  1108. ! 264 }
  1109. ! 265
  1110. ! 266
  1111. ! 267 Length_String *create_length_string(length, chars)
  1112. ! Register BX used in function create_length_string_array
  1113. ! 268 unsigned int length;
  1114. export _create_length_string
  1115. _create_length_string:
  1116. !BCC_EOS
  1117. ! 269 char *chars;
  1118. !BCC_EOS
  1119. ! 270 {
  1120. ! 271
  1121. ! 272 Length_String *legth_string = malloc(sizeof(Length_String));
  1122. push bp
  1123. mov bp,sp
  1124. push di
  1125. push si
  1126. dec sp
  1127. dec sp
  1128. ! Debug: list int = const 6 (used reg = )
  1129. mov ax,*6
  1130. push ax
  1131. ! Debug: func () * void = malloc+0 (used reg = )
  1132. call _malloc
  1133. inc sp
  1134. inc sp
  1135. ! Debug: eq * void = ax+0 to * struct Length_String legth_string = [S+8-8] (used reg = )
  1136. mov -6[bp],ax
  1137. !BCC_EOS
  1138. ! 273 char *copy = malloc(length + 1);
  1139. dec sp
  1140. dec sp
  1141. ! Debug: add int = const 1 to unsigned int length = [S+$A+2] (used reg = )
  1142. mov ax,4[bp]
  1143. ! Debug: list unsigned int = ax+1 (used reg = )
  1144. inc ax
  1145. push ax
  1146. ! Debug: func () * void = malloc+0 (used reg = )
  1147. call _malloc
  1148. inc sp
  1149. inc sp
  1150. ! Debug: eq * void = ax+0 to * char copy = [S+$A-$A] (used reg = )
  1151. mov -8[bp],ax
  1152. !BCC_EOS
  1153. ! 274 memcpy(copy, 0x7e0, chars, 0x7e0, length);
  1154. ! Debug: list unsigned int length = [S+$A+2] (used reg = )
  1155. push 4[bp]
  1156. ! Debug: list int = const $7E0 (used reg = )
  1157. mov ax,#$7E0
  1158. push ax
  1159. ! Debug: list * char chars = [S+$E+4] (used reg = )
  1160. push 6[bp]
  1161. ! Debug: list int = const $7E0 (used reg = )
  1162. mov ax,#$7E0
  1163. push ax
  1164. ! Debug: list * char copy = [S+$12-$A] (used reg = )
  1165. push -8[bp]
  1166. ! Debug: func () void = memcpy+0 (used reg = )
  1167. call _memcpy
  1168. add sp,*$A
  1169. !BCC_EOS
  1170. ! 275 copy[length] = '\0';
  1171. ! Debug: ptradd unsigned int length = [S+$A+2] to * char copy = [S+$A-$A] (used reg = )
  1172. mov ax,4[bp]
  1173. add ax,-8[bp]
  1174. mov bx,ax
  1175. ! Debug: eq int = const 0 to char = [bx+0] (used reg = )
  1176. xor al,al
  1177. mov [bx],al
  1178. !BCC_EOS
  1179. ! 276
  1180. ! 277 legth_string->dynamic = 1;
  1181. mov bx,-6[bp]
  1182. ! Debug: eq int = const 1 to short = [bx+0] (used reg = )
  1183. mov ax,*1
  1184. mov [bx],ax
  1185. !BCC_EOS
  1186. ! 278 legth_string->length = length;
  1187. mov bx,-6[bp]
  1188. ! Debug: eq unsigned int length = [S+$A+2] to unsigned int = [bx+2] (used reg = )
  1189. mov ax,4[bp]
  1190. mov 2[bx],ax
  1191. !BCC_EOS
  1192. ! 279 legth_string->chars = copy;
  1193. mov bx,-6[bp]
  1194. ! Debug: eq * char copy = [S+$A-$A] to * char = [bx+4] (used reg = )
  1195. mov si,-8[bp]
  1196. mov 4[bx],si
  1197. !BCC_EOS
  1198. ! 280
  1199. ! 281 return legth_string;
  1200. mov ax,-6[bp]
  1201. add sp,*4
  1202. pop si
  1203. pop di
  1204. pop bp
  1205. ret
  1206. !BCC_EOS
  1207. ! 282 # 18 "implementation/../main.h"
  1208. ! 18 }
  1209. ! 19 # 1 "implementation/../driver/disk.h"
  1210. ! 1 int data_from_disk(index, number_sectors, data_buffer, data_buffer_segment);
  1211. ! Register BX SI used in function create_length_string
  1212. !BCC_EOS
  1213. ! 2 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment);
  1214. !BCC_EOS
  1215. ! 3
  1216. ! 4 int disk_service_read_data_
  1217. ! 4 from_disk(index, number_sectors, data_buffer, data_buffer_segment)
  1218. ! 5 long* index;
  1219. export _disk_service_read_data_from_disk
  1220. _disk_service_read_data_from_disk:
  1221. !BCC_EOS
  1222. ! 6 long number_sectors;
  1223. !BCC_EOS
  1224. ! 7 void* data_buffer;
  1225. !BCC_EOS
  1226. ! 8 int data_buffer_segment;
  1227. !BCC_EOS
  1228. ! 9 {
  1229. ! 10
  1230. ! 11 #asm
  1231. !BCC_ASM
  1232. _disk_service_read_data_from_disk.data_buffer set 8
  1233. _disk_service_read_data_from_disk.number_sectors set 4
  1234. _disk_service_read_data_from_disk.data_buffer_segment set $A
  1235. _disk_service_read_data_from_disk.index set 2
  1236. ! 13 define number_sectors 8[bp];
  1237. push bp
  1238. mov bp,sp
  1239. pusha
  1240. lsfs_load_data:
  1241. mov ax, 4[bp];
  1242. mov WORD [DAPACK.lba_addr_dw_low], ax
  1243. mov bx, 8[bp];
  1244. mov WORD [DAPACK.blkcnt], bx
  1245. mov cx, 12[bp];
  1246. mov WORD [DAPACK.db_addr_segment], cx
  1247. mov dx, 10[bp]; ;
  1248. mov WORD [DAPACK.db_addr_offset], dx
  1249. mov si, #DAPACK ; address of
  1250. mov ah, #0x42 ; READ
  1251. mov dl, [global_disk_identifier]
  1252. int #0x13
  1253. ;call 0x0000:0x7C2A
  1254. popa
  1255. pop bp
  1256. ret
  1257. DAPACK:
  1258. DAPACK.dap_Size: db 0x10
  1259. DAPACK.rev_byte: db 0x0
  1260. DAPACK.blkcnt: dw 0x0
  1261. DAPACK.db_addr_offset: dw 0x0
  1262. DAPACK.db_addr_segment: dw 0x0
  1263. DAPACK.lba_addr_dw_low: dd 0x0
  1264. DAPACK.lba_addr_dw_high: dd 0x0
  1265. global_disk_identifier: db 0x80
  1266. ! 51 endasm
  1267. !BCC_ENDASM
  1268. ! 52 }
  1269. ret
  1270. ! 53 # 22 "implementation/../main.h"
  1271. ! 22 void dump_ax(input);
  1272. !BCC_EOS
  1273. ! 23 void print_stack(argument);
  1274. !BCC_EOS
  1275. ! 24 void print_newline();
  1276. !BCC_EOS
  1277. ! 25
  1278. ! 26 typedef struct Directory_Table Directory_Table;
  1279. !BCC_EOS
  1280. ! 27 typedef struct Struct_Table_Entry Table_Entry;
  1281. !BCC_EOS
  1282. ! 28 typedef struct struct_partition_control partition_control;
  1283. !BCC_EOS
  1284. ! 29 typedef struct File_System_Control_Information FSCI;
  1285. !BCC_EOS
  1286. ! 30 typedef struct meta_information_format mif;
  1287. !BCC_EOS
  1288. ! 31 typedef struct tag_record tag_record;
  1289. !BCC_EOS
  1290. ! 32 typedef struct Parameter_Struct Parameter_Struct;
  1291. !BCC_EOS
  1292. ! 33
  1293. ! 34 typedef enum Table_Entry_Kind
  1294. ! 35 {
  1295. ! 36
  1296. ! 37 ENTRY_EMPTY = 0,
  1297. ! 38 ENTRY_FILE = 1,
  1298. ! 39 ENTRY_DIRECTORY = 2,
  1299. ! 40 } Table_Entry_Kind;
  1300. !BCC_EOS
  1301. ! 41
  1302. ! 42 typedef enum Service_Action
  1303. ! 43 {
  1304. ! 44 SERIVCE_LOAD_DISK = 1,
  1305. ! 45 SERVICE_FIND_ENTRY = 2,
  1306. ! 46 SERIVCE_READ_DATA = 3,
  1307. ! 47 SERIVCE_WRITE_DATA = 4,
  1308. ! 48
  1309. ! 49 } Service_Action;
  1310. !BCC_EOS
  1311. ! 50
  1312. ! 51 struct Struct_Table_Entry
  1313. ! 52 {
  1314. ! 53 char filename[256];
  1315. !BCC_EOS
  1316. ! 54 long file_id[2];
  1317. !BCC_EOS
  1318. ! 55 long file_size[2];
  1319. !BCC_EOS
  1320. ! 56 void* ext_file_data_low;
  1321. !BCC_EOS
  1322. ! 57 void* ext_file_data_high;
  1323. !BCC_EOS
  1324. ! 58 long number_sector_s;
  1325. !BCC_EOS
  1326. ! 59 short entry_kind;
  1327. !BCC_EOS
  1328. ! 60 short extra_control_bits1;
  1329. !BCC_EOS
  1330. ! 61 short extra_contro
  1331. ! 61 l_bits2;
  1332. !BCC_EOS
  1333. ! 62 short extra_control_bits3;
  1334. !BCC_EOS
  1335. ! 63 long table_entry_sector_index[2];
  1336. !BCC_EOS
  1337. ! 64 long data_pointer[27 * 2];
  1338. !BCC_EOS
  1339. ! 65 };
  1340. !BCC_EOS
  1341. ! 66
  1342. ! 67 struct File_System_Control_Information
  1343. ! 68 {
  1344. ! 69 char filesystem_information[256];
  1345. !BCC_EOS
  1346. ! 70 long master_table_index[2];
  1347. !BCC_EOS
  1348. ! 71 long this_partition_offset_on_disk[2];
  1349. !BCC_EOS
  1350. ! 72 long next_free_sector[2];
  1351. !BCC_EOS
  1352. ! 73 long next_uniqe_id[2];
  1353. !BCC_EOS
  1354. ! 74 long next_sector_reuse_pointer[2];
  1355. !BCC_EOS
  1356. ! 75 long last_sector_index_on_partition[2];
  1357. !BCC_EOS
  1358. ! 76 long maximum_sectors_on_disk[2];
  1359. !BCC_EOS
  1360. ! 77 long sector_size_on_disk[2];
  1361. !BCC_EOS
  1362. ! 78 long not_used[48];
  1363. !BCC_EOS
  1364. ! 79
  1365. ! 80 };
  1366. !BCC_EOS
  1367. ! 81
  1368. ! 82 typedef struct Directory_Table
  1369. ! 83 {
  1370. ! 84 Table_Entry entries[16 ];
  1371. !BCC_EOS
  1372. ! 85
  1373. ! 86 };
  1374. !BCC_EOS
  1375. ! 87
  1376. ! 88 struct Parameter_Struct
  1377. ! 89 {
  1378. ! 90 char* path;
  1379. !BCC_EOS
  1380. ! 91 char* new_path;
  1381. !BCC_EOS
  1382. ! 92 int buffer_segment;
  1383. !BCC_EOS
  1384. ! 93 int buffer_address;
  1385. !BCC_EOS
  1386. ! 94 int buffer_size;
  1387. !BCC_EOS
  1388. ! 95 int data_length;
  1389. !BCC_EOS
  1390. ! 96 int byte_offset_into_file;
  1391. !BCC_EOS
  1392. ! 97 Table_Entry_Kind entry_kind;
  1393. !BCC_EOS
  1394. ! 98 };
  1395. !BCC_EOS
  1396. ! 99 # 4 "implementation/lsfs.c"
  1397. ! 4 struct lsfs_file {
  1398. ! 5 long file_id[2];
  1399. !BCC_EOS
  1400. ! 6 long table_entry_pointer[2];
  1401. !BCC_EOS
  1402. ! 7 Table_Entry_Kind entry_kind;
  1403. !BCC_EOS
  1404. ! 8 char* filename;
  1405. !BCC_EOS
  1406. ! 9 long owner_id;
  1407. !BCC_EOS
  1408. ! 10 long size[2];
  1409. !BCC_EOS
  1410. ! 11 long creation_date[2];
  1411. !BCC_EOS
  1412. ! 12 long access_time[2];
  1413. !BCC_EOS
  1414. ! 13 long modification_time[2];
  1415. !BCC_EOS
  1416. ! 14 long number_sector;
  1417. !BCC_EOS
  1418. ! 15 long table_entry_sector_index[2];
  1419. !BCC_EOS
  1420. ! 16 long data_pointer[27 * 2];
  1421. !BCC_EOS
  1422. ! 17 };
  1423. !BCC_EOS
  1424. ! 18
  1425. ! 19 int lsfs_disk_read_data_from_file(file, buffer_size, data, offset_to_next_entry)
  1426. ! 20 lsfs_file *file;
  1427. export _lsfs_disk_read_data_from_file
  1428. _lsfs_disk_read_data_from_file:
  1429. !BCC_EOS
  1430. ! 21 int buffer_size;
  1431. !BCC_EOS
  1432. ! 22 char *data;
  1433. !BCC_EOS
  1434. ! 23 long offset_to_next_entry;
  1435. !BCC_EOS
  1436. ! 24 {
  1437. ! 25 int integer_file_size = file->size;
  1438. push bp
  1439. mov bp,sp
  1440. push di
  1441. push si
  1442. dec sp
  1443. dec sp
  1444. mov bx,4[bp]
  1445. ! Debug: eq [2] long = bx+$18 to int integer_file_size = [S+8-8] (used reg = )
  1446. add bx,*$18
  1447. mov -6[bp],bx
  1448. !BCC_EOS
  1449. ! 26 int integer_offset = offset_to_next_entry;
  1450. dec sp
  1451. dec sp
  1452. ! Debug: eq long offset_to_next_entry = [S+$A+8] to int integer_offset = [S+$A-$A] (used reg = )
  1453. mov ax,$A[bp]
  1454. mov -8[bp],ax
  1455. !BCC_EOS
  1456. ! 27 int integer_datapointer = 0;
  1457. dec sp
  1458. dec sp
  1459. ! Debug: eq int = const 0 to int integer_datapointer = [S+$C-$C] (used reg = )
  1460. xor ax,ax
  1461. mov -$A[bp],ax
  1462. !BCC_EOS
  1463. ! 28 int data_length = integer_file_size - integer_offset;
  1464. dec sp
  1465. dec sp
  1466. ! Debug: sub int integer_offset = [S+$E-$A] to int integer_file_size = [S+$E-8] (used reg = )
  1467. mov ax,-6[bp]
  1468. sub ax,-8[bp]
  1469. ! Debug: eq int = ax+0 to int data_length = [S+$E-$E] (used reg = )
  1470. mov -$C[bp],ax
  1471. !BCC_EOS
  1472. ! 29 int amount_read = 0;
  1473. dec sp
  1474. dec sp
  1475. ! Debug: eq int = const 0 to int amount_read = [S+$10-$10] (used reg = )
  1476. xor ax,ax
  1477. mov -$E[bp],ax
  1478. !BCC_EOS
  1479. ! 30 int amount_to_read = 0;
  1480. dec sp
  1481. dec sp
  1482. ! Debug: eq int = const 0 to int amount_to_read = [S+$12-$12] (used reg = )
  1483. xor ax,ax
  1484. mov -$10[bp],ax
  1485. !BCC_EOS
  1486. ! 31 int remaining_offset = offset_to_next_entry;
  1487. dec sp
  1488. dec sp
  1489. ! Debug: eq long offset_to_next_entry = [S+$14+8] to int remaining_offset = [S+$14-$14] (used reg = )
  1490. mov ax,$A[bp]
  1491. mov -$12[bp],ax
  1492. !BCC_EOS
  1493. ! 32
  1494. ! 33
  1495. ! 34
  1496. ! 35
  1497. ! 36
  1498. ! 37 int data_pointer_index = 0;
  1499. dec sp
  1500. dec sp
  1501. ! Debug: eq int = const 0 to int data_pointer_index = [S+$16-$16] (used reg = )
  1502. xor ax,ax
  1503. mov -$14[bp],ax
  1504. !BCC_EOS
  1505. ! 38
  1506. ! 39 if (data_length > buffer_size)
  1507. ! Debug: gt int buffer_size = [S+$16+4] to int data_length = [S+$16-$E] (used reg = )
  1508. mov ax,-$C[bp]
  1509. cmp ax,6[bp]
  1510. jle .21
  1511. .22:
  1512. ! 40 {
  1513. ! 41 data_length = buffer_size;
  1514. ! Debug: eq int buffer_size = [S+$16+4] to int data_length = [S+$16-$E] (used reg = )
  1515. mov ax,6[bp]
  1516. mov -$C[bp],ax
  1517. !BCC_EOS
  1518. ! 42 }
  1519. ! 43
  1520. ! 44 while(data_length > 0)
  1521. .21:
  1522. ! 45 {
  1523. br .24
  1524. .25:
  1525. ! 46
  1526. ! 47 if (remaining_offset == 0)
  1527. ! Debug: logeq int = const 0 to int remaining_offset = [S+$16-$14] (used reg = )
  1528. mov ax,-$12[bp]
  1529. test ax,ax
  1530. bne .26
  1531. .27:
  1532. ! 48 {
  1533. ! 49 char *tmp_buffer = calloc(4 , 512 );
  1534. dec sp
  1535. dec sp
  1536. ! Debug: list int = const $200 (used reg = )
  1537. mov ax,#$200
  1538. push ax
  1539. ! Debug: list int = const 4 (used reg = )
  1540. mov ax,*4
  1541. push ax
  1542. ! Debug: func () * void = calloc+0 (used reg = )
  1543. call _calloc
  1544. add sp,*4
  1545. ! Debug: eq * void = ax+0 to * char tmp_buffer = [S+$18-$18] (used reg = )
  1546. mov -$16[bp],ax
  1547. !BCC_EOS
  1548. ! 50
  1549. ! 51
  1550. ! 52 if (data_length < (4 * 512 ))
  1551. ! Debug: lt int = const $800 to int data_length = [S+$18-$E] (used reg = )
  1552. mov ax,-$C[bp]
  1553. cmp ax,#$800
  1554. jge .28
  1555. .29:
  1556. ! 53 {
  1557. ! 54 amount_to_read = data_length;
  1558. ! Debug: eq int data_length = [S+$18-$E] to int amount_to_read = [S+$18-$12] (used reg = )
  1559. mov ax,-$C[bp]
  1560. mov -$10[bp],ax
  1561. !BCC_EOS
  1562. ! 55 }
  1563. ! 56 e
  1564. ! 56 lse
  1565. ! 57 {
  1566. jmp .2A
  1567. .28:
  1568. ! 58 amount_to_read = (4 * 512 );
  1569. ! Debug: eq int = const $800 to int amount_to_read = [S+$18-$12] (used reg = )
  1570. mov ax,#$800
  1571. mov -$10[bp],ax
  1572. !BCC_EOS
  1573. ! 59 }
  1574. ! 60
  1575. ! 61 integer_datapointer = file->data_pointer[data_pointer_index];
  1576. .2A:
  1577. mov bx,4[bp]
  1578. ! Debug: ptradd int data_pointer_index = [S+$18-$16] to [$36] long = bx+$44 (used reg = )
  1579. mov ax,-$14[bp]
  1580. shl ax,*1
  1581. shl ax,*1
  1582. add bx,ax
  1583. ! Debug: eq long = [bx+$44] to int integer_datapointer = [S+$18-$C] (used reg = )
  1584. mov bx,$44[bx]
  1585. mov -$A[bp],bx
  1586. !BCC_EOS
  1587. ! 62 if (integer_datapointer == 0)
  1588. ! Debug: logeq int = const 0 to int integer_datapointer = [S+$18-$C] (used reg = )
  1589. mov ax,-$A[bp]
  1590. test ax,ax
  1591. jne .2B
  1592. .2C:
  1593. ! 63 {
  1594. ! 64 break;
  1595. inc sp
  1596. inc sp
  1597. br .23
  1598. !BCC_EOS
  1599. ! 65 }
  1600. ! 66 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], 4 , tmp_buffer);
  1601. .2B:
  1602. ! Debug: list * char tmp_buffer = [S+$18-$18] (used reg = )
  1603. push -$16[bp]
  1604. ! Debug: list int = const 4 (used reg = )
  1605. mov ax,*4
  1606. push ax
  1607. mov bx,4[bp]
  1608. ! Debug: ptradd int data_pointer_index = [S+$1C-$16] to [$36] long = bx+$44 (used reg = )
  1609. mov ax,-$14[bp]
  1610. shl ax,*1
  1611. shl ax,*1
  1612. add bx,ax
  1613. ! Debug: list long = [bx+$44] (used reg = )
  1614. push $46[bx]
  1615. push $44[bx]
  1616. ! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = )
  1617. call _disk_service_read_data_from_disk
  1618. add sp,*8
  1619. !BCC_EOS
  1620. ! 67 memcpy((data + amount_read), tmp_buffer, amount_to_read);
  1621. ! Debug: list int amount_to_read = [S+$18-$12] (used reg = )
  1622. push -$10[bp]
  1623. ! Debug: list * char tmp_buffer = [S+$1A-$18] (used reg = )
  1624. push -$16[bp]
  1625. ! Debug: ptradd int amount_read = [S+$1C-$10] to * char data = [S+$1C+6] (used reg = )
  1626. mov ax,-$E[bp]
  1627. add ax,8[bp]
  1628. ! Debug: list * char = ax+0 (used reg = )
  1629. push ax
  1630. ! Debug: func () void = memcpy+0 (used reg = )
  1631. call _memcpy
  1632. add sp,*6
  1633. !BCC_EOS
  1634. ! 68 data_length -= amount_to_read;
  1635. ! Debug: subab int amount_to_read = [S+$18-$12] to int data_length = [S+$18-$E] (used reg = )
  1636. mov ax,-$C[bp]
  1637. sub ax,-$10[bp]
  1638. mov -$C[bp],ax
  1639. !BCC_EOS
  1640. ! 69 amount_read += amount_to_read;
  1641. ! Debug: addab int amount_to_read = [S+$18-$12] to int amount_read = [S+$18-$10] (used reg = )
  1642. mov ax,-$E[bp]
  1643. add ax,-$10[bp]
  1644. mov -$E[bp],ax
  1645. !BCC_EOS
  1646. ! 70 data_pointer_index++;
  1647. ! Debug: postinc int data_pointer_index = [S+$18-$16] (used reg = )
  1648. mov ax,-$14[bp]
  1649. inc ax
  1650. mov -$14[bp],ax
  1651. !BCC_EOS
  1652. ! 71
  1653. ! 72 }
  1654. inc sp
  1655. inc sp
  1656. ! 73 else if (remaining_offset < (4 * 512 ))
  1657. br .2D
  1658. .26:
  1659. ! Debug: lt int = const $800 to int remaining_offset = [S+$16-$14] (used reg = )
  1660. mov ax,-$12[bp]
  1661. cmp ax,#$800
  1662. bge .2E
  1663. .2F:
  1664. ! 74 {
  1665. ! 75 char *tmp_buffer = calloc(1, (4 * 512 ));
  1666. dec sp
  1667. dec sp
  1668. ! Debug: list int = const $800 (used reg = )
  1669. mov ax,#$800
  1670. push ax
  1671. ! Debug: list int = const 1 (used reg = )
  1672. mov ax,*1
  1673. push ax
  1674. ! Debug: func () * void = calloc+0 (used reg = )
  1675. call _calloc
  1676. add sp,*4
  1677. ! Debug: eq * void = ax+0 to * char tmp_buffer = [S+$18-$18] (used reg = )
  1678. mov -$16[bp],ax
  1679. !BCC_EOS
  1680. ! 76
  1681. ! 77
  1682. ! 78 if (data_length < ((4 * 512 ) - remaining_offset) )
  1683. ! Debug: sub int remaining_offset = [S+$18-$14] to int = const $800 (used reg = )
  1684. mov ax,#$800
  1685. sub ax,-$12[bp]
  1686. ! Debug: lt int = ax+0 to int data_length = [S+$18-$E] (used reg = )
  1687. cmp ax,-$C[bp]
  1688. jle .30
  1689. .31:
  1690. ! 79 {
  1691. ! 80 amount_to_read = data_length;
  1692. ! Debug: eq int data_length = [S+$18-$E] to int amount_to_read = [S+$18-$12] (used reg = )
  1693. mov ax,-$C[bp]
  1694. mov -$10[bp],ax
  1695. !BCC_EOS
  1696. ! 81 }
  1697. ! 82 else
  1698. ! 83 {
  1699. jmp .32
  1700. .30:
  1701. ! 84 amount_to_read = ((4 * 512 ) - remaining_offset);
  1702. ! Debug: sub int remaining_offset = [S+$18-$14] to int = const $800 (used reg = )
  1703. mov ax,#$800
  1704. sub ax,-$12[bp]
  1705. ! Debug: eq int = ax+0 to int amount_to_read = [S+$18-$12] (used reg = )
  1706. mov -$10[bp],ax
  1707. !BCC_EOS
  1708. ! 85 }
  1709. ! 86
  1710. ! 87 disk_service_read_data_from_disk(file->data_pointer[data_pointer_index], 4 , tmp_buffer);
  1711. .32:
  1712. ! Debug: list * char tmp_buffer = [S+$18-$18] (used reg = )
  1713. push -$16[bp]
  1714. ! Debug: list int = const 4 (used reg = )
  1715. mov ax,*4
  1716. push ax
  1717. mov bx,4[bp]
  1718. ! Debug: ptradd int data_pointer_index = [S+$1C-$16] to [$36] long = bx+$44 (used reg = )
  1719. mov ax,-$14[bp]
  1720. shl ax,*1
  1721. shl ax,*1
  1722. add bx,ax
  1723. ! Debug: list long = [bx+$44] (used reg = )
  1724. push $46[bx]
  1725. push $44[bx]
  1726. ! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = )
  1727. call _disk_service_read_data_from_disk
  1728. add sp,*8
  1729. !BCC_EOS
  1730. ! 88
  1731. ! 89 memcpy(data, (tmp_buffer + remaining_offset), amount_to_read);
  1732. ! Debug: list int amount_to_read = [S+$18-$12] (used reg = )
  1733. push -$10[bp]
  1734. ! Debug: ptradd int remaining_offset = [S+$1A-$14] to * char tmp_buffer = [S+$1A-$18] (used reg = )
  1735. mov ax,-$12[bp]
  1736. add ax,-$16[bp]
  1737. ! Debug: list * char = ax+0 (used reg = )
  1738. push ax
  1739. ! Debug: list * char data = [S+$1C+6] (used reg = )
  1740. push 8[bp]
  1741. ! Debug: func () void = memcpy+0 (used reg = )
  1742. call _memcpy
  1743. add sp,*6
  1744. !BCC_EOS
  1745. ! 90 data_length -= amount_to_read;
  1746. ! Debug: subab int amount_to_read = [S+$18-$12] to int data_length = [S+$18-$E] (used reg = )
  1747. mov ax,-$C[bp]
  1748. sub ax,-$10[bp]
  1749. mov -$C[bp],ax
  1750. !BCC_EOS
  1751. ! 91 amount_read += amount_to_read;
  1752. ! Debug: addab int amount_to_read = [S+$18-$12] to int amount_read = [S+$18-$10] (used reg = )
  1753. mov ax,-$E[bp]
  1754. add ax,-$10[bp]
  1755. mov -$E[bp],ax
  1756. !BCC_EOS
  1757. ! 92 remaining_offset -= amount_to_read;
  1758. ! Debug: subab int amount_to_read = [S+$18-$12] to int remaining_offset = [S+$18-$14] (used reg = )
  1759. mov ax,-$12[bp]
  1760. sub ax,-$10[bp]
  1761. mov -$12[bp],ax
  1762. !BCC_EOS
  1763. ! 93
  1764. ! 94 data_pointer_index++;
  1765. ! Debug: postinc int data_pointer_index = [S+$18-$16] (used reg = )
  1766. mov ax,-$14[bp]
  1767. inc ax
  1768. mov -$14[bp],ax
  1769. !BCC_EOS
  1770. ! 95
  1771. ! 96 }
  1772. inc sp
  1773. inc sp
  1774. ! 97 else
  1775. ! 98 {
  1776. jmp .33
  1777. .2E:
  1778. ! 99
  1779. ! 100 remaining_offset -= (4 * 512 );
  1780. ! Debug: subab int = const $800 to int remaining_offset = [S+$16-$14] (used reg = )
  1781. mov ax,-$12[bp]
  1782. add ax,#-$800
  1783. mov -$12[bp],ax
  1784. !BCC_EOS
  1785. ! 101 data_pointer_index++;
  1786. ! Debug: postinc int data_pointer_index = [S+$16-$16] (used reg = )
  1787. mov ax,-$14[bp]
  1788. inc ax
  1789. mov -$14[bp],ax
  1790. !BCC_EOS
  1791. ! 102 }
  1792. ! 103
  1793. ! 104 }
  1794. .33:
  1795. .2D:
  1796. ! 105 # 109
  1797. ! 109
  1798. ! 110 return amount_read;
  1799. .24:
  1800. ! Debug: gt int = const 0 to int data_length = [S+$16-$E] (used reg = )
  1801. mov ax,-$C[bp]
  1802. test ax,ax
  1803. bgt .25
  1804. .34:
  1805. .23:
  1806. mov ax,-$E[bp]
  1807. add sp,*$10
  1808. pop si
  1809. pop di
  1810. pop bp
  1811. ret
  1812. !BCC_EOS
  1813. ! 111
  1814. ! 112 }
  1815. ! 113
  1816. ! Register BX used in function lsfs_disk_read_data_from_file
  1817. .data
  1818. .bss
  1819. ! 0 errors detected