Re: LZ: lddr routine


Re: LZ: lddr routine

Nathan Adams wrote:
> This is the routine that I have come up with from the info that all of you
> (mostly Alan Bailey) have given me.  But it still isn't working.  If
> somebody could tell me if this routine will work or what is wrong with it
> that would be great.  I'm not sure whether the problem is with this routine
> or somewhere else in my program.  Thanks
> <snip>
> IncMem:                 ;start of routine
>         ld bc,($8333)           ;Load cursor position into bc
>         push bc                 ;push bc onto stack
>         push hl                 ;push hl onto stack (current mem location)
>         ld bc,$0000             ;set bc equal to zero
> IncMemLoop:             ;get total number of bytes to be moved
>         inc bc                  ;increment counter
>         ld a,(hl)               ;load char into a
>         cp $02                  ;compare with EOF code
>         JUMP_Z(IncEOF)          ;If EOF shift memory
>         inc hl                  ;else move to next mem location
>         JUMP_(IncMemLoop)
> IncEOF:                 ;shift memory
>         push hl                 ;hl is the source address
>         pop de                  ;copy hl into de
>         inc de                  ;de is the destination
>         lddr                    ;load from (hl) to (de) until bc is zero
>         CALL_(DispUpdate)       ;call function to update display
>         pop hl                  ;hl now points to memory to be written in
>         pop bc                  ;bc is cursor location
>         ld ($8333),bc
>         ret
> DispUpdate:
>         pop de                  ;de is mem location
>         pop bc                  ;bc is cursor location
>         push bc                 ;replace on stack
>         push de
>         ld ($8333),bc
> DispLoop:
>         ld a,(de)               ;load character into a
>         cp $09                  ;if it is the end of line code return
>         ret z
>         cp $02                  ;or if it is the end of file code return
>         ret z
>         ROM_CALL(M_CHARPUT)     ;else print it
>         inc de                  ;move to next mem location
>         JUMP_(DispLoop)
> <snip>
> I'm grateful for all your help this is my first program in zshell/assembly,
> it's a big change from C.
> Nathan Adams
> "It is better to remain silent and be thought a fool,
> than to speak out and remove all doubt."

The lddr part looks okay, but it would be good if you told us exactly what happened, or 
else bugs are really hard to figure out.  Don't just say it didn't work.  Did it freeze 
or do something wierd?

Compliments of:
  Alan Bailey