Mail Archives: djgpp/2003/02/24/00:32:16
I am using djgpp to build an operating system that has a SYS MSG Q. Now I
have been working with this to get it right but it doesn't seem to be
working right. Rather than starting with my current mess of Q code I will
start from the place I got the code it is based on
http://www.planet-source-code.com/xq/ASP/txtCodeId.4996/lngWId.3/qx/vb/scrip
ts/ShowCode.htm. Note this code is made for a build with the standard lib
and I was able to build and run it the WinXP Pro DOS box. Then I converted
it to test it in my kernel. For testing of Q I have made my kernel as small
in features as I need cause other parts are buggy even without the Q.
The features left are:
1) External asm file build with NASM and linked with the kernel c++ obj
file...
[BITS 32]
GLOBAL _ExASM_OutputChar
CR equ 0x0d
LF equ 0x0a
SECTION .text
;void ExASM_OutputChar(char cCharToWrite, unsigned int iVideoMemIndex, BYTE
StrAttrib);
_ExASM_OutputChar:
push ebp
mov ebp,esp
mov ecx, [ebp+0x8]
mov edx, [ebp+0xc]
OutputChar_StartLoop:
mov al, cl
mov byte [edx], al
inc edx
mov ebx, [ebp+0x10]
mov byte [edx], bl
OutputChar_PrintDone:
mov esp,ebp
pop ebp
retn
2) Simple new and delete code...
Header file...
typedef long unsigned int size_t;
void* operator new(size_t bytes);
void operator delete(void* mem);
void* operator new[](size_t bytes);
void operator delete[](void* mem);
Cpp file...
#include "ker.h"
//Next two line are for printing char to screen control by
TempCharIndexForVideoMem...
extern "C" void ExASM_OutputChar(char cCharToWrite, unsigned int
iVideoMemIndex, BYTE StrAttrib);
int TempCharIndexForVideoMem = 0; //This is elsewhere in the expanded
kernel version...
//Ex how I call the function "ExASM_OutputChar('Q',
0xb8000+(TempCharIndexForVideoMem++ * 2), 2);"
//The rest of new delete...
static char memblock[100];
static char* lastAllocated = memblock;
void* operator new(size_t bytes)
{
char* r = lastAllocated;
lastAllocated += bytes/* + sizeof(int)*/; // save room for size
//*r++ = bytes; // save size
return r;
}
void operator delete(void* mem)
{
if(mem)
{
int size = (int)((int*) mem) - 1; // retrieve size
// here, you will need to retrieve the memory block
}
}
void* operator new[](size_t bytes)
{
return ::operator new(bytes);
}
void operator delete[](void* mem)
{
::operator delete(mem);
}
Now with my features I left in my kernel do you know how I can convert what
was at the link it to work right cause when I add 3 and 5 to the Q print()
give me -1 then I started using pointer to pointer and really got messed
up...
Any help...
- Raw text -