From: Ed Beroset
Subject: Re: Fire effect 1/2
At 16:42 1/2/98, you wrote:
>
> -=> Quoting Ed Beroset to All <=-
>
>Hey there!
>
> EB> Here it is a bit smaller:
>Thanks for having a fiddle with it =)
>
> EB> ; changed to TASM/MASM syntax, created some subroutines, and
> EB> generally ; tightened things to shave it to 222 bytes.
>Ok, I compiled it again, with TASM v3.1 and TLINK v7.00 and it was 226 bytes
>:(
>Hmm.. Did you use some command line parameters I should know about?
Yes. Try tasm /la /m6 fire.asm. The /la creates a listing file (which is
useful for spotting problems) and the /m6 tells tasm to run in multipass
mode -- up to six passes through, although it probably needs only two in
this case.
>And just a few questions!
>
> EB> stksize = 200h
> EB> start proc
> EB> ; move stack pointer
> EB> stkend = (stkptr - start) + stksize + 100h
> EB> mov sp, stkend
> EB> ; resize block so we can allocate some memory
> EB> mov bx, (stkend + 100h) / 10h
> EB> mov ah, 4ah
> EB> int 21h
>Ok, firstly, you've got stkend + 100h, but you also added 100h to stkend
>previously. Should that be there?
No. You've spotted an error. That second +100 should be replaced with a
+0Fh.
>Also, I don't quite follow what you've
>done. I understand that one has to resize the amount of memory allocated to
>your program to the size of all your code. But do you have to actually
>allocate
>the size of your code minus the size of your stack? And how come you
hanged
>sp?
When the program starts, SS = CS = DS and SP = 0FFFEh (a zero has already
been pushed onto the stack.) Since we're resizing memory and making it
smaller, the stack is suddenly outside our allocated memory block. Then,
when we do the memory allocations next, since the OS now thinks that space
is free, we might very well get the stack pointer pointing to one of our
data buffers! Clearly, this is a disaster waiting to happen. Better is to
resize the memory to include both code and stack, and then adjust SP.
> EB> mov si,di
> EB> sub si,320
> EB> mov bl, [di]
> EB> mov ax, bx
> EB> mov bl, [si] ; di-320
>How come you did it this way? I checked in Turbo Debugger, and mov bl,
>[di-320]
>was smaller than what you've done here.
That's correct. However, if you look farther down in the code, you'll see
that I used [si] instead of [di-320] a total of three times. The
instructions to load si takes six bytes, but each use saves two bytes, so
it's a wash.
>Ok, I think that's about it for now :)
>Oh, one last thing, do you get FidoNet mail through email or something?
No, I'm afraid not. I have no FidoNet address anymore -- only internet.
That address is beroset@mindspring.com.
Ed
-!-
---
---------------
* Origin: The Circuit! Board * Spokane * (1:346/100)
|