Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>You are invoking the sys_write system call. sys_write() takes three arguments, file descriptor of the output device(it should be 1 for stdout),address of the buffer where you stored the value to be printed, and the size of the data to be printed. So you have to store file descriptor in %ebx, and store address of the buffer in %ecx and size of the data in %edx. To store the file descriptor you can use the following instruction.</p> <pre><code> movl $1, %ebx // store 1 (stdout) in ebx) </code></pre> <p>To store the size of the data you can use:</p> <pre><code> movl $1, %edx // size is 1 byte </code></pre> <p>Now, you have to store the address of the buffer, you need to put your data in the memory some where and need to store the address of the memory in %ecx. Assume that you want store the data in the stack it self, then you can do like this:</p> <pre><code> subl $4, %esp // get 4 bytes of memory in the stack movl $65, (%esp) // store data in the memory where esp points to movl %esp, %ecx // store address of the data in the ecx </code></pre> <p>Now you can issue the int 0x80.</p> <pre><code> movl $04, %eax // store syscall number in eax int $0x80 // issue the trap interrupt </code></pre> <p>As a whole you can write the following code:</p> <pre><code> movl $1, %ebx subl $0x4, %esp movl $64, (%esp) start_loop: movl (%esp), %eax addl $1, %eax movl %eax, (%esp) movl %esp, %ecx movl $1, %edx movl $0x04, %eax int $0x80 movl (%esp), %eax cmpl $126, %eax jle start_loop addl $0x4, %esp </code></pre> <p>See Linux System Calls Part2 at <a href="http://www.rulingminds.com/syscallspart2" rel="nofollow">http://www.rulingminds.com/syscallspart2</a> to know more about registers and system calls usage.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload