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"; const char* source = "Hello world";
int main(){ int main(){
char buffer[16];
for(int i = 0; i < 10; ++i){ for(int i = 0; i < 10; ++i){
auto c = read_char(); auto c = read_input(buffer, 15);
print(c); buffer[c] = '\0';
print(buffer);
} }
exit(0); exit(0);

View File

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