Mail Archives: djgpp/2002/11/30/21:30:03
I am am working on the mix ASM/C model and here is my current try...
Ker.asm
[BITS 32]
global _OutputText
_OutputText:
push ebp ;Setup stack for function
mov ebp,esp
;char* HoldCurrentIndexCharPointer;
;char* SrcIndex;
sub esp, byte +0x8 ;Add a local varibles to stack
mov edx, [ebp+0x8] ;The 1st passed function param is a
pointer to text
mov [ebp-0x4], edx ;so set
HoldCurrentIndexCharPointer to the same address
mov ebx, [ebp+0x12] ;The 2nd passed function param is an
index where to put the char in viedo memory
mov eax, 0xb8000 ;so set SrcIndex to 0xb8000 plus
the index
add eax, ebx
mov [ebp-0x8], eax
StartLoop:
and byte ptr [edx], 0x0 ;Check for Null char
jz short PrintDone
mov byte ptr [ebx], byte ptr [edx]
add byte ptr [ebx], 0x1
add byte ptr [edx], 0x1
mov byte ptr [ebx], 0x4f ;Add new colors later
add byte ptr [ebx], 0x1
jmp short StartLoop
PrintDone:
mov esp,ebp
pop ebp
retn
And here is the ker.cpp
extern void OutputText(char* pOutStr, int iVideoMemIndex);
int main()
{
OutputText("Hello, world!", 22);
return 0;
}
Now the problems...
1) When linking I get an error - "...undefined reference to
'_OutputText(char* , int);". Now I am new to global/extern so I don't know
what is wrong...
2) Next in the lines...
StartLoop:
and byte ptr [edx], 0x0 ;Check for Null char
jz PrintDone
mov byte ptr [ebx], byte ptr [edx]
add byte ptr [ebx], 0x1
add byte ptr [edx], 0x1
mov byte ptr [ebx], 0x4f ;Add new colors later
add byte ptr [ebx], 0x1
jmp short StartLoop
PrintDone:
every mov, and(the instruction), and(the conjuction) add line gives me an
error -"...comma or end of line expected" now I don't know what I did wrong
there either...
Any help...
- Raw text -