home bbs files messages ]

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,925 of 4,675   
   Frank Kotler to Kevin Mardoux   
   Re: copy bytes in a file   
   14 Aug 17 19:01:10   
   
   From: fbkotler@nospicedham.myfairpoint.net   
      
   Kevin Mardoux wrote:   
    > Hello, to day : i add :   
    > You propose to reserve a buffer for each file, then save the total   
   result in one time, or buffer   
    > ... instead of recording byte by byte   
    > Can someone give me an example?   
      
   I haven't used DOS for a long time, and A86 for even longer.   
      
    > I confirm: byte 0 and all unaltered even bytes  (Byte=2n) so   
   0,2,4,6,8,10,12...   
    > Bytes 1, 3 and all odd ones are replaced  B=2n+1)  : 1,3,5,7,9,11,13 ...   
      
   What I had in mind was roughly...   
      
    >> 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   
      
   mov dat_len, ax   
      
   mov si, offset table   
   mov di, offset table + 30000   
   xor cx, cx   
   xor dx, dx   
   top:   
   inc di   
   movsb   
   inc dx   
   add cx, 2   
   cmp dx, ntest   
   ja ??? ; if we run out of source first, start over?   
   cmp cx, dat_len   
   ja done ;?   
   jmp top   
   done:   
    seek back to beginning of "dest" file, handle still in bx   
    write buffer at "table + 30000", dat_len bytes   
      
   That's untested, and probably not correct syntax for A86, but something   
   along those lines...   
      
   Best,   
   Frank   
      
   --- 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