Move vram functions into separate file
This commit is contained in:
55
x86_vram_functions.asm
Normal file
55
x86_vram_functions.asm
Normal file
@@ -0,0 +1,55 @@
|
||||
%include "x86_vram.asm"
|
||||
|
||||
; first argument is row, 1 byte
|
||||
; second argument is column, 1 byte
|
||||
; third argument is cell, 2 bytes
|
||||
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
|
||||
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
|
||||
Reference in New Issue
Block a user