[ q3dalibor @ 14.04.2011. 10:02 ] @
pocheo sam nedavno da uchim assembly i ne uspevam da pristupim fajlu na hard disku mozda koristim pogreshne DOS funkcije ili neshto nisam odradio kako treba probao sam sa: INT 21,3D Open file using handle INT 21,40 Write file or device using handle ali nisam bash siguran da je to pravi nachin code izgleda ovako i treba da ispishe sve kombinacije velikih slova od 1 i 2 karaktera ali hteo bi da output programa zapishem u fajl ------------------------------------------------------------------------------- [BITS 16]-----------------------------;Set code generation to 16 bit mode [ORG 0x0100]------------------------;Set code start address to 0100h [SEGMENT .text]---------------------;Main code segment start: __mov bh,[dali]-----------------------;load value of dali to register bh __inc bh-------------------------------;increase the value of reg bh by 1 __cmp bh,05bh-----------------------;o5bh is the hex value of letter Z+1 __jz loop1-----------------------------;if it goes above Z goto loop1 __mov [dali],bh-----------------------;if not continue the loop __call output--------------------------;print the value of dali __jmp start---------------------------;go to the start loop1: __mov al,040h-----------------------;when dali reaches Z it needs to reset __mov [dali],al __call check1------------------------ ;checking of the value of dali1 loop11: __inc bh-------------------------------;increase bl by 1 __cmp bh,05bh-----------------------;compare with hex value of Z+1 __jz end-------------------------------;in case Z is sorpassed end it __mov [dali1],bh---------------------;otherwise move the increased value to dali1 __jmp start---------------------------;and continue END: __call end check1: __mov bh,[dali1]---------------------;load dali1 into bl for comparison __cmp bh,040h-----------------------;compare bl with hex value @ __jae loop11--------------------------;if the value of bl - 040h is >= zero jump back __mov bh,040h-----------------------;if its <0 then make bl 040h __ret output: __;call cls __;call locate __mov dx,dali1 __call print __call write __mov dx,dali __call print __call write __call CRLF __ret CRLF: __mov dx,crlf __call print __ret print: __mov ah,9 __int 21h __ret write: __call openfile __mov ah,40h __mov bx,myfile __mov cx,2 __int 21h __ret openfile: __mov ah,3dh---------------------;open file? __mov al,02h----------------------;read/write mode? __mov dx,myfile __int 21h __ret locate: __mov ah,02h __mov bh,0 __mov dl,10 __mov dh,3 __int 10h __ret cls: __mov ax,0600h __mov bh,07h __mov cx,0 __mov dx,0314fh __int 10h __ret end: __mov ah, 04ch __int 21h [SEGMENT .data]------------------------------------------ ;Initialised data segment __dali db 040h, "$"-----------------------------------------; last char __dali1 db 020h, "$"----------------------------------------; 2nd last char __crlf db 0dh,0ah, "$"--------------------------------------; end of line __myfile db "c:\asm\myfile.txt",0h---------------------; file location ------------------------------------------------------------------------------------------------ da li je moguce pisati u fajl na ovaj nachin i kako? ako nije, koju DOS funkciju da koristim? hvala unapred [Ovu poruku je menjao q3dalibor dana 14.04.2011. u 11:25 GMT+1] [Ovu poruku je menjao q3dalibor dana 14.04.2011. u 11:32 GMT+1] [Ovu poruku je menjao q3dalibor dana 14.04.2011. u 11:32 GMT+1] |