I want to move information byte by byte from one memory location to another without using any library function. Am using a 16bits architecture emulated in qemu and this code is part of tiny small kernel i am writing, so i can not use any system call
// The struct i want to copy
struct procinfo info_tmp;
// here i put some stuff in my struct
info_tmp.pid = tablaprocesos[indiceProceso].pid;
kstrcpy(info_tmp.nombre, tablaprocesos[indiceProceso].nombre);
info_tmp.segmento = tablaprocesos[indiceProceso].memoria;
if(tablaprocesos[indiceProceso].estado==PROCESO_LISTO)
info_tmp.estado = 0;
else if(tablaprocesos[indiceProceso].estado==PROCESO_RUN)
info_tmp.estado = 1;
else if(tablaprocesos[indiceProceso].estado==BLOQ_TECLADO ||
tablaprocesos[indiceProceso].estado==PROCESO_SYSCALL)
info_tmp.estado = 2;
else
info_tmp.estado = 3; // Zombie
// Tiempo total = tiempoSYS + tiempoUSER
info_tmp.tiempo = tablaprocesos[indiceProceso].tiempoUSER +
tablaprocesos[indiceProceso].tiempoSYS;
// pointer to destination that i want to copy to
infoProc = (struct procinfo *)(((int)es << 16) + (0x0000ffff & ebx));
// now pointer to my source struct
procinfo * origen = &info_tmp;
int limit = sizeof(struct procinfo);
int i;
for(i=0;i<limit;i++){
// I need here to read only one byte from my source pointer to a variable "byte"
// macro written in ASM to copy one byte to a pointed location
// it writes in another data segment of another process
WRITE_POINTER_FAR(infoProc,byte);
// next byte
origen += 1;
infoProc += 1;
}
Is there a direct way to do it without the need to write a small code in ASM to do it manually ?
Note: This code is part of a 16bits segmented OS kernel (a 64KB segment for each process), the source struct is in the kernel segment and i want to copy it to a location in another process segment and it can not be like *targetBytePointer = *sourceBytePointer.
1 Answer