I am trying to make the user input with any length.
More specifically, I am trying to read from input a directory that will be created using a mkdir
syscall (0x27
). But since this specificity is only for mkdir
; you can also include for an issue for my program "creating directories"; I have multiple programs that act like this.
Without C libraries would be appreciated.
I tried
mov r7, #0x04
mov r0, #0x00
ldr r1, =some_variable
mov r2, #(1 << 30)
swi 0x00
but it works (on a terminated string); However, I would like to know other ways of approaching this.
In general if you don't know the length but want to read all the data, you will have to read in chunks. Chunk size can be whatever you want, as little as 1 byte and as much as you like.
Some data structures do not lend themselves to this kind of chunking, so for them, we need strategies to combine chunks from fixed sized reads into units that can be processed. Variable length records (e.g. lines of text) might fall into this category, where occasionally the length of a line exceeds the fixed chunk size, but the processing algorithm want to see whole lines.
Sometimes we have to combine all the chunks into one single buffer for further processing. Rather than allocating the largest possible buffer in the first place, that most likely would use dynamic memory allocation and memory copy to present that contiguous buffer of data in the end.
Exceedingly large data sets may require special handling, such as using a 64-bit computer. Memory mapping files is also an option that can remove some of the buffering at the application level, in favor of letting the system do that.
The above applies whether writing in C or assembly.