Param parsing within the terminal implemented.

git-svn-id: https://spexeah.com:8443/svn/Asuro@232 6dbc8c32-bb84-406f-8558-d1cf31a0ab0c
This commit is contained in:
kieron 2017-10-23 18:41:10 +00:00
parent 6a000366a5
commit 9c2a5c976e
42 changed files with 89 additions and 2 deletions

BIN
Asuro.iso

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -14,9 +14,15 @@ interface
uses
console,
keyboard,
util;
util,
lmemorymanager;
type
PParamList = ^TParamList;
TParamList = record
Param : pchar;
Next : PParamList;
end;
TCommandBuffer = array[0..1023] of byte;
TCommandMethod = procedure(buf : TCommandBuffer);
TCommand = record
@ -34,9 +40,74 @@ var
procedure run;
procedure init;
procedure registerCommand(command : pchar; method : TCommandMethod; description : pchar);
function getParams(buf : TCommandBuffer) : PParamList;
implementation
function getParams(buf : TCommandBuffer) : PParamList;
var
start, finish : uint32;
size : uint32;
ptr : uint32;
root : PParamList;
current : PParamList;
begin
root:= PParamList(kalloc(sizeof(TParamList)));
current:= root;
current^.next:= nil;
current^.Param:= nil;
start:= 0;
finish:= 0;
while (char(buf[finish]) <> ' ') and (buf[finish] <> 0) do begin
inc(finish);
end;
while buf[start] <> 0 do begin
start:=finish+1;
inc(finish);
while (char(buf[finish]) <> ' ') and (buf[finish] <> 0) do begin
inc(finish);
end;
size:= finish - start;
if size > 0 then begin
ptr:= uint32(@buf[start]);
current^.Param:= pchar(kalloc(size+2));
memset(uint32(current^.Param), 0, size+2);
memcpy(uint32(ptr), uint32(current^.Param), size);
current^.next:= PParamList(kalloc(sizeof(TParamList)));
current:= current^.next;
current^.next:= nil;
current^.Param:= nil;
end;
end;
getParams:= root;
end;
procedure testParams(buffer : TCommandBuffer);
var
params : PParamList;
begin
params:= getParams(buffer);
while params^.Param <> nil do begin
writestringln(params^.Param);
params:= params^.next;
end;
end;
procedure echo(buffer : TCommandBuffer);
var
idx : uint32;
begin
idx:= 5;
while buffer[idx] <> 0 do begin
console.writechar(char(buffer[idx]));
inc(idx);
end;
console.writestringln('');
end;
procedure clear(buffer : TCommandBuffer);
begin
console.clear();
@ -158,7 +229,9 @@ begin
memset(uint32(@buffer[0]), 0, 1024);
registerCommand('VERSION', @version, 'Display the running version of Asuro.');
registerCommand('CLEAR', @clear, 'Clear the Screen.');
registerCommand('HELP', @help, 'Lists all registered commands and their description.')
registerCommand('HELP', @help, 'Lists all registered commands and their description.');
registerCommand('ECHO', @echo, 'Echo''s text to the terminal.');
registerCommand('TESTPARAMS', @testParams, 'Tests param parsing.');
end;
procedure run;

View File

@ -31,6 +31,7 @@ function inb(port : uint16) : uint8;
function inw(port : uint16) : uint16;
function inl(port : uint16) : uint32;
procedure memset(location : uint32; value : uint8; size : uint32);
procedure memcpy(source : uint32; dest : uint32; size : uint32);
procedure psleep(t : uint16);
var
@ -189,4 +190,17 @@ begin
end;
end;
procedure memcpy(source : uint32; dest : uint32; size : uint32);
var
src, dst : puint8;
i : uint32;
begin
for i:=0 to size-1 do begin
src:= puint8(source + i);
dst:= puint8(dest + i);
dst^:= src^;
end;
end;
end.