Implemented memcpy and memset. Allows larger local variables.

This commit is contained in:
neviyn 2017-11-16 17:07:52 +00:00
parent f279852501
commit 8eef348eca
2 changed files with 16 additions and 2 deletions

View File

@ -65,9 +65,8 @@ proc terminalWrite*(data: string) =
proc terminalWrite*(data: char) =
terminalWriteChar(data)
var parsedData: array[0..9, char]
proc terminalWrite*(data: SomeSignedInt) =
var parsedData: array[0..9, char]
if(data == 0):
terminalWrite('0')
return
@ -86,6 +85,7 @@ proc terminalWrite*(data: SomeSignedInt) =
terminalWrite(parsedData[i])
proc terminalWrite*(data: SomeUnsignedInt) =
var parsedData: array[0..9, char]
if(data == 0):
terminalWrite('0')
return

View File

@ -3,6 +3,20 @@
import tty, gdt, irq, serial
type
MemoryPointer{.unchecked.} = ptr array[0, char]
proc memcpy*(dest: ByteAddress, src: ByteAddress, count: int){.exportc.} =
var destMem = cast[MemoryPointer](dest)
var srcMem = cast[MemoryPointer](src)
for i in 0..count-1:
destMem[i] = srcMem[i]
proc memset*(dest: ByteAddress, value: char, count: int){.exportc.} =
var destMem = cast[MemoryPointer](dest)
for i in 0..count-1:
destMem[i] = value
proc kernelMain() {.exportc: "kernel_main"}=
serial.init()
serial.write("Booting OS\L")