News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Program sometimes hangs

Started by Jethro82, May 11, 2020, 06:55:45 AM

Previous topic - Next topic

Jethro82

I'm using the delays between user inputs to create an array of random bytes.  Sometimes this program goes to the end, other times it stops recognizing keyboard input before the 80 characters are up and just hangs.
push cs
pop ds
mov ax,3
int 10h
mov ax,1300h
mov bx,7
xor dx,dx
mov bp,SeedString
mov cx,SeedStringEnd-SeedString
int 10h
mov bx,300h
mov Ax,0B800h
mov es,Ax
NextKey:
        KeyWait:
                mov ah,1
                inc cx ;increment 'random' variable
                int 16h ; check for key stroke
        jz KeyWait ; exit loop on key stroke

   cmp dl,al
   jz KeyWait      
   mov dl,al
        mov [bx],cx ; save 'random' variable   to key space
   mov [es:bx],al
   mov ah,0
        int 16h
   inc bx
   inc bx
        cmp bx,300h+160
jl NextKey
int 20h
SeedString:
db 'Enter 80 characters';
SeedStringEnd:

FORTRANS

Hi,

   I modified your code to make it assemble with MASM.
No real code changes, but MASM needs some more
directives to make it happy.  It runs to completion here.

   However, until I figured out what the following code
did, I thought it had hung up.  That code requires a
different keystroke from the last keystroke to continue.

cmp dl,al
jz KeyWait


Regards,

Steve N.

Jethro82

Thanks!  That was actually deliberate, but was added in an afterthought.  What I should have done is cleared the buffer with Int 16h, ah=0 before I ran that part of the loop rather than after

(my concern was if the user kept their finger on one key to fill out the 80 characters cx wouldn't be random enough).