pgubook-readers
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Pgubook-readers] A strange problem in Chapter 6


From: Dušan Xmetov
Subject: [Pgubook-readers] A strange problem in Chapter 6
Date: Fri, 30 Aug 2013 21:42:31 +0200
User-agent: Mozilla/5.0 (X11; Linux i686; rv:17.0) Gecko/20130704 Icedove/17.0.7

Hello everyone. My name is Dušan. I am really enjoying reading the PGU-book (v1.0). However, while I was reading, I hit a strange problem. In chapter 6, part Reading Records, there is a small function which prints a newline. Well, for some very strange reason, I'm unable to get it to work. It simply does nothing, it runs and exits as expected, without writing a newline. So I thought to my self, let's just rewrite it. And that's what I did. It didn't help, still the same problem. I tried changing the string to say something else, but it didn't write that either. Here is the code (To make testing easier, I temporarily made it a stand-alone program):

 .section data
newline:
 .byte 0x0A

 .section .text
 .globl _start
#.type  write_newline, @function

_start:

#       pushl   %ebp                            # Back-up old base pointer
#       movl    %esp, %ebp                      # Copy stack pointer to %ebp

        movl    $4, %eax                        # Set syscall to write
        movl    $1, %ebx                        # Set FD according to arg1
                                                # (Not. For testing purpuses, 1
                                                # is hardcoded in.)
        movl    $newline, %ecx                  # Set buffer to NEWLINE
        movl    $1, %edx                        # Set length to 1
        int     $0x80                           # Do write

#       movl    %ebp, %esp                      # Restore stack pointer
#       popl    %ebp                            # Restore base pointer
#       ret                                     # Return control to caller

        movl    $1, %eax
        movl    $0, %ebx
        int     $0x80


Again, I have no Idea why am I having such problems with such a simple function/program. It's probably something banally simple, but I'm unable to figure it out. Help is appreciated.

reply via email to

[Prev in Thread] Current Thread [Next in Thread]