Page 1 of 5 123 ... LastLast
Results 1 to 10 of 50

Thread: Assembly Language - int $0x80

  1. #1
    Join Date
    Oct 2005
    Location
    Hyderabad, India
    Beans
    71

    Question Assembly Language - int $0x80

    I am learning assembly language programming. Here is the first program which does nothing but exits and returns 0.

    Code:
    .section .data
    .section .text
    .globl _start
    _start:
    movl $1, %eax # this is the linux kernel command
                        # number (system call) for exiting
                        # a program
    movl $0, %ebx # this is the status number we will
                        # return to the operating system.
                        # Change this around and it will
                        # return different things to
                        # echo $?
    int $0x80        # this wakes up the kernel to run 
                        # the exit command
    What is the significance of $0x80. I mean why is only 0x80 is used as the interrupt number and why not any other number?

    I am using the book Programming from the Ground Up which can be freely downloaded from here http://download.savannah.gnu.org/rel...0-booksize.pdf
    Vj
    Registered Linux User #410083
    Machine registration number 316762
    Ubuntu 10.04 User

  2. #2
    Join Date
    Mar 2006
    Beans
    5

    Re: Assembly Language - int $0x80

    Read page 27 of the book you posted (page 33 of the pdf). It has your explanation.

  3. #3
    Join Date
    Jul 2005
    Location
    Northern CA
    Beans
    656
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Assembly Language - int $0x80

    Or, as I've said in the book I'm writing:
    Calling a function that is embedded in the operating system is accomplished through a
    special type of instruction sometimes called a “software interrupt.” The instruction itself
    will be discussed in Section 15.3 (page 291), but it is easy to understand its use at this
    point. The technique involves moving the arguments to specific registers, placing a special
    code in the eax register, and then using the int $0x80 instruction to “call” a function in
    the operating system. The operating system will perform the action specified by the code
    in the eax register, using the arguments passed in the other registers. The values required
    for reading from and writing to files are given in Table 7.2.
    Code:
    Table 7.2: Register set up for system calls to read or write.
          system call   eax   ebx             ecx                edx
          -----------   ---   ---             ---                ---
          read          3     file descriptor  pointer to place   number of bytes
                                              to store bytes     to read
          write         4     file descriptor  pointer to first    number of bytes
                                              byte to write      to write
    Intel i7-920; Nvidia GT 220, 1GB; MSI X58 Pro-E; 6GB DDR; 64-bit mode.

  4. #4
    Join Date
    Oct 2005
    Location
    Hyderabad, India
    Beans
    71

    Lightbulb Re: Assembly Language - int $0x80

    Thanks for your replies.
    So the interrupt number 0x80 is linux specific right. I mean if I were to write an assembly language program in DOS or some other OS for that matter, I must use the interrupt number specific to that operating system. Am I correct?

    Thanks again for your replies.
    vijay
    Vj
    Registered Linux User #410083
    Machine registration number 316762
    Ubuntu 10.04 User

  5. #5
    Join Date
    Jul 2005
    Location
    Northern CA
    Beans
    656
    Distro
    Ubuntu 13.04 Raring Ringtail

    Re: Assembly Language - int $0x80

    Quote Originally Posted by vijayanand_sodadasi
    Thanks for your replies.
    So the interrupt number 0x80 is linux specific right. I mean if I were to write an assembly language program in DOS or some other OS for that matter, I must use the interrupt number specific to that operating system. Am I correct?

    Thanks again for your replies.
    vijay
    Correct. When the OS is starting up is loads the interrupt vector table. You have to know which interrupt number to use for the particular OS. I've never programmed under DOS (by choice), but according to one of my assembly language books the vector number for output to the screen is 0x21.
    Intel i7-920; Nvidia GT 220, 1GB; MSI X58 Pro-E; 6GB DDR; 64-bit mode.

  6. #6
    Join Date
    Nov 2004
    Beans
    2,614

    Re: Assembly Language - int $0x80

    Rather, the main DOS interrupt vector is 0x21.

  7. #7
    Join Date
    Jun 2010
    Beans
    1

    Re: Assembly Language - int $0x80

    yes.
    each os have different os soft interrupt.
    especially assembly can't port easily!

  8. #8
    Join Date
    Jan 2010
    Location
    Not Texas
    Beans
    340
    Distro
    Ubuntu 14.04 Trusty Tahr

    Lightbulb Re: Assembly Language - int $0x80

    Quote Originally Posted by runcoder_en View Post
    yes.
    each os have different os soft interrupt.
    especially assembly can't port easily!
    I always wondered about the imagination of people when they speak of assembly like its a spent [insert spent item here].

    Well, $OS_interrupt_vector would be a stand-in. OS portability solved. Took me a microsecond to think up and a few seconds to type up.

    The text editor could even have several $[ stand-ins]... so when you pushed $, a little menu popped up with the most used [followed by all the rest].... oooh!!!! dreamy!!!

    Not that I'm saying people should all go jump into assembly, but arbitrarily saying assembly can't port is just plain unimaginative. Any problem is itself its own solution, just in a different form. Even something as complicated as a rubics cube is its own solution. Just have to puzzle it out.


  9. #9
    Join Date
    Apr 2007
    Location
    NorCal
    Beans
    1,149
    Distro
    Ubuntu 10.04 Lucid Lynx

    Re: Assembly Language - int $0x80

    Quote Originally Posted by texaswriter View Post
    I always wondered about the imagination of people when they speak of assembly like its a spent [insert spent item here].

    Well, $OS_interrupt_vector would be a stand-in. OS portability solved. Took me a microsecond to think up and a few seconds to type up.

    The text editor could even have several $[ stand-ins]... so when you pushed $, a little menu popped up with the most used [followed by all the rest].... oooh!!!! dreamy!!!

    Not that I'm saying people should all go jump into assembly, but arbitrarily saying assembly can't port is just plain unimaginative. Any problem is itself its own solution, just in a different form. Even something as complicated as a rubics cube is its own solution. Just have to puzzle it out.

    That said, it's much easier to port a python program than an assembly program. Especially if you need it on your G5 Mac.
    Posting code? Use the [code] or [php] tags.
    I don't care, I'm still free. You can't take the sky from me.

  10. #10
    Join Date
    Jan 2010
    Location
    Not Texas
    Beans
    340
    Distro
    Ubuntu 14.04 Trusty Tahr

    Lightbulb Re: Assembly Language - int $0x80

    Quote Originally Posted by schauerlich View Post
    That said, it's much easier to port a python program than an assembly program. Especially if you need it on your G5 Mac.
    I wouldn't doubt it. My intention was not so much to compare the portability of one language to another, but to say that assembly can be just as portable as any language.

    For example, you could even create an assembly language that used generic opcodes and then at compile time the compiler would insert actual registry names and use "macros" when a certain opcode wasn't supported, even allowing complex code to be ported to simpler platforms. The vast majority of computers going back [many many decades] all have the same families of basic opcodes [also called mnemonics]. Abstracting specific registers and implementations [memory registers, memory to register, register to memory, register to register, memory to memory, etc] could allow someone to use their own arbitrary set of registers. You could have an add this, that where this was a memory location and that was something else. If the intended platform didn't support adding memory locations, it would be translated to: ld register, memory address; ld register2, memory address; add register1, register2; and then another ld to put it in a memory address. NOTE: ld = mov;

    Not saying this is *how* it should be implemented, but it is one easy method that allows assembly code to be robust and platform independent.

Page 1 of 5 123 ... LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •