~prelude/puts.cr
.cr
Crystal
(text/x-crystal)
fun print_string(str : UInt8*)
end

def puts(str : String)
  _str : Pointer(UInt8) = str.to_unsafe
  video_memory = Pointer(UInt8).new(0xB8000_u64)
  i = 0
  ch = _str.value
  while ch > 0
    ch = (_str + i).value
    break if ch == 0
    (video_memory + (i * 2)).value = ch
    (video_memory + (i * 2) + 1).value = 0x07_u8
    i += 1
  end
end

# Example usage with a static NUL-terminated string
message = "[CrystalOS Kernel] Hello from C++\0"
puts(message)