Fix read input from user program

This commit is contained in:
Baptiste Wicht 2014-02-02 21:20:58 +01:00
parent 6cfc85e7e0
commit aa44208030
2 changed files with 8 additions and 5 deletions

View File

@ -11,9 +11,12 @@
const char* source = "Hello world";
int main(){
char buffer[16];
for(int i = 0; i < 10; ++i){
auto c = read_char();
print(c);
auto c = read_input(buffer, 15);
buffer[c] = '\0';
print(buffer);
}
exit(0);

View File

@ -47,12 +47,12 @@ void print_line(size_t v){
print_line();
}
char read_char(){
size_t read_input(char* buffer, size_t max){
size_t value;
asm volatile("mov rax, 3; int 50; mov %0, rax"
: "=m" (value)
: //No inputs
: "rax", "rbx");
: "b" (buffer), "c" (max)
: "rax");
return value;
}