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

668 行
13 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年前
  1. push bp
  2. mov bp,sp
  3. push 8[bp]
  4. push 6[bp]
  5. call _main
  6. add sp, #0x4
  7. pop bp
  8. retf
  9. ! 1
  10. ! 1 # 1 "main.c"
  11. ! 1 # 1 "std_singos/string.h"
  12. ! 1 void strcpy (destination, destination_segment, source, source_segment );
  13. !BCC_EOS
  14. ! 2
  15. ! 3 void strcpy (destination, destination_segment, source, source_segment )
  16. ! 4 char *destination;
  17. export _strcpy
  18. _strcpy:
  19. !BCC_EOS
  20. ! 5 int destination_segment;
  21. !BCC_EOS
  22. ! 6 char *source;
  23. !BCC_EOS
  24. ! 7 int source_segment;
  25. !BCC_EOS
  26. ! 8 {
  27. ! 9 #asm
  28. !BCC_ASM
  29. _strcpy.source set 6
  30. _strcpy.destination set 2
  31. _strcpy.source_segment set 8
  32. _strcpy.destination_segment set 4
  33. ; copy two strings
  34. ; IN si: the first (zero terminated) string
  35. ; IN di: the second (zero terminated) string
  36. ; OUT SF and ZF (same semantics as cmp)
  37. ! 15 19
  38. push bp
  39. mov bp,sp
  40. stringcompare:
  41. push ax
  42. push bx
  43. push di
  44. push es
  45. push si
  46. push ds
  47. mov ax, 4[bp]; ;
  48. mov di, ax
  49. mov ax, 6[bp]; ;
  50. mov es, ax
  51. mov ax, 8[bp]; ;
  52. mov si, ax
  53. mov ax, 10[bp]; ;
  54. mov ds, ax
  55. mov cx, 0x050
  56. .loop:
  57. movsb
  58. cmp cx, 0x0
  59. je .end
  60. dec cx
  61. jmp .loop
  62. .end:
  63. pop ds
  64. pop si
  65. pop es
  66. pop di
  67. pop bx
  68. pop ax
  69. pop bp
  70. ! 53 endasm
  71. !BCC_ENDASM
  72. ! 54 }
  73. ret
  74. ! 55 # 1 "driver/disk.h"
  75. ! 1 int data_from_disk(index, number_sectors, data_buffer, data_buffer_segment);
  76. !BCC_EOS
  77. ! 2 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment);
  78. !BCC_EOS
  79. ! 3
  80. ! 4 int disk_service_read_data_from_disk(index, number_sectors, data_buffer, data_buffer_segment)
  81. ! 5 long* index;
  82. export _disk_service_read_data_from_disk
  83. _disk_service_read_data_from_disk:
  84. !BCC_EOS
  85. ! 6 long number_sectors;
  86. !BCC_EOS
  87. ! 7 void* data_buffer;
  88. !BCC_EOS
  89. ! 8 int data_buffer_segment;
  90. !BCC_EOS
  91. ! 9 {
  92. ! 10
  93. ! 11 #asm
  94. !BCC_ASM
  95. _disk_service_read_data_from_disk.data_buffer set 8
  96. _disk_service_read_data_from_disk.number_sectors set 4
  97. _disk_service_read_data_from_disk.data_buffer_segment set $A
  98. _disk_service_read_data_from_disk.index set 2
  99. ! 13 define number_sectors 8[bp];
  100. push bp
  101. mov bp,sp
  102. pusha
  103. lsfs_load_data:
  104. mov ax, 4[bp];
  105. mov WORD [DAPACK.lba_addr_dw_low], ax
  106. mov bx, 8[bp];
  107. mov WORD [DAPACK.blkcnt], bx
  108. mov cx, 12[bp];
  109. mov WORD [DAPACK.db_addr_segment], cx
  110. mov dx, 10[bp]; ;
  111. mov WORD [DAPACK.db_addr_offset], dx
  112. mov si, #DAPACK ; address of
  113. mov ah, #0x42 ; READ
  114. mov dl, [global_disk_identifier]
  115. int #0x13
  116. ;call 0x0000:0x7C2A
  117. popa
  118. pop bp
  119. ret
  120. DAPACK:
  121. DAPACK.dap_Size: db 0x10
  122. DAPACK.rev_byte: db 0x0
  123. DAPACK.blkcnt: dw 0x0
  124. DAPACK.db_addr_offset: dw 0x0
  125. DAPACK.db_addr_segment: dw 0x0
  126. DAPACK.lba_addr_dw_low: dd 0x0
  127. DAPACK.lba_addr_dw_high: dd 0x0
  128. global_disk_identifier: db 0x80
  129. ! 51 endasm
  130. !BCC_ENDASM
  131. ! 52 }
  132. ret
  133. ! 53 # 10 "main.c"
  134. ! 10 #define SPACE_VBR_RECORD 2048
  135. ! 11
  136. ! 12 #define DEFAULT_ENTRY_SIZE 1
  137. ! 13
  138. ! 14 #define NUMBER_OF_MBR_PARTITIONS 4
  139. ! 15
  140. ! 16 #define DEFAULT_DATA_POINTER_SIZE 4
  141. ! 17
  142. ! 18
  143. ! 19
  144. ! 20 void dump_ax(input);
  145. !BCC_EOS
  146. ! 21 void print_stack(argument);
  147. !BCC_EOS
  148. ! 22 void print_newline();
  149. !BCC_EOS
  150. ! 23
  151. ! 24 typedef struct Directory_Table Directory_Table;
  152. !BCC_EOS
  153. ! 25 typedef struct Struct_Table_Entry Table_Entry;
  154. !BCC_EOS
  155. ! 26 typedef struct struct_partition_control partition_control;
  156. !BCC_EOS
  157. ! 27 typedef struct File_System_Control_Information FSCI;
  158. !BCC_EOS
  159. ! 28 typedef struct meta_information_format mif;
  160. !BCC_EOS
  161. ! 29 typedef struct tag_record tag_record;
  162. !BCC_EOS
  163. ! 30 typedef struct lsfs_file lsfs_file;
  164. !BCC_EOS
  165. ! 31
  166. ! 32 typedef enum Table_Entry_Kind
  167. ! 33 {
  168. ! 34
  169. ! 35 ENTRY_EMPTY = 0,
  170. ! 36 ENTRY_FILE = 1,
  171. ! 37 ENTRY_DIRECTORY = 2,
  172. ! 38 } Table_Entry_Kind;
  173. !BCC_EOS
  174. ! 39
  175. ! 40 typedef enum Service_Action
  176. ! 41 {
  177. ! 42 SERIVCE_LOAD_DISK = 1,
  178. ! 43 SERVICE_FIND_ENTRY = 2,
  179. ! 44 SERIVCE_READ_DATA = 3,
  180. ! 45 SERIVCE_WRITE_DATA = 4,
  181. ! 46
  182. ! 47 } Service_Action;
  183. !BCC_EOS
  184. ! 48
  185. ! 49 int number_low;
  186. !BCC_EOS
  187. ! 50 int selector;
  188. !BCC_EOS
  189. ! 51
  190. ! 52 struct Struct_Table_Entry
  191. ! 53 {
  192. ! 54 char filename[256];
  193. !BCC_EOS
  194. ! 55 long file_id[2];
  195. !BCC_EOS
  196. ! 56 long file_size[2];
  197. !BCC_EOS
  198. ! 57 void* ext_file_data_low;
  199. !BCC_EOS
  200. ! 58 void* ext_file_data_high;
  201. !BCC_EOS
  202. ! 59 long number_sector_s;
  203. !BCC_EOS
  204. ! 60 short entry_kind;
  205. !BCC_EOS
  206. ! 61 short extra_control_bits1;
  207. !BCC_EOS
  208. ! 62 short extra_control_bits2;
  209. !BCC_EOS
  210. ! 63 short extra_control_bits3;
  211. !BCC_EOS
  212. ! 64 long table_entry_sector_index[2];
  213. !BCC_EOS
  214. ! 65 long data_pointer[27 * 2];
  215. !BCC_EOS
  216. ! 66 };
  217. !BCC_EOS
  218. ! 67
  219. ! 68 struct File_System_Control_Information
  220. ! 69 {
  221. ! 70 char filesystem_information[256];
  222. !BCC_EOS
  223. ! 71 long master_table_index[2];
  224. !BCC_EOS
  225. ! 72 long this_partition_offset_on_disk[2];
  226. !BCC_EOS
  227. ! 73 long next_free_sector[2];
  228. !BCC_EOS
  229. ! 74 long next_uniqe_id[2];
  230. !BCC_EOS
  231. ! 75 long next_sector_reuse_pointer[2];
  232. !BCC_EOS
  233. ! 76 long last_sector_index_on_partition[2];
  234. !BCC_EOS
  235. ! 77 long maximum_sectors_on_disk[2];
  236. !BCC_EOS
  237. ! 78 long sector_size_on_disk[2];
  238. !BCC_EOS
  239. ! 79 long not_used[48];
  240. !BCC_EOS
  241. ! 80
  242. ! 81 };
  243. !BCC_EOS
  244. ! 82
  245. ! 83 typedef struct Directory_Table
  246. ! 84 {
  247. ! 85 Table_Entry entries[16 ];
  248. !BCC_EOS
  249. ! 86
  250. ! 87 };
  251. !BCC_EOS
  252. ! 88
  253. ! 89
  254. ! 90 void print(string);
  255. !BCC_EOS
  256. ! 91
  257. ! 92 int main(selector, parameter_struct)
  258. ! 93 int selector;
  259. export _main
  260. _main:
  261. !BCC_EOS
  262. ! 94 void* parameter
  263. ! 94 _struct;
  264. !BCC_EOS
  265. ! 95 {
  266. ! 96
  267. ! 97
  268. ! 98
  269. ! 99 FSCI fsci;
  270. !BCC_EOS
  271. ! 100 Service_Action service_action;
  272. !BCC_EOS
  273. ! 101 Directory_Table current_table;
  274. !BCC_EOS
  275. ! 102 int local_segment = 0x7e0;
  276. push bp
  277. mov bp,sp
  278. push di
  279. push si
  280. add sp,#-$2204
  281. ! Debug: eq int = const $7E0 to int local_segment = [S+$220A-$220A] (used reg = )
  282. mov ax,#$7E0
  283. mov -$2208[bp],ax
  284. !BCC_EOS
  285. ! 103 int stack_segment = 0x8fc0;
  286. dec sp
  287. dec sp
  288. ! Debug: eq unsigned int = const $8FC0 to int stack_segment = [S+$220C-$220C] (used reg = )
  289. mov ax,#$8FC0
  290. mov -$220A[bp],ax
  291. !BCC_EOS
  292. ! 104 long index_as_long;
  293. !BCC_EOS
  294. ! 105
  295. ! 106 char local_path[256];
  296. !BCC_EOS
  297. ! 107 service_action = selector;
  298. add sp,#-$104
  299. ! Debug: eq int selector = [S+$2310+2] to int service_action = [S+$2310-$208] (used reg = )
  300. mov ax,4[bp]
  301. mov -$206[bp],ax
  302. !BCC_EOS
  303. ! 108
  304. ! 109 switch (service_action)
  305. mov ax,-$206[bp]
  306. ! 110 {
  307. br .3
  308. ! 111 case SERIVCE_LOAD_DISK:
  309. ! 112 {
  310. .4:
  311. ! 113
  312. ! 114
  313. ! 115
  314. ! 116
  315. ! 117 index_as_long = parameter_struct;
  316. ! Debug: eq * void parameter_struct = [S+$2310+4] to long index_as_long = [S+$2310-$2210] (used reg = )
  317. mov ax,6[bp]
  318. xor bx,bx
  319. mov -$220E[bp],ax
  320. mov -$220C[bp],bx
  321. !BCC_EOS
  322. ! 118 disk_service_read_data_from_disk(index_as_long, 1, &fsci, stack_segment);
  323. ! Debug: list int stack_segment = [S+$2310-$220C] (used reg = )
  324. push -$220A[bp]
  325. ! Debug: list * struct File_System_Control_Information fsci = S+$2312-$206 (used reg = )
  326. lea bx,-$204[bp]
  327. push bx
  328. ! Debug: list int = const 1 (used reg = )
  329. mov ax,*1
  330. push ax
  331. ! Debug: list long index_as_long = [S+$2316-$2210] (used reg = )
  332. push -$220C[bp]
  333. push -$220E[bp]
  334. ! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = )
  335. call _disk_service_read_data_from_disk
  336. add sp,*$A
  337. !BCC_EOS
  338. ! 119 print("File System has been loaded: ");
  339. ! Debug: list * char = .5+0 (used reg = )
  340. mov bx,#.5
  341. push bx
  342. ! Debug: func () void = print+0 (used reg = )
  343. call _print
  344. inc sp
  345. inc sp
  346. !BCC_EOS
  347. ! 120 print_newline();
  348. ! Debug: func () void = print_newline+0 (used reg = )
  349. call _print_newline
  350. !BCC_EOS
  351. ! 121 print_stack(fsci.filesystem_information);
  352. ! Debug: list * char fsci = S+$2310-$206 (used reg = )
  353. lea bx,-$204[bp]
  354. push bx
  355. ! Debug: func () void = print_stack+0 (used reg = )
  356. call _print_stack
  357. inc sp
  358. inc sp
  359. !BCC_EOS
  360. ! 122 print_newline();
  361. ! Debug: func () void = print_newline+0 (used reg = )
  362. call _print_newline
  363. !BCC_EOS
  364. ! 123 } break;
  365. br .1
  366. !BCC_EOS
  367. ! 124 case SERVICE_FIND_ENTRY:
  368. ! 125 {
  369. .6:
  370. ! 126 disk_service_read_data_from_disk(fsci.master_table_index[0], 16 , &current_table, stack_segment);
  371. ! Debug: list int stack_segment = [S+$2310-$220C] (used reg = )
  372. push -$220A[bp]
  373. ! Debug: list * struct Directory_Table current_table = S+$2312-$2208 (used reg = )
  374. lea bx,-$2206[bp]
  375. push bx
  376. ! Debug: list int = const $10 (used reg = )
  377. mov ax,*$10
  378. push ax
  379. ! Debug: list long fsci = [S+$2316-$106] (used reg = )
  380. push -$102[bp]
  381. push -$104[bp]
  382. ! Debug: func () int = disk_service_read_data_from_disk+0 (used reg = )
  383. call _disk_service_read_data_from_disk
  384. add sp,*$A
  385. !BCC_EOS
  386. ! 127 print("Current table: ");
  387. ! Debug: list * char = .7+0 (used reg = )
  388. mov bx,#.7
  389. push bx
  390. ! Debug: func () void = print+0 (used reg = )
  391. call _print
  392. inc sp
  393. inc sp
  394. !BCC_EOS
  395. ! 128 print_newline();
  396. ! Debug: func () void = print_newline+0 (used reg = )
  397. call _print_newline
  398. !BCC_EOS
  399. ! 129 print_stack(current_table.entries[0].filename);
  400. ! Debug: list * char current_table = S+$2310-$2208 (used reg = )
  401. lea bx,-$2206[bp]
  402. push bx
  403. ! Debug: func () void = print_stack+0 (used reg = )
  404. call _print_stack
  405. inc sp
  406. inc sp
  407. !BCC_EOS
  408. ! 130 print_newline();
  409. ! Debug: func () void = print_newline+0 (used reg = )
  410. call _print_newline
  411. !BCC_EOS
  412. ! 131 print_stack(current_table.entries[1].filename);
  413. ! Debug: list * char current_table = S+$2310-$2008 (used reg = )
  414. lea bx,-$2006[bp]
  415. push bx
  416. ! Debug: func () void = print_stack+0 (used reg = )
  417. call _print_stack
  418. inc sp
  419. inc sp
  420. !BCC_EOS
  421. ! 132 print_newline();
  422. ! Debug: func () void = print_newline+0 (used reg = )
  423. call _print_newline
  424. !BCC_EOS
  425. ! 133 print_stack(current_table.entries[2].filename);
  426. ! Debug: list * char current_table = S+$2310-$1E08 (used reg = )
  427. lea bx,-$1E06[bp]
  428. push bx
  429. ! Debug: func () void = print_stack+0 (used reg = )
  430. call _print_stack
  431. inc sp
  432. inc sp
  433. !BCC_EOS
  434. ! 134 print_newline();
  435. ! Debug: func () void = print_newline+0 (used reg = )
  436. call _print_newline
  437. !BCC_EOS
  438. ! 135 } break;
  439. jmp .1
  440. !BCC_EOS
  441. ! 136 case SERIVCE_READ_DATA:
  442. ! 137 {
  443. .8:
  444. ! 138 print("Hit READ case");
  445. ! Debug: list * char = .9+0 (used reg = )
  446. mov bx,#.9
  447. push bx
  448. ! Debug: func () void = print+0 (used reg = )
  449. call _print
  450. inc sp
  451. inc sp
  452. !BCC_EOS
  453. ! 139 } break;
  454. jmp .1
  455. !BCC_EOS
  456. ! 140 case SERIVCE_WRITE_DATA:
  457. ! 141 {
  458. .A:
  459. ! 142 print("Hit WRITE case");
  460. ! Debug: list * char = .B+0 (used reg = )
  461. mov bx,#.B
  462. push bx
  463. ! Debug: func () void = print+0 (used reg = )
  464. call _print
  465. inc sp
  466. inc sp
  467. !BCC_EOS
  468. ! 143 } break;
  469. jmp .1
  470. !BCC_EOS
  471. ! 144 default:
  472. ! 145 {
  473. .C:
  474. ! 146 print("Default case");
  475. ! Debug: list * char = .D+0 (used reg = )
  476. mov bx,#.D
  477. push bx
  478. ! Debug: func () void = print+0 (used reg = )
  479. call _print
  480. inc sp
  481. inc sp
  482. !BCC_EOS
  483. ! 147 }
  484. ! 148 }
  485. ! 149
  486. ! 150 return 0;
  487. jmp .1
  488. .3:
  489. sub ax,*1
  490. beq .4
  491. sub ax,*1
  492. beq .6
  493. sub ax,*1
  494. je .8
  495. sub ax,*1
  496. je .A
  497. jmp .C
  498. .1:
  499. ..FFFF = -$2310
  500. xor ax,ax
  501. lea sp,-4[bp]
  502. pop si
  503. pop di
  504. pop bp
  505. ret
  506. !BCC_EOS
  507. ! 151
  508. ! 152 }
  509. ! 153 # 157
  510. ! 157 void print(string)
  511. ! Register BX used in function main
  512. ! 158 char* string;
  513. export _print
  514. _print:
  515. !BCC_EOS
  516. ! 159 {
  517. ! 160 #asm
  518. !BCC_ASM
  519. _print.string set 2
  520. push bp
  521. mov bp,sp
  522. mov si,4[bp]
  523. call 0x0000:0x7C47
  524. pop bp
  525. ! 166 endasm
  526. !BCC_ENDASM
  527. ! 167 }
  528. ret
  529. ! 168
  530. ! 169 void print_stack(argument)
  531. ! 170 {
  532. export _print_stack
  533. _print_stack:
  534. ! 171 #asm
  535. !BCC_ASM
  536. _print_stack.argument set 2
  537. push bp
  538. mov bp,sp
  539. push ds
  540. push ax
  541. mov ax, ss
  542. mov ds, ax
  543. mov si,4[bp]
  544. call 0x0000:0x7C47
  545. pop ax
  546. pop ds
  547. pop bp
  548. ! 185 endasm
  549. !BCC_ENDASM
  550. ! 186 }
  551. ret
  552. ! 187
  553. ! 188 dump_ax_return(input)
  554. ! 189 void* input;
  555. export _dump_ax_return
  556. _dump_ax_return:
  557. !BCC_EOS
  558. ! 190 {
  559. ! 191 return input;
  560. push bp
  561. mov bp,sp
  562. push di
  563. push si
  564. mov ax,4[bp]
  565. pop si
  566. pop di
  567. pop bp
  568. ret
  569. !BCC_EOS
  570. ! 192 }
  571. ! 193
  572. ! 194 void dump_ax(input)
  573. ! 195 void* input;
  574. export _dump_ax
  575. _dump_ax:
  576. !BCC_EOS
  577. ! 196 {
  578. ! 197
  579. ! 198 dump_ax_return(input)
  580. push bp
  581. mov bp,sp
  582. push di
  583. push si
  584. ! 199 #asm
  585. ! Debug: list * void input = [S+6+2] (used reg = )
  586. push 4[bp]
  587. ! Debug: func () int = dump_ax_return+0 (used reg = )
  588. call _dump_ax_return
  589. inc sp
  590. inc sp
  591. !BCC_EOS
  592. !BCC_ASM
  593. _dump_ax.input set 8
  594. .dump_ax.input set 4
  595. push bp
  596. mov bp,sp
  597. call 0x000:0x7C2A
  598. pop bp
  599. ! 204 endasm
  600. !BCC_ENDASM
  601. !BCC_EOS
  602. ! 205 }
  603. pop si
  604. pop di
  605. pop bp
  606. ret
  607. ! 206
  608. ! 207 void print_newline()
  609. ! 208 {
  610. export _print_newline
  611. _print_newline:
  612. ! 209 #asm
  613. !BCC_ASM
  614. printCRLF:
  615. mov ah, #0xE
  616. mov al, #13
  617. int #0x10
  618. mov al, #10
  619. int #0x10
  620. ret
  621. ! 217 endasm
  622. !BCC_ENDASM
  623. ! 218 # 217
  624. ! 217 }
  625. ret
  626. ! 218
  627. .D:
  628. .E:
  629. .ascii "Default case"
  630. .byte 0
  631. .B:
  632. .F:
  633. .ascii "Hit WRITE case"
  634. .byte 0
  635. .9:
  636. .10:
  637. .ascii "Hit READ case"
  638. .byte 0
  639. .7:
  640. .11:
  641. .ascii "Current table: "
  642. .byte 0
  643. .5:
  644. .12:
  645. .ascii "File System has been loaded: "
  646. .byte 0
  647. .bss
  648. .comm _selector,2
  649. .comm _number_low,2
  650. ! 0 errors detected