TIP: Click on subject to list as thread! ANSI
echo: 80xxx
to: KURT WISMER
from: JERRY COFFIN
date: 1997-06-22 12:11:00
subject: problem with my code...

On (17 Jun 97) Kurt Wismer wrote to Jerry Coffin...
 JC> I see a couple of problems, though I'm not sure if they're
 JC> related to the symptoms you're seeing or not.
 KW> well the litmus test will be if the symptoms go away...
Well, I did some more looking at it, and actually did some testing on
the result this time.  It seems to produce a reasonable backup of a full
disk, though I haven't done extensive testing.  I've changed it over to
using simplified segment directives, though I don't think that made any
real difference; mostly it let me move the data declarations to the top
where I prefer them, and still have them at the end of the program where
they belong in the final image.
.model tiny, c
; DiskBack - generates an image of a floppy disk in a file (and parses
; out the empty space).
.stack
.data
file db 'diskback.img',0
.data?
buff db 202h dup(?)
.code
.startup
main proc
   mov dx, offset file      ;create file with filename in [dx]
   xor cx, cx               ;set file attributes = 00000000
   mov ah, 3ch              ;create function => int 21h, ah = 3ch
   int 21h                  ;returns handle of created file in ax
   mov di, ax               ;save handle
   mov dx, 0ffffh
arge:
   inc dx
   xor ax, ax
   mov bx, offset buff
   mov cx, 1
   int 25h
   pop si
   jc close                 ;close and exit on error
   mov si, bx
   mov cx, 100h
loop1:
   lodsw
   cmp ax, 0f6f6h
   loopz   loop1
   jz   arge
writ:
   push dx                  ;save sector index
   mov bx, offset buff + 200h
   mov [bx], dl
   mov [bx+1], dh
   mov bx, di               ;restore file handle
   mov dx, offset buff
   mov ah, 40h              ;write function => int 21h, ah = 40h
   mov cx, size buff        ; ****  write 200h (512) bytes
   int 21h                  ;writes 1 sector to the file with handle bx
   pop dx                   ;restore sector index
   jmp arge
close:
   mov bx, di               ;restore file handle
   mov ah, 3eh              ;close file => int 21h, ah = 3eh
   int 21h                  ;bx = file handle
   mov ax, 4c00h            ;exit program
   int 21h
main endp
        end
This should assemble to 89 bytes.  If you want to make it shorter, it's
safe to eliminate explicitly closing the file before exit, since DOS wil
do that automatically.  There ar probably other places bits can be
shaved off as well.  Then again, if you really want to use this, you'll
probably want to add some feedback to the user during operation, which
is likely to occupy almost as much space as the real guts of the
program...
    Later,
    Jerry.
... The Universe is a figment of its own imagination.
--- PPoint 1.90
---------------
* Origin: Point Pointedly Pointless (1:128/166.5)

SOURCE: echomail via exec-pc

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.