Re:New Problem with Screen
Posted: Mon Sep 16, 2002 6:50 pm
Hi,
I am not sure what you thought I meant, however I have written this function in assembly and you will need to assemble it with NASM and then link it in with your c code, you will then need to declare it as 'extern' in any c file you want to use it in, the prototype will be this
extern void ScrollScreen(int);
and you will call it as a normal c function like so,
ScroolScreen( 5 );
this will scroll the display up by 5 lines. If you do not know how to link assembly code with c code, then you will be best to drop a line to Tim Robinson, he is a moderator of this site and he will be able to tell you how to do this properly. http://www.mega-tokyo.com/forum/index.p ... e;user=Tim just send him a private message and ask him.
; =======================================
; void ScrollScreen(int);
; =======================================
_ScrollScreen:
push ebp
mov ebp, esp
mov eax, dword [ebp + 8]
mov cx, 160
mul cx
mov ebx, 0xb8000
add ebx, eax
mov ecx, 0xb8000
.ScrollLoop:
mov eax, dword [ebx]
mov dword [ecx], eax
add ebx, 4
add ecx, 4
cmp ebx, 0xb8fa0
je .ScrollDone
jmp .ScrollLoop
.ScrollDone:
mov dword [ecx], 0x00070007
add ecx, 4
cmp ecx, 0xb8fa0
jl .ScrollDone
pop ebp
ret
NOTE: C will remove any parameters from the stack automatically, if you call this from within another assembly file it will leave the parameters on the stack, to use this function from another assembly file simply change the
ret
instruction to
ret 4
and it will work as expected. Or you can 'pop' it off after the call like C does.
Hope this helps.
I am not sure what you thought I meant, however I have written this function in assembly and you will need to assemble it with NASM and then link it in with your c code, you will then need to declare it as 'extern' in any c file you want to use it in, the prototype will be this
extern void ScrollScreen(int);
and you will call it as a normal c function like so,
ScroolScreen( 5 );
this will scroll the display up by 5 lines. If you do not know how to link assembly code with c code, then you will be best to drop a line to Tim Robinson, he is a moderator of this site and he will be able to tell you how to do this properly. http://www.mega-tokyo.com/forum/index.p ... e;user=Tim just send him a private message and ask him.
; =======================================
; void ScrollScreen(int);
; =======================================
_ScrollScreen:
push ebp
mov ebp, esp
mov eax, dword [ebp + 8]
mov cx, 160
mul cx
mov ebx, 0xb8000
add ebx, eax
mov ecx, 0xb8000
.ScrollLoop:
mov eax, dword [ebx]
mov dword [ecx], eax
add ebx, 4
add ecx, 4
cmp ebx, 0xb8fa0
je .ScrollDone
jmp .ScrollLoop
.ScrollDone:
mov dword [ecx], 0x00070007
add ecx, 4
cmp ecx, 0xb8fa0
jl .ScrollDone
pop ebp
ret
NOTE: C will remove any parameters from the stack automatically, if you call this from within another assembly file it will leave the parameters on the stack, to use this function from another assembly file simply change the
ret
instruction to
ret 4
and it will work as expected. Or you can 'pop' it off after the call like C does.
Hope this helps.