選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

1899 行
41 KiB

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