Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 23.26 KB | None | 0 0
  1. ; multi-segment executable file template.
  2.  
  3. data segment
  4. name_contents db "c:\contents.bin", 0
  5.  
  6. string_menu_1 db "- Import Spreadsheet";length=20
  7. string_menu_2 db "- Show spreadsheet" ;length=18
  8. string_menu_3 db "- Edit spreadsheet" ;length=18
  9. string_menu_4 db "- Export spreadsheet";length=20
  10. string_menu_5 db "- About" ;length=7
  11. string_menu_6 db "- Exit" ;length=6
  12.  
  13. string_formula db "Formula"
  14. string_result db "Result"
  15. string_menu db "Menu"
  16.  
  17. str_buffer db 7, dup(0)
  18.  
  19. num_hcell dw 04h
  20. matrix_lenght dw 160 ;estava 240 antes
  21. matrix_height dw 65
  22. cell db 16 dup(-128)
  23. ;formula_lenght 88
  24. ends
  25.  
  26. stack segment
  27. dw 128 dup(0)
  28. ends
  29.  
  30. code segment
  31. start:
  32. ; set segment registers:
  33. mov ax, data
  34. mov ds, ax
  35. mov es, ax
  36.  
  37. ;open contents.bin
  38. call open_contents
  39.  
  40. draw_menu:
  41. ;iniciate video mode
  42. mov ah, 00h
  43. mov al, 13h
  44. int 10h
  45.  
  46. call menu
  47.  
  48. keep_checking_menu:
  49. mov ax, 03h
  50. int 33h
  51. shr cx, 1 ; x/2 - in this mode the value of CX is doubled.
  52. cmp bx, 1
  53. jnz keep_checking_menu
  54.  
  55. call checkMenu
  56.  
  57. cmp dh, 01h
  58. jne draw_menu
  59.  
  60.  
  61. ;saves contents.bin
  62. call save_contents
  63.  
  64. mov ax, 4c00h ; exit to operating system.
  65. int 21h
  66.  
  67. ;*****************************************************************
  68. ; menu -
  69. ; descricao: draws menu
  70. ; input -
  71. ; output -
  72. ; destroi -
  73. ;*****************************************************************
  74.  
  75. menu proc
  76. xor dh, dh
  77. mov al, 01h
  78. mov bh, 00h
  79. mov bl, 0Fh
  80. mov dl, 02h
  81.  
  82. mov cx, 14h;length of string_1
  83. mov bp, offset string_menu_1
  84.  
  85. imprime_string:
  86. inc dh
  87. inc dh ;next line
  88. push bx
  89.  
  90. xor bh, bh
  91. mov ah, 13h
  92. int 10h
  93.  
  94. pop bx
  95. inc bh ;next string
  96.  
  97. cmp bh, 02h
  98. je menu_2
  99.  
  100. cmp bh, 03h
  101. je menu_3
  102.  
  103. cmp bh, 04h
  104. je menu_4
  105.  
  106. cmp bh, 05h
  107. je menu_5
  108. ja end_of_menu
  109.  
  110. mov cx, 12h
  111. mov bp, offset string_menu_2
  112. jmp imprime_string
  113.  
  114. menu_2:
  115. mov bp, offset string_menu_3
  116. jmp imprime_string
  117.  
  118. menu_3:
  119. mov cx, 14h
  120. mov bp, offset string_menu_4
  121. jmp imprime_string
  122.  
  123. menu_4:
  124. mov cx, 07h
  125. mov bp, offset string_menu_5
  126. jmp imprime_string
  127.  
  128. menu_5:
  129. mov cx, 06h
  130. mov bp, offset string_menu_6
  131. jmp imprime_string
  132.  
  133. end_of_menu:
  134. ret
  135. menu endp
  136.  
  137. ;*****************************************************************
  138. ; checkMenu -
  139. ; descricao: checks position clicked on menu window
  140. ; input -
  141. ; output -
  142. ; destroi -
  143. ;*****************************************************************
  144.  
  145. checkMenu proc
  146. xor dh, dh
  147.  
  148. cmp cx, 13h ;left limit x
  149. jb done_checking_menu
  150. cmp cx, 178 ;right limit x
  151. ja done_checking_menu
  152. cmp dx, 12h ;superior limit y
  153. jb done_checking_menu
  154. cmp dx, 6Ch ;inferior limit y
  155. ja done_checking_menu
  156.  
  157. cmp dx, 1Bh ;test import
  158. ja test_show
  159. call import_spreadsheet
  160. jmp done_checking_menu
  161.  
  162. test_show:
  163. cmp dx, 2Bh
  164. ja test_edit
  165. call show_spreadsheet
  166. jmp done_checking_menu
  167.  
  168. test_edit:
  169. cmp dx, 3Bh
  170. ja test_export
  171. call edit_spreadsheet
  172. jmp done_checking_menu
  173.  
  174. test_export:
  175. cmp dx, 4Bh
  176. ja test_about
  177. call export_spreadsheet
  178. jmp done_checking_menu
  179.  
  180. test_about:
  181. cmp dx, 5Bh
  182. ja definitely_exit
  183. call show_about
  184. jmp done_checking_menu
  185.  
  186. definitely_exit:
  187. mov dh, 01h
  188.  
  189. done_checking_menu:
  190. ret
  191. checkMenu endp
  192.  
  193. ;*****************************************************************
  194. ; import_spreadsheet -
  195. ; descricao: importa um ficheiro .txt
  196. ; input -
  197. ; output -
  198. ; destroi -
  199. ;*****************************************************************
  200.  
  201. import_spreadsheet proc
  202. ret
  203. import_spreadsheet endp
  204.  
  205. ;*****************************************************************
  206. ; show_spreadsheet -
  207. ; descricao: mostra a spreadsheet em memoria
  208. ; input -
  209. ; output -
  210. ; destroi -
  211. ;*****************************************************************
  212.  
  213. show_spreadsheet proc
  214. ;reiniciate video mode to clear window
  215. mov ah, 00h
  216. mov al, 13h
  217. int 10h
  218.  
  219. ret
  220. show_spreadsheet endp
  221.  
  222. ;*****************************************************************
  223. ; edit_spreadsheet -
  224. ; descricao: mostre e permite editar a spreadsheet em memoria
  225. ; input -
  226. ; output -
  227. ; destroi -
  228. ;*****************************************************************
  229.  
  230. edit_spreadsheet proc
  231. ;reiniciate video mode to clear window
  232. mov ah, 00h
  233. mov al, 13h
  234. int 10h
  235.  
  236. ;draw spreadsheet
  237. call createMatrix
  238.  
  239. call createMenuBox
  240.  
  241. call createFormulaBox
  242.  
  243. call createResultBox
  244.  
  245. call showLetters
  246.  
  247. call showNumbers
  248.  
  249. mov ax, 00h
  250. int 33h
  251.  
  252. ;wait for user input
  253. keep_checking:
  254. mov ax, 03h
  255. int 33h
  256. shr cx, 1 ; x/2 - in this mode the value of CX is doubled.
  257. cmp bx, 1
  258. jnz keep_checking
  259.  
  260. call cANDeCell ;check and evaluate cell
  261.  
  262. ;Preisamos agora de uma funcao para avaliar a celula que foi clicada
  263. ;ja temos toda a informacao necessaria
  264. ;devo meter AL para a dizer se a celula e valida
  265. ;e AH para dizer o tipo de celula
  266.  
  267. cmp bx, 1 ;exit to MENU
  268. jne keep_checking
  269.  
  270. ret
  271. edit_spreadsheet endp
  272.  
  273. ;*****************************************************************
  274. ; export_spreadsheet -
  275. ; descricao: exporta para um ficheiro .txt a funcao em memoria
  276. ; input -
  277. ; output -
  278. ; destroi -
  279. ;*****************************************************************
  280.  
  281. export_spreadsheet proc
  282. ret
  283. export_spreadsheet endp
  284.  
  285. ;*****************************************************************
  286. ; show_about -
  287. ; descricao: mostra certas informacoes sobre os criadores
  288. ; input -
  289. ; output -
  290. ; destroi -
  291. ;*****************************************************************
  292.  
  293. show_about proc
  294. ;reiniciate video mode to clear window
  295. mov ah, 00h
  296. mov al, 13h
  297. int 10h
  298.  
  299. ret
  300. show_about endp
  301.  
  302. ;*****************************************************************
  303. ; hLine -
  304. ; descricao: creates horizontal lines for the matrix
  305. ; input - bx= numero de linhas ; cx = horizontal margin ; dx = vertical margin ; ax = line lenght
  306. ; output -
  307. ; destroi -
  308. ;*****************************************************************
  309.  
  310. hLine proc
  311.  
  312. n_hlines:
  313. push ax
  314. push cx
  315.  
  316. h_change_pixel:
  317. push ax
  318. mov ah, 0Ch
  319. mov al, 0Fh
  320. int 10h
  321.  
  322. pop ax
  323. dec ax
  324. jz h_done
  325. inc cx
  326. jmp h_change_pixel
  327.  
  328. h_done:
  329. pop cx
  330. pop ax
  331. add dx, 16
  332. dec bx
  333. jnz n_hlines
  334.  
  335. ret
  336. hLine endp
  337.  
  338.  
  339. ;*****************************************************************
  340. ; vLine -
  341. ; descricao: creates vertical lines for the matrix
  342. ; input - bx= numero de linhas ; cx = horizontal margin ; dx = vertical margin ; ax = matrix_height
  343. ; output -
  344. ; destroi -
  345. ;*****************************************************************
  346.  
  347. vLine proc
  348.  
  349. n_vlines:
  350. push ax
  351. push dx
  352.  
  353. v_change_pixel:
  354. push ax
  355. mov ah, 0Ch
  356. mov al, 0Fh
  357. int 10h
  358.  
  359. pop ax
  360. dec ax
  361. jz v_done
  362. inc dx
  363. jmp v_change_pixel
  364.  
  365. v_done:
  366. pop dx
  367. pop ax
  368. add cx, 40
  369. dec bx
  370. jnz n_vlines
  371.  
  372. ret
  373. vLine endp
  374.  
  375.  
  376.  
  377. ;*****************************************************************
  378. ; createMatrix -
  379. ; descricao: creates horizontal lines for the matrix
  380. ; input - bx= numero de linhas ; cx = horizontal margin ; dx = vertical margin ; ax = line lenght
  381. ; output -
  382. ; destroi -
  383. ;*****************************************************************
  384.  
  385. createMatrix proc
  386. mov bx, 05h ; se calhar temos de remover isto
  387. mov dx, 28
  388. mov cx, 20
  389. mov ax, matrix_lenght
  390. call hLine
  391.  
  392. mov bx, 05h
  393. mov cx, 20
  394. mov dx, 28
  395. mov ax, matrix_height
  396. call vLine
  397.  
  398. ret
  399.  
  400. createMatrix endp
  401.  
  402. ;*****************************************************************
  403. ; createMatrix -
  404. ; descricao: creates horizontal lines for the matrix
  405. ; input - bx= numero de linhas ; cx = horizontal margin ; dx = vertical margin ; ax = line lenght
  406. ; output -
  407. ; destroi -
  408. ;*****************************************************************
  409.  
  410.  
  411. createMenuBox proc
  412.  
  413. mov bx, 2
  414. mov ax, 40
  415. mov cx, 20
  416. mov dx, 156
  417. call hLine
  418.  
  419. mov bx, 2
  420. mov ax, 17
  421. mov cx, 20
  422. mov dx, 156
  423. call vLine
  424.  
  425. ;writes "Menu" inside the cell
  426. mov al, 1
  427. mov bl, 0Fh
  428. mov cx, 4 ;string lenght
  429. mov dh, 20
  430. mov dl, 3
  431. mov ah, 13h
  432. mov bp, offset string_menu
  433. int 10h
  434.  
  435. ret
  436.  
  437. createMenuBox endp
  438.  
  439. ;*****************************************************************
  440. ; createFormulaBox -
  441. ; descricao: creates a box where the user will input operations
  442. ; input -
  443. ; output -
  444. ; destroi -
  445. ;*****************************************************************
  446.  
  447. createFormulaBox proc ;Provavelmente vamos ter de alterar o
  448. ;tamanho da caixa da formula
  449.  
  450. mov ax, 80 ; formula lenght
  451. mov cx, 20
  452. mov dx, 124
  453. mov bx, 02h
  454. call hLine
  455.  
  456. mov ax, 17 ; formula height + 1
  457. mov cx, 20
  458. mov dx, 124
  459. mov bx, 01h
  460. call vLine
  461.  
  462. mov ax, 17 ; formula height + 1
  463. mov cx, 100
  464. mov dx, 124
  465. mov bx, 01h
  466. call vLine
  467.  
  468. ret
  469.  
  470. createFormulaBox endp
  471.  
  472.  
  473. ;*****************************************************************
  474. ; createResultBox -
  475. ; descricao: creates a box to output the result
  476. ; input -
  477. ; output -
  478. ; destroi -
  479. ;*****************************************************************
  480.  
  481. createResultBox proc
  482.  
  483. mov ax, 80 ;cell lenght
  484. mov cx, 140
  485. mov dx, 124
  486. mov bx, 02h
  487. call hLine
  488.  
  489. mov ax, 17 ; formula height + 1
  490. mov cx, 140
  491. mov dx, 124
  492. mov bx, 01h
  493. call vLine
  494.  
  495. mov ax, 17 ; formula height + 1
  496. mov cx, 220
  497. mov dx, 124
  498. mov bx, 01h
  499. call vLine
  500.  
  501. ret
  502.  
  503. createResultBox endp
  504.  
  505. ;*****************************************************************
  506. ; showLetter -
  507. ; descricao: prints a letter for each matrix collumn,
  508. ; also prints "Formula" and "Result"
  509. ; input -
  510. ; output -
  511. ; destroi -
  512. ;*****************************************************************
  513.  
  514. showLetters proc
  515.  
  516. xor bh, bh
  517. mov bl, 0Fh
  518. mov cx, 1
  519. mov dl, 04
  520. mov al, 'A'
  521.  
  522. new_letter:
  523. ;set cursor position
  524. mov dh, 02h
  525. mov ah, 02h
  526. int 10h
  527.  
  528. ;write char at cursor position
  529. mov ah, 09h
  530. int 10h
  531.  
  532. inc al
  533. add dl, 5
  534. cmp al, 'E'
  535. jnz new_letter
  536.  
  537. ;writes "Formula" above the big cell
  538. mov al, 1
  539. mov bl, 0Fh
  540. mov cx, 7 ;string lenght
  541. mov dh, 14
  542. mov dl, 3
  543. mov ah, 13h
  544. mov bp, offset string_formula
  545. int 10h
  546.  
  547. ;writes "Result" aove the small cell
  548. mov dl, 18
  549. mov cx, 6 ;string lenght deve ser 6
  550. mov bp, offset string_result
  551. int 10h
  552.  
  553. ret
  554.  
  555. showLetters endp
  556.  
  557. ;*****************************************************************
  558. ; showNumbers -
  559. ; descricao: prints a number for each matrix row
  560. ; input -
  561. ; output -
  562. ; destroi -
  563. ;*****************************************************************
  564.  
  565. showNumbers proc
  566.  
  567. xor bh, bh
  568. mov bl, 0Fh
  569. mov cx, 1
  570. mov dh, 04h
  571. mov al, '1'
  572.  
  573. new_number:
  574. ;set cursor position
  575. mov dl, 01h
  576. mov ah, 02h
  577. int 10h
  578.  
  579. ;write char at cursor position
  580. mov ah, 09h
  581. int 10h
  582.  
  583. inc al
  584. add dh, 2
  585. cmp al, '5'
  586. jnz new_number
  587.  
  588. ret
  589.  
  590. showNumbers endp
  591.  
  592.  
  593.  
  594. ;*****************************************************************
  595. ; checkCell -
  596. ; descricao: checks and eveluates what to do with the cell clicked by the user
  597. ; input -
  598. ; output - bx=0(exit to menu)
  599. ; destroi -
  600. ;*****************************************************************
  601.  
  602. cANDeCell proc
  603.  
  604. xor bx, bx ;nao sei se isto e preciso, tem a ver com um racicionio que ja nao me lembro
  605.  
  606. ;check if user clicked on the margin
  607.  
  608. cmp cx, 20
  609. jb done_checking
  610. cmp dx, 28
  611. jb done_checking
  612.  
  613. mov ax, cx
  614. sub ax, 20
  615.  
  616. mov bx, 40
  617. div bl
  618. xor ah, ah ;sabemos agora a celula das letras
  619. mov cx, ax ;o resultado esta em cx
  620.  
  621. mov ax, dx
  622. sub ax, 28
  623.  
  624. mov bx, 16
  625. div bl
  626. xor ah, ah
  627. mov dx, ax ;coordonates are now stored in cx(x) and dx(y)
  628.  
  629. ;check if user clicked on a matrix cell
  630.  
  631. cmp cx, 3
  632. ja not_matrix
  633. cmp dx, 3
  634. ja not_matrix
  635. call matrixCellClicked ;a celula clicada foi uma da matriz descrita por cx e dx
  636. jmp done_checking
  637.  
  638. ;check if user clicked on the formula or result cell
  639. not_matrix:
  640. cmp dx, 6
  641. jnz not_fORr
  642. cmp cx, 1
  643. ja not_formula
  644. ;a celula clicada e a celula da formula
  645. jmp done_checking
  646.  
  647. not_formula:
  648. cmp cx, 3
  649. jnz not_fORr
  650. cmp cx, 4
  651. jnz not_fORr
  652. ;a celula clicada e a celula do resultado
  653. jmp done_checking
  654.  
  655. not_fORr:
  656. ;check if used clicked on MENU
  657. cmp dx, 8 ;esta na linha do menu
  658. jnz done_checking
  659. cmp cx, 0
  660. jnz done_checking
  661. mov bx, 1
  662. done_checking:
  663.  
  664. ret
  665. cANDeCell endp
  666.  
  667.  
  668. ;*****************************************************************
  669. ; matrixCellClicked -
  670. ; descricao: edit clicked cell
  671. ; input -
  672. ; output -
  673. ; destroi -
  674. ;*****************************************************************
  675.  
  676. matrixCellClicked proc
  677.  
  678. ;meter o cursor no sitio certo
  679. push cx
  680. push dx
  681.  
  682. mov al, 05h ;multiplo necessario
  683. mul cl ;multiplicar a celula pelo multiplo de posicao
  684. add al, 03h ;somar a constante de deslocamento incial
  685. mov bl, al ;adquirir a posicao em x do cursor
  686.  
  687. mov al, 02h ;a mesma coisa mas para o
  688. mul dl ;eixo do y
  689. add al, 04h
  690.  
  691. mov dl, bl ;from cx
  692. mov dh, al ;from dx
  693.  
  694. push dx
  695.  
  696. xor bx, bx
  697.  
  698. mov ah, 02h
  699. int 10h
  700.  
  701. mov ch, 06h
  702. mov cl, 0000_1111b
  703. mov ah, 01h
  704. int 10h
  705.  
  706. ;modificacoes comecam aqui
  707. mov dx, offset str_buffer
  708. mov ah, 0Ah
  709. int 21h
  710.  
  711. ;se o buffer estiver todo cheio entao o utilizador meteu mal os numeros
  712. ;falta fazer essa comparacao
  713.  
  714. pop dx
  715.  
  716. call evaluateInput ;ficamos com o valor em decimal no registo bx
  717.  
  718. pop dx
  719. pop cx
  720.  
  721. push bx
  722. xor bx, bx
  723. mov al, 4
  724. mul cl
  725.  
  726. mov bl, al
  727. add bx, dx
  728. pop cx
  729. mov cell[bx], cl
  730.  
  731. ret
  732. matrixCellClicked endp
  733.  
  734.  
  735. ;*****************************************************************
  736. ; evaluateInput -
  737. ; descricao: checks if input is valid, startes checking from the last number
  738. ; input - DL,DH = column, row at which to start writing
  739. ; output -
  740. ; destroi -
  741. ;*****************************************************************
  742.  
  743. evaluateInput proc
  744.  
  745. xor bx, bx
  746. mov bl, str_buffer[1]
  747. ;mov buffer[bx + 2], '$'
  748. cmp bl, 4
  749. ja invalid_input
  750. mov si, bx
  751.  
  752. check_input:
  753. dec si
  754. cmp si, -1
  755. jz input_checked
  756. cmp si, 0
  757. jnz check_char
  758. cmp ch, '-'
  759. jz negative_num
  760. mov ax, 0
  761.  
  762. check_char:
  763. mov ch, str_buffer[si + 2]
  764. cmp ch, '0'
  765. jb invalid_input
  766. cmp ch, '9'
  767. ja invalid_input
  768. jmp check_input
  769.  
  770. negative_num:
  771. mov ax, 1
  772. input_checked:
  773. ;push ax
  774. ;mov al, 1
  775. ;xor bh, bh
  776. ;mov cx, bx ;string lenght was in bl
  777. ;mov bl, 0Fh
  778. ;mov bp, offset str_buffer
  779. ;add bp, 2
  780. ;int 10h
  781.  
  782. ;pop ax
  783. call asciiToDecimal ;ficamos com o valor em decimal no registo bx
  784.  
  785. invalid_input:
  786. ret
  787.  
  788. evaluateInput endp
  789.  
  790.  
  791. ;*****************************************************************
  792. ; asciiToDecimal -
  793. ; descricao:
  794. ; input - ax = 1 if number is negative, ax = 0 if number is positive
  795. ; output - bx = numero para guardar
  796. ; destroi -
  797. ;*****************************************************************
  798.  
  799. asciiToDecimal proc
  800.  
  801. push ax
  802. xor ax, ax
  803. xor bx, bx
  804. xor ch, ch
  805. mov cl, str_buffer[1]
  806. mov si, cx
  807. mov al, 1
  808. mov dl, 10
  809. next_number:
  810. dec si
  811. cmp si, 0
  812. jz last_char
  813. push ax ;isto deve dar erro porque eu acho que so queria al
  814. mov dh, str_buffer[si + 2]
  815. sub dh, '0'
  816. mul dh
  817. add bx, ax ;o numero esta no bx
  818.  
  819. pop ax
  820. mul dl
  821.  
  822. jmp next_number
  823. last_char:
  824. pop cx
  825. cmp cx, 1 ;verificar se o numero e negativo ou nao
  826. jnz pos_num
  827. neg bx
  828. jmp ascii_dec_done:
  829. pos_num:
  830. ;mul dl ;para meter o ax com o multiplo correcto
  831. mov dh, str_buffer[2]
  832. sub dh, '0'
  833. mul dh
  834. add bx, ax
  835.  
  836. ascii_dec_done:
  837. ret
  838. asciiToDecimal endp
  839.  
  840. ;*****************************************************************
  841. ; fopen -
  842. ; descricao: abre um ficheiro em modo read(al==0), write(al==1) ou append(al==2)
  843. ; input - dx=offset nome ficheiro
  844. ; output - ax=file_handle
  845. ; destroi -
  846. ;*****************************************************************
  847.  
  848. fopen proc
  849. mov ah, 3Dh
  850. mov al, 02h
  851. mov cx, 00h
  852. int 21h
  853.  
  854. ret
  855. fopen endp
  856.  
  857. ;*****************************************************************
  858. ; fclose -
  859. ; descricao:
  860. ; input - bx= file handle
  861. ; output -
  862. ; destroi -
  863. ;*****************************************************************
  864.  
  865. fclose proc
  866. mov ah, 3Eh
  867. int 21h
  868.  
  869. ret
  870. fclose endp
  871.  
  872. ;*****************************************************************
  873. ; fcreate -
  874. ; descricao: cria um ficheiro
  875. ; input - dx=offset nome ficheiro
  876. ; output - ax=file_handle
  877. ; destroi -
  878. ;*****************************************************************
  879.  
  880. fcreate proc
  881. mov ah, 3Ch
  882. mov cx, 00h
  883. int 21h
  884.  
  885. ret
  886. fcreate endp
  887.  
  888. ;*****************************************************************
  889. ; save_contents -
  890. ; descricao: saves contents.bin or creates it
  891. ; input -
  892. ; output -
  893. ; destroi -
  894. ;*****************************************************************
  895.  
  896. save_contents proc
  897. ;tries to open file
  898. mov dx, offset name_contents
  899. call fopen
  900. jnc save
  901.  
  902. ;in case it doesn't exist, creates it
  903. call fcreate
  904.  
  905. save:
  906. mov bx, ax ;move handle
  907.  
  908. mov cx, 16 ;number of bytes
  909. mov dx, offset cell ;offset to write to
  910. mov ah, 40h
  911. int 21h
  912.  
  913. ;closes file
  914. call fclose
  915.  
  916. ret
  917. save_contents endp
  918.  
  919. ;*****************************************************************
  920. ; open_contents -
  921. ; descricao: opens contents.bin if it exists
  922. ; input -
  923. ; output -
  924. ; destroi - tudo
  925. ;*****************************************************************
  926.  
  927. open_contents proc
  928. ;tries to open file
  929. mov dx, offset name_contents
  930. call fopen
  931. jc end_open_cont ;in case it doesn't exist yet
  932.  
  933. mov bx, ax
  934.  
  935. mov cx, 16 ;number of bytes
  936. mov dx, offset cell ;offset to write to
  937. mov ah, 3Fh
  938. int 21h
  939.  
  940. call fclose
  941. end_open_cont:
  942. ret
  943. open_contents endp
  944.  
  945. ends
  946.  
  947. end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement