1

the following script works fine if I type it line-by-line in debug. When I copy it to a file called script.txt, it hangs up after "enter 3 numbers". I run it like so:

D:>debug < script.txt

the file is:

a
mov cx, 3
jmp 0119
db 0d,0a,"enter 3 numbers",0d,0a,"$"
mov dx, 0105
mov ah, 09
int 21h
mov ah, 01
int 21h
and al, 0f
add bl, al
mov dl, 0a
mov ah, 02
int 21h
loop 0120
jmp 013a
db 0d,0a,"sum: ","$"
mov dx,0132
mov ah, 09
int 21h
or bl, 30
mov dl, bl
mov ah, 02
int 21h
mov ax, 4c00
int 21h

g

what am I doing wrong? Any hints or links appreciated. keith

4 Answers 4

5

You redirected input to debug to be from the script, not from the console, so debug is never receiving your keystrokes The program is hanging, waiting for more data to come in from the script.

If you put 3 numbers after the 'g' in the script, it should continue

Sign up to request clarification or add additional context in comments.

5 Comments

thanks for the explanation, jdigital, Michael, your suggestion works, but can I do both? I want the console user to provide the input, but I don't want them to have to type the entire code to run it again. Can the script redirect back to the console for input?
I don't believe there is a straightforward way to . . . you might be able to reopen CON and replace the stdin handle with that somehow, but I've no idea - I haven't coded for DOS since the Clinton administration
Forget about that last comment of mine!
Try reading directly from the keyboard; for example, int 16 function 0
jdigital, thanks that works! (changed line 8: mov ah,0 line 9: int 16h) now trying to make it echo so you can see the inputs...
2

You're telling debug to take all its input from script.txt, so when your program tries to read the numbers from standard input, it's reading from the file, not from the console.

Comments

0

good explanations. Thanks Michael, your suggestion worked, but I want to get input from the console and still run a script so I don't have to type the entire code to run it again. Thanks jdigital!, that's the answer I'm looking for. Using your hints (in comments above) I was able to make a simple working script:

a
mov cx, 3
jmp 0119
db 0d,0a,"enter 3 numbers",0d,0a,"$"
mov dx, 0105
mov ah, 09
int 21h
mov ah, 0     ; for console input
int 16h       ; use int 16h function 0.
mov dl,al     ; echo input to screen
mov ah,02
int 21h
and al, 0f
add bl, al
mov dl, 0a
mov ah, 02
int 21h
loop 0120
jmp 0140
db 0d,0a,"sum: ","$"
mov dx,0138
mov ah, 09
int 21h
or bl, 30
mov dl, bl
mov ah, 02
int 21h
mov ax, 4c00
int 21h

g

Comments

0
enter 3 numbers

9 7 9

sum: 9

Seam your program not working ... maybe is need to use stack , not regs.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.