Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.asm.x86    |    Ahh, the lost art of x86 assembly    |    4,675 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 2,909 of 4,675    |
|    Kevin Mardoux to All    |
|    copy bytes in a file    |
|    04 Aug 17 01:45:25    |
      From: mardou2k@nospicedham.gmail.com               I try this it is OK               may be somebody have a better solution ?                     the file R1 containts bytes value A,a,B,b,C,c,D,d....       the file S2 contain 1,2,3,4,5,6... it is my table       The aim to have il file R1 with bytes A,1,B,2,C,3,D,4....              i use A86 8-16 bytes compilator       R2.COM is the name of this file              mov si,0080H ; how many Char after ?       lodsb        cmp al,0        jne suite        erreur: mov dx,offset usage        mov ah,9        int 21h ; indicate the syntax : to run type " R2 S2.DAT "        ret ; this file will open automatiquely the file R1.DAT              suite: cbw       xchg ax,bx       mov byte [bx+si],00 ; 0 Terminate       inc si ; mov si,0082H              mov ax,3d12H       mov dx,0082H ; adresse name S2.DAT i MUST tape it       int 21H       jb err82 ; can i open it ? jnc       the user MUST type de name of the file with data 1,2,3,4...              xchg ax,bx ; Handle       mov ah,3fH       mov cx,0FFFFh ; ; size max buffer       mov dx,offset table ; position file of S2.DAT       int 21H ; cmp ax,0000 ; JBE fermer       i suppose more than 0 byte to read       i suppose that datas of S2.DAT are on address Table              mov word VS2,ax ; just for information Verify S2       mov word ntest,ax ; True number of bytes to read in the TABLE S2.DAT       ntest is usefull : will count number of cycles       push bx ; i qave the handle of file S2.DAT              mov ax,3d12H ; i will write in this file       mov dx,offset S1R1 ; file R1.DAT       int 21H       jb err1 ; i verify : i have NO error : counter stay at 0              xchg ax,bx ; handle of R1.DAT in BX       mov ah,3fH ; read file R1       mov cx,0FFFFh ; test a large buffer       mov dx,offset table+30000 ; i suppose file S2 is less than 30k       int 21H ; ; S2.DAT begin at offset TABLE       jb err2 ; same no error              dec byte testok ; if no error before, i comme here              jmp short continue        ; this part count errors       err82: inc byte cerr82       jmp short continue       err1: inc byte cerr1       jmp short continue       err2: inc byte cerr2       continue:              tesbou: mov ax,4200H ; position file       inc word verify ; i come here number ?       word verify just a test > the counter indicate a good answer              xor cx,cx ; begin byte 0       confil: mov dx,1        ; i suppose i read the byte 1 of the file R1.DAT              the value of confil is BA 01 01 next BA 03 01 next BA 0501       if i do mov dx,offset table+30000 ; the size of the file grow              int 21H       i use a counter : BA 0101 BA 0301 BA 0501 "BA" is "mov dx"       mov ax, word confil+1 ; next step read the byte 1 +2 = 3       add ax,2       mov word confil+1,ax ; I prepare for the next test              mov ah,40H       mov cx,1 ; write 1 byte               conta: mov dx,offset table ; + 1 by test       int 21H        mov ax, word conta+1 ; i suppose i read the 1st byte        add ax,1 ; then i read the 2nd        mov word conta+1,ax ; then the 3rd        ; i use it like a counter              mov ax,word ntest ; i count the number of bytes in file S2.DAT       dec ax       zontest: mov word ntest,ax       cmp ax,0 ; byte to read ? yes do again       jnz tesbou ; no byte to read ; go away              mov dx,82H       fermer: mov ah,3eH ; i close S2.DAT       int 21H       pop bx       mov dx,offset S1R1 ; AH stay at value 3E       int 21H              part below only to register informations              jmp short openfil ; this part to verify              crefil: ; i register in a file errors a number of byte read       mov ah,3ch       mov dx,offset fildat       xor cx,cx ; attribute       int 21h ; if FIL.DAT do not exist, i have an error, but it don't care        ; the i have FIL.DAT size 0 ; second try fileexist, it is ok              openfil:       mov ax,3d12h       mov dx,offset fildat       int 21h       jb crefil       xchg ax,bx ; save the handle              mov ax,4202h ; handle in BX       xor cx,cx ; begin byte 0       xor dx,dx ; no offset       int 21h       jc erreur1              mov dx,ax       mov ax,4200h ;       xor cx,cx       int 21h              mov ah,40h ; write file ; BX keep same value       mov cx,16 ; write 16 bytes 1 line is easy to read       mov dx,offset verify       int 21h       jb erreur1              mov ah,3eh ; close ; mov bx,[offset] handle       int 21h       mov ah,09       mov dx,offset txt       int 21h       int 20h              txt db:       verify dw: ,0 ; count number of test "tesbou" ; 2 bytes       VS2 dw: ,0 ; number of byte read in S2.DAT       db: ,9 ; separator again 1 byte              cerr82 db: ,0 ; 1 B is the inkey correct ?       cerr1 db: ,0 ; 1 b about main file R1.DAT       cerr2 db: ,0 ; 1 b       testok db: ,0 ; if ok i read value FF       db: ,9       fildat db: "FIL.DAT",0,36 ; used for TXT error and History File       erreur1:       mov dx,offset fildat       mov ah,09       int 21h       int 20H              S1R1 db: "R1.DAT" ,0       ntest dw: ,0       usage db: "R2 S2.DAT" ,24H       table db:       ret              Best regards       Kevin              --- SoupGate-Win32 v1.05        * Origin: you cannot sedate... all the things you hate (1:229/2)    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca