Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

int statement

Josh CodeJosh Code Member Posts: 675
I am quite new to programming in assembly and still don't know what the "int" instruction does. I learned that you can reboot a computer with and call dos procedures but I want to know more about what it does and why it's used.

Comments

  • geek_guygeek_guy Member Posts: 1
    The int instruction is a way of telling the CPU that your program is desperate for the CPU's attention. It typically tells the computer to do something depending on the values in different registers. And yeah it can boot you out of DOS if you include the following statement in your program:
    int 19h

    : I am quite new to programming in assembly and still don't know what the "int" instruction does. I learned that you can reboot a computer with and call dos procedures but I want to know more about what it does and why it's used.
    :

  • Sephiroth2Sephiroth2 Member Posts: 423
    : I am quite new to programming in assembly and still don't know what the "int" instruction does. I learned that you can reboot a computer with and call dos procedures but I want to know more about what it does and why it's used.
    :
    The INT instruction executes an interrupt. The processor will push CS, IP and the flags onto the stack. Then it fetches the next IP and CS from a table at 0000:0000. However, in protected mode it retrieves the new address from the IDT instead, which contains interrupt, trap or task gates.
  • DariusDarius Member Posts: 1,666
    : I am quite new to programming in assembly and still don't know what the "int" instruction does. I learned that you can reboot a computer with and call dos procedures but I want to know more about what it does and why it's used.
    :


    For all intents and purposes software generated interrupts might as well be far calls. Basically, software int's provide a well-defined location to access a library of functions. For example, you may create a TSR, but no other program later will really know where the code for that TSR is. However, your TSR would hook an interrupt and then other programs could access it through the interrupt. Software int's have nothing to do with the interrupt mechanism of the computer. They just use the same data structure.

    There are two other types of interrupts: hardware interrupts and CPU-generated interrupts. As you might have noticed these aren't generated by software and therefore they don't use the INT opcode to trigger. These are the real interrupts. An example of a CPU-generated interrupt would be the divide by 0 exception, while an example of a hardware interrupt would be the keyboard having a key ready.

    "We can't do nothing and think someone else will make it right."
    -Kyoto Now, Bad Religion

  • Josh CodeJosh Code Member Posts: 675
    What is a TSR? How does a division by 0 exception go from the CPU generating an interupt to Windows showing the message on the screen?

    Thanks for the help.

    : For all intents and purposes software generated interrupts might as well be far calls. Basically, software int's provide a well-defined location to access a library of functions. For example, you may create a TSR, but no other program later will really know where the code for that TSR is. However, your TSR would hook an interrupt and then other programs could access it through the interrupt. Software int's have nothing to do with the interrupt mechanism of the computer. They just use the same data structure.
    :
    : There are two other types of interrupts: hardware interrupts and CPU-generated interrupts. As you might have noticed these aren't generated by software and therefore they don't use the INT opcode to trigger. These are the real interrupts. An example of a CPU-generated interrupt would be the divide by 0 exception, while an example of a hardware interrupt would be the keyboard having a key ready.
    :
    : "We can't do nothing and think someone else will make it right."
    : -Kyoto Now, Bad Religion
    :
    :

  • DariusDarius Member Posts: 1,666
    : What is a TSR? How does a division by 0 exception go from the CPU generating an interupt to Windows showing the message on the screen?
    :
    : Thanks for the help.
    :

    TSR stands for Terminate and Stay Resident. It is a program in DOS or a single-tasking operating system (as it isn't really necessary for multi-tasking OSes) that executes then exits but tells the OS not to deallocate the memory for the program so that the code is still safe. Then, other programs can access and use the code. An example may be the DOS soundblaster drivers that you would execute (perhaps in the autoexec.bat).

    The same way all interrupts software, hardware, or CPU-generated get handled. An interrupts just informs the software about the event, it's up to the software to do something about it. The second post goes over the basic process for it.


    "We can't do nothing and think someone else will make it right."
    -Kyoto Now, Bad Religion

  • Andre YoungAndre Young USAMember Posts: 0

    ______ || http://forcoder.org || free ebooks and video tutorials about | C#, Java, R, Scratch, Delphi, Objective-C, C, JavaScript, Ruby, Python, Perl, PHP, Visual Basic .NET, Visual Basic, Assembly, MATLAB, Go, C++, Swift, PL/SQL Crystal, SAS, FoxPro, Fortran, Julia, Rust, Hack, LabVIEW, Lua, VBScript, Clojure, ML, COBOL, Awk, Bash, Lisp, Apex, Alice, D, Scheme, Ada, Prolog, Transact-SQL, ABAP, Erlang, Logo, Kotlin, F#, Dart, Scala | ______

Sign In or Register to comment.