0

I need to display the buffer backwards than it is at first

....
MOV cx, ax
    MOV si, offset skBuf
    MOV di, offset raBuf
 work
    MOV dl, [si]
    
    MOV [di], dl
    INC si
    INC di
    LOOP    work
....
lulzo
  • 11
  • 3
  • 2
    Start with a pointer to the end of the destination and `dec di`. – Peter Cordes Dec 06 '22 at 18:43
  • 1
    More precisely, do `ADD si, ax; DEC si` before the loop, so that `si` points to the last element, then in the loop change `INC si` into `DEC si` in order to move backwards as you read the bytes to copy. – 500 - Internal Server Error Dec 06 '22 at 18:48
  • You are the best! I love you!!!! – lulzo Dec 06 '22 at 19:19
  • 1
    @500-InternalServerError: Instead of an extra `dec si` before the loop, put the `dec si` at the top of the loop, before the load. So you can still enter the loop with SI pointing to one-past-the-end of the input buffer. – Peter Cordes Dec 06 '22 at 23:03

0 Answers0