as I have take a look at the assemly code to syscall. I have notice some mistake (my be in my code or compiler-asm code). tell me if I WRONG.
Code: Select all
0010495c <syscall>:
10495c: 55 push %ebp
10495d: 89 e5 mov %esp,%ebp
10495f: 83 ec 14 sub $0x14,%esp
104962: 53 push %ebx
104963: 8b 5d 08 mov 0x8(%ebp),%ebx
104966: e8 85 39 00 00 call 1082f0 <disable>
10496b: 8b 4b 10 mov 0x10(%ebx),%ecx
10496e: 8b 53 18 mov 0x18(%ebx),%edx
104971: 8b 43 1c mov 0x1c(%ebx),%eax
104974: 89 cb mov %ecx,%ebx
104976: 89 d1 mov %edx,%ecx
104978: 51 push %ecx
104979: 53 push %ebx
10497a: ff 14 85 40 b8 10 00 call *0x10b840(,%eax,4)
104981: 5b pop %ebx
104982: 59 pop %ecx
104983: 89 43 1c mov %eax,0x1c(%ebx)
104986: e8 75 39 00 00 call 108300 <enable>
10498b: 5b pop %ebx
10498c: c9 leave
10498d: c3 ret
* gcc use EBX to as placehalter for regs and mov value to ecx and eax and ebx in instructions "10496b -> 104971"
* then it change the value of ebx ( !!) at 104974. that mean the ebx not point now to regs.
* when return from sys_read it save the return in 0x1c(%ebx), which not point regs now.
there for the eax value in regs struct have not been change. thus i receive the old value eax before call syscall.
the c-code for syscall you can find it here in this thread.
please correct me if I am wrong in my analysis !