Implemented instruction to dump data from registers to memory

This commit is contained in:
Bartłomiej Szostak 2024-06-08 17:56:45 +02:00
parent 337ed7d795
commit 96386d56e3
No known key found for this signature in database
GPG Key ID: 562DACF230A18086
3 changed files with 44 additions and 19 deletions

View File

@ -1,27 +1,23 @@
default: sillymachine default: sillymachine
floattobitshelper: ./src/floattobitshelper.c ./src/floattobitshelper.h sillymachine: ./src/sillymachine.adb ./src/*.adb ./src/*.ads ./src/floattobitshelper.h ./src/floattobitshelper.c
gcc -c src/floattobitshelper.c -o floattobitshelper.o gcc -c src/floattobitshelper.c -o floattobitshelper.o
ar -crs floattobitshelper.a floattobitshelper.o ar -crs floattobitshelper.a floattobitshelper.o
floatwin: ./src/floattobitshelper.c ./src/floattobitshelper.h
x86_64-w64-mingw32-gcc -c src/floattobitshelper.c -o floatwin.o -lwinmm -lgdi32
ar -crs floattobitshelper.a floatwin.o
sillymachine: ./src/sillymachine.adb ./src/*.adb ./src/*.ads floattobitshelper
gnatmake ./src/sillymachine.adb -largs -L./ -l:floattobitshelper.a gnatmake ./src/sillymachine.adb -largs -L./ -l:floattobitshelper.a
debug: ./src/sillymachine.adb ./src/*.adb ./src/*.ads floattobitshelper debug: ./src/sillymachine.adb ./src/*.adb ./src/*.ads ./src/floattobitshelper.h ./src/floattobitshelper.c
gcc -g -c src/floattobitshelper.c -o floattobitshelper.o
ar -crs floattobitshelper.a floattobitshelper.o
gnatmake ./src/sillymachine.adb -o sillymachine-debug -g -largs -L./ -l:floattobitshelper.a gnatmake ./src/sillymachine.adb -o sillymachine-debug -g -largs -L./ -l:floattobitshelper.a
win: ./src/sillymachine.adb ./src/*.adb ./src/*.ads floatwin win: ./src/sillymachine.adb ./src/*.adb ./src/*.ads ./src/floattobitshelper.h ./src/floattobitshelper.c
x86_64-w64-mingw32-gcc -c src/floattobitshelper.c -o floatwin.o -lwinmm -lgdi32
x86_64-w64-mingw32-gnatmake src/sillymachine.adb -lwinmm -lgdi32 -largs -L./ -l:floattobitshelper.a ar -crs floatwin.a floatwin.o
x86_64-w64-mingw32-gnatmake src/sillymachine.adb -lwinmm -lgdi32 -largs -L./ -l:floatwin.a
all: sillymachine win all: sillymachine win
clean: clean:
rm *.o *.ali *.a sillymachine.exe sillymachine sillymachine-debug rm *.o *.ali *.a sillymachine sillymachine.exe sillymachine-debug

View File

@ -262,10 +262,18 @@ package body Shardware is
Length : Integer := Integer(Registers (3)); Length : Integer := Integer(Registers (3));
CharBuff : String (1 .. Length); CharBuff : String (1 .. Length);
begin begin
for i in 1 .. Length loop if InputTypeFlag = LEString then
CharBuff (i) := Character'Val(Memory (Pointer + Unsigned_32(i))); for i in 1 .. Length loop
end loop; CharBuff (i) := Character'Val(Memory (Pointer + Unsigned_32(i)));
Put(CharBuff); end loop;
Put(CharBuff);
elsif InputTypeFlag = LEUint then
Put(Unsigned_32'Image(Registers (26)));
elsif InputTypeFlag = LEInt then
Put(Integer'Image(UnToSignedInt(Registers (26))));
elsif InputTypeFlag = LEFloat then
Put(Float'Image(BytesToF(UToBytes(Registers (26)))));
end if;
end; end;
when others => null; when others => null;
end case; end case;

View File

@ -213,6 +213,27 @@ begin
when 3 => InputTypeFlag := LEFloat; when 3 => InputTypeFlag := LEFloat;
when others => InputTypeFlag := LEString; when others => InputTypeFlag := LEString;
end case; end case;
when 44 => -- Dump Register to Memory (Unsigned)
declare
Buffer : ByteArr(1 .. 4);
begin
Buffer := UToBytes(RegisterU(Integer(Instruction(3))));
WriteMem(MemoryArr, BytesToU(TempBytes(Instruction)), Buffer, True);
end;
when 45 => -- Dump Register to Memory (Int)
declare
Buffer : ByteArr(1 .. 4);
begin
Buffer := IToBytes(RegisterI(Integer(Instruction(3))));
WriteMem(MemoryArr, BytesToU(TempBytes(Instruction)), Buffer, True);
end;
when 46 => -- Dump Register to Memory (Float)
declare
Buffer : ByteArr(1 .. 4);
begin
Buffer := FToBytes(RegisterF(Integer(Instruction(3))));
WriteMem(MemoryArr, BytesToU(TempBytes(Instruction)), Buffer, True);
end;
when 65535 => when 65535 =>
goto THE_END; -- exit opcode goto THE_END; -- exit opcode
when others => null; when others => null;