You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

586 lines
10 KiB

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