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.

579 lines
10 KiB

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