Hi!
I'm wondering how to perform:
"To read and write call interrupts using instruction int (e.g. int 10h)."
(in nasm x86)

for example:

bits 32
extern _printf, _scanf
global _main

section .data
    message db "Hello!", 10, 0
section .text
_main:
      pushad

      push dword message
      call _printf        <--- how to?      
      add esp, 4

      popad
      ret

and

bits 32
extern _printf, _scanf
global _main

section .bss
    value resd 1
section .data
    message db "Hello!", 10, 0
    handler db "%d"

section .text
_main:
      pushad

      push dword value
      push dword handler
      call _scanf        <--- how to?      
      add esp, 8

      popad
      ret

So I need to use int instruction instead of _scanf and _printf..

Any advise?

thanx in advance!

int instructions only work for the interrupt functions that are pre-defined by the operating system. printf() and scanf() are not define by the os api therefore it's not possible to perform int instructions to access them. Those are higher-level functions defined by the C language. google for int 21 instructions and you will find a list of all available functions for int 21.

bits 32
extern _printf, _scanf
global _main

section .data
    message dw "Hello!"
    lenmessage equ $-message
section .text
_main:
      pushad

      mov edx, lenmessage   ;count of bytes for write syscall
      mov ecx, message      ;poiter to output buffer
      mov eax, 4            ;syscall write
      int 0x80              ;make call

      popad
      ret

I tried something like this but its still not working...
Help?

Edited 6 Years Ago by mikesr: n/a

What platform are you using, as there is a distinct way of calling interrupts through BIOS, DOS or LINUX.

These calling conventions allow you to access hardware directly (BIOS) or near directly (DOS). Windows just won't allow you to do it at all.

This page deliniates how to use INT 10 Video

In Linux INT 80 is probably the best option. This site will probably be a good resource.

I have limited experience with Linux, but have had enough exposure in the past that I may be able to help with specifics

This article has been dead for over six months. Start a new discussion instead.