I'm trying to copy a bunch of pixels from a screen location into other location. Picture this, I have a 8x8 green square on coordinates (100,120), and I want to copy the square to coordinates (150,60).
I'm using graphic mode 13h. That means 320x200, so my square begins in address 38500 (using y*320+x).
DS
points to 0A0000h.
How can I copy this square to the other coords (19350)?
I tried something like this:
MOV SI,38500
MOV DI,19350
INIT:
MOV CX,4 ; loop 4 times
COPY_BOX:
MOV AX,DS:[SI] ; copy two pixels
MOV DS:[DI],AX
ADD SI,2 ; move to the next two pixels
ADD DI,2
LOOP COPY_BOX
ADD SI,312 ; drop one line and position on the first pixel
ADD DI,312
JMP INIT ; copy next row of pixels
; do this for the 8 rows
What am I doing wrong?
This is where your program goes into an infinite loop.
You only need to repeat the code height=8 times.
I solved it by putting these small counters in
CH
andCL
:If you're willing to use the string primitives it could look like this :