124 lines
2.0 KiB
NASM
124 lines
2.0 KiB
NASM
; asmfuncs.asm
|
|
; Josh Holtrop
|
|
; 10/23/03
|
|
|
|
|
|
;stores the parameter to the CR0 register
|
|
;extern dword write_cr0(dword cr0);
|
|
[global _write_cr0]
|
|
_write_cr0:
|
|
push ebp
|
|
mov ebp, esp
|
|
mov eax, [ebp+8]
|
|
mov cr0, eax
|
|
pop ebp
|
|
ret
|
|
|
|
;returns the value in the CR0 register
|
|
;extern dword read_cr0();
|
|
[global _read_cr0]
|
|
_read_cr0:
|
|
mov eax, cr0;
|
|
ret
|
|
|
|
;stores the parameter to the CR3 register
|
|
;extern dword write_cr3(dword cr3);
|
|
[global _write_cr3]
|
|
_write_cr3:
|
|
push ebp
|
|
mov ebp, esp
|
|
mov eax, [ebp+8]
|
|
mov cr3, eax
|
|
pop ebp
|
|
ret
|
|
|
|
;returns the value in the CR3 register
|
|
;extern dword read_cr3();
|
|
[global _read_cr3]
|
|
_read_cr3:
|
|
mov eax, cr3;
|
|
ret
|
|
|
|
|
|
;copies 32bpp video buffer memory to LFB
|
|
;extern dword video_copyBuffer32(dword src, dword dest, dword pixelcount);
|
|
[global _video_copyBuffer32]
|
|
_video_copyBuffer32:
|
|
push ebp
|
|
mov ebp, esp
|
|
push esi
|
|
push edi
|
|
push ecx
|
|
mov esi, [ebp+8]
|
|
mov edi, [ebp+12]
|
|
mov ecx, [ebp+16]
|
|
rep movsd
|
|
pop ecx
|
|
pop edi
|
|
pop esi
|
|
pop ebp
|
|
ret
|
|
|
|
|
|
;copies 24bpp video buffer memory to LFB
|
|
;extern dword video_copyBuffer24(dword src, dword dest, dword pixelcount);
|
|
[global _video_copyBuffer24]
|
|
_video_copyBuffer24:
|
|
push ebp
|
|
mov ebp, esp
|
|
push esi
|
|
push edi
|
|
push ecx
|
|
mov esi, [ebp+8]
|
|
mov edi, [ebp+12]
|
|
mov ecx, [ebp+16]
|
|
_video_copyBuffer24_loop:
|
|
movsd
|
|
dec edi
|
|
loop _video_copyBuffer24_loop
|
|
pop ecx
|
|
pop edi
|
|
pop esi
|
|
pop ebp
|
|
ret
|
|
|
|
|
|
;copies 16bpp video buffer memory to LFB
|
|
;extern dword video_copyBuffer16(dword src, dword dest, dword pixelcount);
|
|
[global _video_copyBuffer16]
|
|
_video_copyBuffer16:
|
|
push ebp
|
|
mov ebp, esp
|
|
push esi
|
|
push edi
|
|
push ecx
|
|
push ebx
|
|
mov esi, [ebp+8]
|
|
mov edi, [ebp+12]
|
|
mov ecx, [ebp+16]
|
|
_video_copyBuffer16_loop:
|
|
lodsd ;eax = 32bpp color
|
|
shr eax, 3
|
|
mov ebx, eax
|
|
and ebx, 0x1F
|
|
shr eax, 2
|
|
and eax, 0xFFFFFFE0
|
|
or ebx, eax
|
|
and ebx, 0x7FF
|
|
shr eax, 3
|
|
and eax, 0xF800
|
|
or ebx, eax
|
|
mov eax, ebx
|
|
stosw ;store ax
|
|
loop _video_copyBuffer16_loop
|
|
pop ebx
|
|
pop ecx
|
|
pop edi
|
|
pop esi
|
|
pop ebp
|
|
ret
|
|
|
|
|
|
|
|
|