Moving back and forth strings in assembly -
given matrix 25 rows , 80 columns attributes 160 columns have write program in assembly move 4 letter string "fool" (say) move across matrix , forth.
what have done till now:
mov bx,0b800h mov ds, bx mov si, 1760 mov cx,80 fool: add si,-6 mov [si], " " add si, 2 mov [si], "f" add si, 2 mov [si], "o" add si, 2 mov [si], "o" add si,2 mov [si],"l" loop fool mov cx, 80 foool: add si,-6 mov [si], "f" add si, -2 mov [si], "o" add si, 2 mov [si], "o" add si,2 mov [si],"l" add si,2 mov [si], " " loop foool mov ah,9 int 21h
but code, when reversed, last letter comes before first. newbie in assembly, have tried 8085 before first attempt 8086.
i grateful if me fix problem.
this works:
; compile nasm: ; nasm.exe fool.asm -f bin -o fool.com bits 16 org 100h mov bx,0b800h mov ds, bx mov si, 80*11*2 ; 1760 mov cx, 80+1-5 fool: mov [si], byte " " add si, 2 mov [si], byte "f" add si, 2 mov [si], byte "o" add si, 2 mov [si], byte "o" add si, 2 mov [si], byte "l" sub si, 3*2 call delay loop fool sub si, 1*2 mov cx, 80+1-5 foool: mov [si], byte "f" add si, 2 mov [si], byte "o" add si, 2 mov [si], byte "o" add si, 2 mov [si], byte "l" add si, 2 mov [si], byte " " sub si, 5*2 call delay loop foool mov ax, 4c00h int 21h delay: pusha push ds mov ax, 0 mov ds, ax mov bx, [46ch] d0: mov ax, [46ch] cmp ax, bx je d0 ; wait timer tick (once in ~55 ms) pop ds popa ret
Comments
Post a Comment