.model small

.stack 100h

.data
mov CX,0
.code

start:
array db 8 DUP (?)
mov bx, offset array
mov ah, 01h
int 21h
mov , al
mov dl, al
mov ah, 2h
int 21h

inc CX
cmp CX, 8
jl start

mov ax, 4c00h ; return to ms-dos
int 21h

end start


First of all is the input going into the array? If not what am I missing for the input to be put inside the array? Second of all based on what I understand the jl start line should make it so that the user can input 8 times before the program stops. Instead the program stops right after the first input. Can somebody please explain what's happening?

Thank you.
Posted on 2009-10-13 20:44:50 by RS
mov cx, 0 is never executed.. cx starts with some random value.. probably why it runs only once.. also put data like array in the data section..
Posted on 2009-10-13 21:21:12 by lone_samurai5
Is it never executed because I had it under the .data ? Here is an updated version of my code:


.model small

.stack 100h

.data
array db 8 DUP (?)
.code
mov CX,0
start:
mov bx, offset array
mov  ah, 01h  ; keyboard input subprogram
int  21h    ; read character into al
mov , al
mov  dl, al
mov  ah, 2h  ; display subprogram
int  21h    ; display character in dl

inc CX
cmp CX, 8
jl start

mov  ax, 4c00h ; return to ms-dos
int  21h

end start


Unfortunately the problem continues.
Posted on 2009-10-13 21:29:14 by RS
mov cx, 0 still won't execute.. start is the program's entry point here.. you need to add the code after it..
Posted on 2009-10-13 21:40:59 by lone_samurai5
Got it to work! Seperated the code with a couple of labels. Thanks for that.

Now for my other question, is the input actually being added into my array? Here is my updated code:


.model small

.stack 100h

.data
array db 8 DUP (?)
.code

start:
mov CX,0

mid:
mov bx, offset array
mov   ah, 01h  
int   21h
mov , al
mov   dl, al
mov   ah, 2h  
int   21h    

adder:
inc CX
cmp CX, 8
jl mid
mov   ax, 4c00h
int   21h

end start


Thanks again for any help.
Posted on 2009-10-13 21:43:57 by RS
only the 1st byte of array is updated now.. move mov bx, offset array outside the loop and increment bx if you want it to fill up the array
Posted on 2009-10-13 21:57:27 by lone_samurai5