⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 create_stack.c

📁 阿基米德操作系统的源代码
💻 C
字号:

///////////////////////////////////////////////////////////////////////////////
#include "general.h"

#include "hd_info_struct.h"
#include "dir_entry.h"
#include "msdos_dir_entry.h"
#include "d_inode.h"
#include "m_inode.h"
#include "buffer_head.h"
#include "fat_cache.h"
#include "file.h"
#include "hd_request_struct.h"
#include "super_block.h"

#include "common_head.h"
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

void create_stack(unsigned char * stack_ptr, unsigned char * arg_ptr)
{
	int				temp_index;
	unsigned char * temp_argptr;
	int				temp_args;
	unsigned long * temp_pLong0, *temp_pLong1;

	arg_ptr		= arg_ptr + 255;	
	temp_index	= 255;
	temp_argptr	= NULL;
	temp_args	= 0;
	temp_pLong0	= NULL;
	temp_pLong1	= NULL;

	while (temp_index >= 0)
	{
		if (*arg_ptr == 0)
		{
			stack_ptr--;
			*stack_ptr = *arg_ptr;
			temp_index--;
			arg_ptr--;
			temp_args++;

			while ((temp_index >= 0) && (*arg_ptr == 0))
			{
				temp_index--;
				arg_ptr--;
			}
		}
		else
		{
			while ((temp_index >= 0) && (*arg_ptr != 0))
			{
				temp_argptr = arg_ptr;
				stack_ptr--;
				*stack_ptr = *arg_ptr;
				temp_index--;
				arg_ptr--;
			}
		}
	}

	stack_ptr++;
	while (*stack_ptr++ != 0);
	temp_args--;
	temp_args--;

	temp_pLong0		= (unsigned long *)(((unsigned long)stack_ptr) & 0xfffffffc);
	temp_pLong0--;
	*temp_pLong0	= 0;
	temp_pLong0		= temp_pLong0 - temp_args;
	temp_pLong1		= temp_pLong0;
	temp_pLong0--;
	*temp_pLong0	= 0;
	temp_pLong0--;
	*temp_pLong0	= ((unsigned long)temp_pLong1) - 0x800000;
	temp_pLong0--;
	*temp_pLong0	= temp_args;
	
	while (temp_args)
	{
		*temp_pLong1	= ((unsigned long)stack_ptr) - 0x800000;
		temp_pLong1++;

		while (*stack_ptr++ != 0);
		temp_args--;
	}

	exec_stackptr	= temp_pLong0;
	exec_argptr		= temp_argptr;

	return;
}

///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -