.model small .386 .code org 100h shiftpal: jmp body init dw 0 qty dw 0 body proc near loadpal: lea di,palette mov dx,3c7h xor al,al out dx,al add dx,2 mov cx,300h rep insb call command cmp qty,2 jne rotate mov di,init cmp word ptr cs:[di],332fh je rotate3 rotate: mov al,byte ptr cs:[palette+2ffh] std lea si,palette+2fch mov di,si inc di mov cx,0bfh rep movsd mov byte ptr cs:[palette],al cld jmp sendpal rotate3: std mov bx,word ptr cs:[palette+2feh] mov al,byte ptr cs:[palette+2fdh] lea si,palette+2fch mov di,si add di,3 movsb sub si,3 sub di,3 mov cx,0bfh rep movsd mov word ptr cs:[palette+1],bx mov byte ptr cs:[palette],al cld sendpal: lea si,palette mov dx,3c8h xor al,al out dx,al inc dx mov cx,300h rep outsb quit: int 20h body endp command proc near xor bh,bh mov bl,cs:[80h] cmp bl,0 je return add bx,81h mov al,20h mov cx,7eh mov di,82h rep scasb dec di cmp di,bx je return mov init,di mov cx,bx sub cx,di mov al,20h repne scasb dec di cmp byte ptr cs:[di],20h je keep inc di keep: sub di,init mov qty,di return: retn command endp palette: end shiftpal