|
Prev: HLA external symbols without headers
Next: [OT] there is no assembly without good food and drink :))
From: almas on 14 Apr 2008 17:40 Hello. I ofen need help... but, this day, i built a COm alone. The aim : Open a file, modify bytes, write it in an other file. Now, i just write 256 bytes, just for test. Next step : modify particular Ascii. Then use largers files. Below, my usefull code. If you have betters methods, , sure i will apprecate. Best Regards Almas mov ax, 3D12h mov dx, offset input int 21h mov offset handle1, ax mov bx, [offset handle1] ; A86 need this syntax ! mov ah, 3Fh mov cx,100h ; read 256 Bytes mov dx, offset address ; buffer int 21h cmp ax,0 ; End of File ? ja continue int 20h continue: mov cx,ax ; Nbr of bytes usefull if less than 256 mov offset size_byte, ax ; rescue the size mov si, offset address ; change bytes in buffer mloop: add byte [si],20h inc si ; modify here... loop mloop jmp short do_it creat_fil: mov ah,3Ch mov dx,offset output xor cx,cx ; attrib int 21h do_it: mov ax,3D01h ; Open for Write mov dx, offset output int 21h jb creat_fil ; if not exist mov offset handle2,ax mov bx, [offset handle2] mov ax,4202h xor cx,cx xor dx,dx ; BX keeps same value int 21h ; mov dx,ax ; size, give an offset xor dx,dx ; begin a byte 0 mov ax,4200h xor cx,cx int 21h mov ah,40h mov cx, [offset size_byte] mov dx, offset address int 21h mov ah,3Eh int 21h ; BX keep value Handle2 mov bx, [offset handle1] ; close first file mov ah, 3Eh int 21h int 20h ; data ----------- size_byte db: ,0,0,0,0 input db: "FILE.IN" ,0 output db: "FILE.OUT" ,0 handle1 db: ,0,0,0,0 handle2 db: ,0,0,0,0 address: db: ,0,0,0,0,0,0 |