I'm new to Assembly and trying to write a program that requires a simple graphic display: a 10x10 grid of "|##|" . I need to make changes to it and redisplay it every so often. I can get it to display perfectly once but the second time I call the same function it only displays the first line then stops.

I have tried for a long time to figure out why this is happening and (though its very possible I missed something little in the code) I think it has to do with the way the characters are sent the screen to be displayed

Is there any reason this code shouldn't display the same thing both times WrtiteGraphicInterface is called???

INCLUDE Irvine16.inc
.data
DispInterface BYTE 100 DUP("|##|")
DispDivider BYTE 40 DUP("="),0 ;divider string between rows
OLoop DWORD 10d
ILoop DWORD 40d
.code

main PROC
mov ax,@data
mov ds,ax

call WriteGraphicInterface
call WriteGraphicInterface
exit
main ENDP

WriteGraphicInterface PROC

mov esi, OFFSET DispInterface

mov ecx, OLoop
OutterLoop:
mov OLoop, ecx
mov ecx, ILoop

InnerLoop:
mov al, [esi]
call WriteChar
inc esi
Loop InnerLoop
call CrLf
mov edx, offset DispDivider
call WriteString
call CrLf
mov ecx, OLoop
Loop OutterLoop

ret
WriteGraphicInterface ENDP


end main

The first time it is called it displays 10 rows of
|##||##||##|.....etc
but the second time it only displays one row

(NOTE: the functions CrLf WriteString and WriteChar are from the include file Irvine16.inc - It came with the book our class is using
Write string takes the offset of a string in edx and writes it on the screen. Write char takes a character in al and writes it. Crlf just starts a new line in the display)


Please Help!
I have no idea what I'm doing =P

-Thanks

WOW! I figured it out right after I posted...

I really should have thought to reset the value of the OLoop variable at the beginning of each call...

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.