%include "x86_vram.asm" ; first argument is row, 1 byte ; second argument is column, 1 byte ; third argument is cell, 2 bytes global write_to_coord write_to_coord: push ebp mov ebp, esp push edi push ebx ; should do the same thing ;call get_vram_offset ;mov edi, eax mov edi, X86_VRAM mov ebx, [ebp+8] imul ebx, X86_COLS*2 add ebx, [ebp+12] add ebx, [ebp+12] add edi, ebx ;edi now has effective address mov ebx, [ebp+16] ;; load word into ebx mov [edi], bx pop ebx pop edi mov esp, ebp pop ebp ret ; takes character/attribute in edi ; writes it to all cells on screen global clear clear: push ebp mov ebp, esp push edi ; movzx - move and zero-extend ; this trick lets us write half as many doublewords to vram movzx eax, word [ebp + 8] mov edx, eax shl eax, 16 or eax, edx ; stosd stores eax at the address in edi (here, vram) ; and then increments edi ; rep stosd repeats stosd while ecx is nonzero mov edi, X86_VRAM mov ecx, X86_COLS * X86_ROWS / 2 rep stosd ; "A REP STOS instruction is the fastest way to initialize a large block of memory." pop edi mov esp, ebp pop ebp ret