; This program tests Intel's "MMX" instructions, which are available ; on some Pentiums and the Pentium II. You can only run this on a machine ; with a MMX-capable chip, otherwise I don't know what will happen. ; The MMX instructions used are movq, paddb, pand, and emms. ; Notice also how you can use 32 bit- and MMX registers even in ; 16 bit mode. The NASM assembler can handle it. bits 16 org 100h section .text mov eax,0x0013 ; you can do this in 16 bit mode too! int 10h ; start vga mode mov di,0xA000 mov es,di mov di,0 mov cx,200 ; outer loop counter movq mm1,[incr] ; mm0-mm7 are special MMX registers movq mm0,[green] ; movq = move quadword (64 bits) loop0 mov ax,0 ; ax used as inner loop counter loop1 es movq [di],mm0 ; store quadword to video memory add di,8 inc ax cmp ax,40 ; 40x8=320=horizontal resolution jne loop1 ; fill one row paddb mm0,mm1 ; vector addition pand mm0,[mask] ; parallel (or vector) AND loop loop0 ; fill next row emms ; empty MMX state jmp endprog ; standard endprogram procedure: endprog mov ah,1 ; key delay int 21h mov ax,0x0003 ; restores text mode int 10h int 20h section .data green db 02,02,02,02,02,02,02,02 ; start with green incr db 01,01,01,01,01,01,01,01 mask db 0xf,0xf,0xf,0xf,0xf,0xf,0xf,0xf ; use only 16 colors