Mail Archives: djgpp/2002/12/03/03:51:24
lewi9908 (lewi9908 AT ghc DOT ctc DOT edu) wrote:
: 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
So far this is an ordinary DJGPP program, right? Not any kernel that
some bootloader loads, switches to PM and jump to, right?
If so, then why do you think graphic memory is at DS:0xb8000? Read the
FAQ regarding that.
Right,
MartinS
- Raw text -