[net.micro.pc] Help with PCDOS problem

dmt@hocsl.UUCP (10/13/84)

HELP! I thank those who suggested [unsuccessful] fixes
to my problem, but they didn't work. I have now narrowed it down
to, "I must be doing something very stupid; somebody please
set me straight."

I now have an assembly language program whose entire script is:

abc	segment	common
xyz	proc
	assume	cs:abc,ds:abc
;
	int	20H	; don't do anything, just halt
;
xyz	endp
abc	ends
	end

If I run it under DEBUG, it terminates normally.
If I run it from a .BIN file (even right after a boot),
the system hangs.  It DOES compile OK, into the single
interrupt instruction.
I've done this on three different PCDOS machines, each
with its own system disk.  Same result each time.

Does anybody out there know what I'm forgetting?
Thanks in advance.
			Dave Tutelman

faisal@smu.UUCP (10/21/84)

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>

I now have an assembly language program whose entire script is:

abc	segment	common
xyz	proc
	assume	cs:abc,ds:abc
;
	int	20H	; don't do anything, just halt
;
xyz	endp
abc	ends
	end

If I run it under DEBUG, it terminates normally.
If I run it from a .BIN file (even right after a boot),
the system hangs.  It DOES compile OK, into the single
interrupt instruction.
I've done this on three different PCDOS machines, each
with its own system disk.  Same result each time.

Does anybody out there know what I'm forgetting?
Thanks in advance.
			Dave Tutelman

<><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><><>
Response:

Writing a one instruction program is a challenge.  Int 20h is not a legal one
instruction program.  The problem is that when DOS loads your program, it 
changes CS to locate your int 20h, the first instruct. of your program, at
CS:00; therefore, it MUST change CS.  The DOS manual states that "Every
program must ensure that the CS register contains the segment address of its
Program Segment Prefix control block prior to issuing INT X'20'."  In other
words you need to change CS back before the int 20h instruction executes.
There is NO way you can change your CS DIRECTLY, AND have the int 20h be the
next instruction, AND have the computer run this int 10h... no way (you have
to move things around and play tricks).  Why resort to tricks when you can
do it nicely and legally.

Use this as the code:

          push DS        ;save the segment of the PSP for this program
          xor ax,ax      ;put 0 in ax
          push ax        ;push this 0 on the stack on top of the PSP seg.
  
          . . .          ; put your code here

          ret far        ;return to the segment:offset specified by the words
                         ;  at [sp + 2]:[sp]

This code saves the address of the PSP for itself on the stack, and when it is
ready to terminate, it RETurns to this address, which happens to be the 
original CS:00.  Guess what's at this address: int 20h (the legal way).

Faisal Shah
MicroLab
CSE Dept.
SMU
Dallas, TX

gino@voder.UUCP (Gino Bloch) (10/27/84)

>> I now have an assembly language program whose entire script is:
>> abc	segment	common
>> xyz	proc
>> 	assume	cs:abc,ds:abc
>> ;
>> 	int	20H	; don't do anything, just halt
>> ;
>> xyz	endp
>> abc	ends
>> 	end
>> 
>> If I run it under DEBUG, it terminates normally.
>> If I run it from a .BIN file (even right after a boot),
>> the system hangs.
>> 			Dave Tutelman

>  BTW: Just because you say 'assume ds:someware' don't make it so,
>  and DOS does not set cs and ds correctly for .com files, you have
>  to do it.
>  Alan Fargusson.

First, in response to Alan Fargusson:
    From the IBM DOS Technical Manual Version 2.10, page 6-8:
	"For .COM Programs:
	    All four segment registers contain the segment address of the
	    initial allocation block, that starts with the Program Segment
	    Prefix control block"

Back to the original question.  Since you can't execute a .bin file, Dave,
I suspect you actually executed a .exe file that you had left lying around.
That will hang.  Try these five things (they just worked for me 5 minutes ago):
    1.  Assemble whatever
    2.  Run exe2bin on whatever
    3.  DELETE whatever.exe
    4.  RENAME whatever.bin to whatever.com
    5.  whatever
-- 
Gene E. Bloch (...!nsc!voder!gino)

ericr@hpvcla.UUCP (ericr) (10/28/84)

I didn't try this, but I believe that the lack of an explicit start 
point may be giving you trouble.  Change your 'end' statement to
'end xyz'.  This should set things straight.

alan@drivax.UUCP (10/31/84)

Well, if you read the fine print in the DOS manual it says that
CS must point to the Program Segment Prefix when you execute the
Int 20. The only way that I know to do that is:

	xor	ax,ax
	push	ax
	push	ds
	ret

BTW: Just because you say 'assume ds:someware' don't make it so,
and DOS does not set cs and ds correctly for .com files, you have
to do it.
-- 
---------------------
Alan Fargusson.

{ ihnp4, sftig, amdahl, ucscc, ucbvax!unisoft }!drivax!alan