y si te digo que he estado unos dias creando un OS para Kellybootloader en HEASM? , que funciones he hecho y como hice que funcione en Kellybootloader y en cualquier arquitecutra bueno vamos a saberlo ahora
introduccion
buenas gente, hace muchas muchas semanas lanze KellyBootloader, el bootloader por excelencia de ErickCraftStudios y tiene la capcidad de ejecutar programas portables a la arquitecutra en su propio formato ErickBinaryFormat asi que decidi un dia que el Bootloader y EBF esta muy avanzados y pueden hacer muchas cosas aunque aun no se termine la version mas estable de EBF la beta 3 pero decidi hacer un OS
esto no es un tutorial pero podran usarlo como referencia
lo que hice fue crear una prueba en la EbfDevelopmentTools para probar si se podia hacer algo de esa magnitud entonces empeze
primero tenia que desaherme de los servicios de arranque de KellyBootloader con el siguiente codigp
// no vamos a extraer nada de los servicios de arranque
(LET*)1 = 1
call_tapot ExitBootservices 1
asi que una vez tenia el codigo de inicializacion empeze con el sistema, decidi que hiba a ser un sistema tipo cli y unix asi que defini algunos comandos para empezar
Array _RuncmCommand_ AllocatePool->5
Array _CatCommand_ AllocatePool->3
Array _ClearCommand_ AllocatePool->5
Array _GuideCommand_ AllocatePool->5
Array _ReseCommand_ AllocatePool->4
Array _EchoCommand_ AllocatePool->4
Array _CommentStart_ AllocatePool->1
Array _RebootCommand_ AllocatePool->6
Array _ShutdownCommand_ AllocatePool->8
Array _AllocationCommand_ AllocatePool->4
Array _SrcCommand_ AllocatePool->3
Array _Line_ _YaLeTocaraXd_
asi que me puse a hacer el prompt con el siguiente codigo
// funcion del bucle
FUNCTION _Loop_
// dibujar el prompt
(LET*)1 = _ConsoleColor_brightgreen_
call_tapot SetForegroundColor 1
Print "BasOS"
(LET*)1 = _ConsoleColor_brightblue_
call_tapot SetForegroundColor 1
Print "^"
(LET*)1 = _ConsoleColor_gray_
call_tapot SetForegroundColor 1
Print "#\s"
// leer la linea
_CallOut 23 _Line_
Print "\n"
call_tapot ExecuteCommand _Line_
FreePool _Line_
// repetir el loop
call_tapot CmpAndJump 0 0 3 _Loop_ 0
__asm ret
y luego me puse a hacer el interprete de comandos
/**
* ExecuteCommand
*
* ejecuta un comando
* @param Line es la linea
*/
tapot ExecuteCommand (
_Linea_::String
)
_Line_ = *_Linea_
call _ExCommand_
END tapot
FUNCTION _ExCommand_
// comparar los comandos
call_tapot GetArrayLength _Line_ 2
(LET*)1 = 0
call_tapot CmpAndJump 1 2 _ComparatorType_IfEqual_ _hlt_ 0
// runcm
IF BufferNCmp<_Line_,_RuncmCommand_,5> THEN _DoRunCm_
// cat
IF BufferNCmp<_Line_,_CatCommand_,3> THEN _DoCat_
// echo
IF BufferNCmp<_Line_,_EchoCommand_,4> THEN _DoEcho_
// clear
IF BufferCmp<_Line_,_ClearCommand_> THEN _DoClear_
// guide
IF BufferCmp<_Line_,_GuideCommand_> THEN _DoGuide_
// reboot
IF BufferCmp<_Line_,_RebootCommand_> THEN _DoReset_
// shutdown
IF BufferCmp<_Line_,_ShutdownCommand_> THEN _DoOff_
// mall
IF BufferNCmp<_Line_,_AllocationCommand_,4> THEN _DoMall_
// rese
IF BufferNCmp<_Line_,_ReseCommand_,4> THEN _DoRese_
// src
IF BufferNCmp<_Line_,_SrcCommand_,3> THEN _DoSrc_
// #comentario
IF BufferNCmp<_Line_,_CommentStart_,1> THEN _hlt_
__asm ret
y luego hice los comandos
/**
* _DoRunCm_
*
* si hace un runcm
*/
FUNCTION _DoRunCm_
_IProto()
/**
* _DoCat_
*
* si hace un cat
*/
FUNCTION _DoCat_
_IProto()
/**
* _DoClear_
*
* si hace un clear
*/
FUNCTION _DoClear_
_IProto()
/**
* _DoEcho_
*
* si se hace un echo
*/
FUNCTION _DoEcho_
_IProto()
/**
* _DoGuide_
*
* si hace un ?
*/
FUNCTION _DoGuide_
_IProto()
/**
* _DoReset_
*
* si se hace un reboot
*/
FUNCTION _DoReset_
_IProto()
/**
* _DoOff_
*
* si se hace un shutdown
*/
FUNCTION _DoOff_
_IProto()
/**
* _DoMall_
*
* si se hace un mall
*/
FUNCTION _DoMall_
_IProto()
/**
* _DoSrc_
*
* si se hace un src
*/
FUNCTION _DoSrc_
_IProto()
FUNCTION _hlt_
__asm ret
FUNCTION _DoOff_
_CallOut 27 0
__asm ret
FUNCTION _DoReset_
_CallOut 28 0
__asm ret
FUNCTION _DoRunCm_
// recorrerlo 6 caracteres
(LET*)1 = *_Line_
(LET*)2 = 6
_CallOut 33 1
call_tapot ExecuteFile 1
Print "\n"
__asm ret
FUNCTION _DoSrc_
// recorrerlo 6 caracteres
(LET*)1 = *_Line_
(LET*)2 = 4
_CallOut 33 1
call_tapot ExecuteScriptFromFile 1
Print "\n"
__asm ret
FUNCTION _DoEcho_
// recorrerlo 7 caracteres
(LET*)1 = *_Line_
(LET*)2 = 5
_CallOut 33 1
call_tapot PrintPool 1
Print "\n"
__asm ret
FUNCTION _DoCat_
// recorrerlo 6 caracteres
(LET*)1 = *_Line_
(LET*)2 = 4
_CallOut 33 1
// cargar el archivo a la ram
call_tapot LoadFileToMem 1
call_tapot PrintPool 1
// liberar el pool del archivo
FreePool 1
Print "\n"
__asm ret
FUNCTION _DoClear_
_CallOut 2 0
__asm ret
FUNCTION _DoRese_
// recorrerlo 6 caracteres
(LET*)4 = *_Line_
(LET*)5 = 5
_CallOut 33 4
call_tapot Atoi 4 9
(LET)9 = *9
(LET)6 = 1
call_tapot SetVar 9 6
__asm ret
FUNCTION _DoMall_
// recorrerlo 6 caracteres
(LET*)4 = *_Line_
(LET*)5 = 5
_CallOut 33 4
call_tapot Atoi 4 9
_CallOut 18 9
(LET)9 = *9
(LET)6 = 1
call_tapot SetVar 9 6
call_tapot AllocateVar _AlloctedVarPos_
call_tapot SetVar 9 _AlloctedVarPos_
call_tapot GetVar 9 4
_CallOut 18 4
Print "\n"
__asm ret
FUNCTION _DoGuide_
Print "#\s\s\s\s\s\s\s\s\s\s\s[Comment]\n"
Print "runcm\s\s\s\s\s\s\s[Name]\n"
Print "cat\s\s\s\s\s\s\s\s\s[Name]\n"
Print "echo\s\s\s\s\s\s\s\s[Msg]\n"
Print "mall\s\s\s\s\s\s\s\s[Id]\n"
Print "rese\s\s\s\s\s\s\s\s[Id]\n"
Print "src\s\s\s\s\s\s\s\s\s[Name]\n"
Print "reboot\n"
Print "shutdown\n"
Print "clear\n"
Print "guide\n"
__asm ret
ya con eso listo me puse a hacer el sistema de scripts
primero declare las variables
// el script
Array _Script_ _YaLeTocaraXd_
// las lineas del script
Array _LinesOfScript_ _YaLeTocaraXd_
// el separador de lineas
Array _ScriptLineSplit_ AllocatePool->1
// lo que no queremos en el script
Array _CarrigeReturnChar_ AllocatePool->1
// la linea a ejecutar
LET _LineToExecute_
y luego hice la funcion de ejecucion
tapot ExecuteScriptFromFile (
_FileName_::String
)
// cargar el archivo a la ram
call_tapot LoadFileToMem _FileName_
_Script_ = *_FileName_
//call_tapot PrintPool _Script_
// ejecutarlo
call _ExecuteScript_
// liberar el pool del archivo
//FreePool _FileName_
END tapot
FUNCTION _ExecuteScript_
//FreePool _Line_
call_tapot StrReplace _Script_ _CarrigeReturnChar_ _ScriptLineSplit_ _Script_
//call_tapot PrintPool _Script_
_CallOut 9 0
// separar las lineas
call_tapot SplitStr _Script_ _ScriptLineSplit_ _LinesOfScript_
// ir a la linea 0
_LineToExecute_ = 0
// ejecutar las lineas
call _ScriptExecutionLoop_
// librerarlo
FreePool _LinesOfScript_
__asm ret
FUNCTION _ScriptExecutionLoop_
// obtener la linea
call_tapot GetArrayItem _LinesOfScript_ _LineToExecute_ _Line_
//call_tapot PrintPool _Line_
//_CallOut 9 0
call _ExCommand_
FreePool _Line_
// incrementar la linea
__asm increment _LineToExecute_
// obtener la longitud del array
call_tapot GetArrayLength _LinesOfScript_ 2
// ver si no se acabaron las lineas
call_tapot CmpAndJump _LineToExecute_ 2 _ComparatorType_IfNotGreater_ _ScriptExecutionLoop_ 0
__asm ret
este os es simple pero una base para tal vez si se hace conocido EBF se hagan muchos OSes