Mail Archives: djgpp/2002/12/02/17:45:13
Looking back at the example I noticed I didn't have SECTION .text. Now the
page I gave the link to eariler said nothing about this it does say varibles
written in asm to be used by C need to be in the .data section so I added
the line and tried it out and it linked correctly.
However, the text doesn't print even with
extern "C" void OutputText(char* pOutStr, int iVideoMemIndex);
int main()
{
OutputText("Hello, world!", 22);
//Continue on by overriding text written by OutputText()
char* screen = (char*)0xb8000 + 22;
const char* msg = "Hello, world!";
while (*msg)
{
*screen++ = *msg++;
*screen++ = 0x4f;
}
//for(;;);
return 0;
}
So for now I have the asm code below(it shows the section location, retn
after _outputText label, and current text printing asm that appear to have a
run-time bug)
[BITS 32]
GLOBAL _OutputText
SECTION .text
_OutputText:
retn ;Added to skip asm so text will appear again...
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:
mov byte al, [edx] ;Check for null char
test al,al
jz short PrintDone
mov byte al, [edx]
mov byte [ebx], al
add byte [ebx], 0x1
add byte [edx], 0x1
mov byte [ebx], 0x4f ;Add new colors later
add byte [ebx], 0x1
jmp short StartLoop
PrintDone:
mov esp,ebp
pop ebp
retn
I am a little busy now but I will work with the loop a little tonight see if
I take out the loop and execute the loop once so I can test at least one
char goes thur loop...
Note: the loop is suppose to be like
while (*msg)
{
*screen++ = *msg++;
*screen++ = 0x4f;
}
but in asm. Also screen pointer is ebx and msg pointer is edx...
So it look like we are almost home with this...
Any more help...
- Raw text -