简体   繁体   中英

Why does assembly use INT instruction when it can use CALL?

If I'm not mistaken, executing an INT is basically a software subroutine. Why is there an INT instruction when you could use CALL to execute these interrupt routines?

Using INT makes the API very generic and independent of location of all the function entry points in the system that defines it. You don't need a library that has all the external symbols defined to link to. You just call INT xxH , for example, for some value xx and with the registers set a certain way. If you use CALL , you must know the address of the function either directly through a link library, or indirectly through a known table or other location, which could still require a link library for the table locations.

Subsystems like your BIOS use this method because then they don't have to publish the addresses of a bunch of individual functions, or have the impossible to maintain task of distributing a link/lib file for every conceivable operating system or development tool you may have. (Not to mention, you might be writing your own OS.) And it would likely have to vary for different PC hardware manufacturers as well. The INT mechanism is totally independent of all that.

If you have a collection of functions serviced by specific software interrupts and register settings, you can change the location of all the functions all that you want, and the collection of functions will still remain compatible with all the software out there that uses the interrupts. Very handy for something like a BIOS, or Linux system calls, etc.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM