Skip to contentSkip to conversation

How interrupts work

DISCUSSION RCS 3 participants 5 messages Aug 23, 2002 – Aug 25, 2002

lore
Share & tools
lore

RCS

author
#0 lore raw

Thanks, but which assembler must I use for this code? GNU as? I'm asking that because I am only familiar with nasm.

Thanks Again,

RCS

Em Aug 2002, Dmitry Trunikov escreveu:

Quoted 5 lines
Quoted 3 lines · RCS

I need some help to understand how interrupts work on Intel. For example, how do I print a character in the screen? Wich register must contain the character for that? Is "int 10h" the

correct

Quoted 25 lines
Quoted 3 lines

interrupt for that?

It depends on which pc or OS you use. "int 10h" is a BIOS (base input output system) interrupt i.e. it can be used AFAIK only in real CPU mode. Usually for character output is used OS API. In MSDOS you can uset "int 10h" or "int 21h" for input/output. Under linux you can use system call "int 80h".
This is an example for output string under linux:

// ssize_t write(int fd, const void *buf, size_t count); // write(fileno(stdout), "hello", 6);

.data
hello:
.string "hello world\n"
.text
.globl _start
_start:
movl 4,%eax // 4 - sys function 'write'
movl 1,%ebx // fd = fileno(stdio)
movl $hello,%ecx // buf = str
movl $12,%edx // count
int $0x80

Quoted 5 lines

movl 1,%eax // sys function 'exit'
xorl %ebx,%ebx
int $0x80

----------

_________________________________________________________
Oi! Você quer um iG-mail gratuito?
Então clique aqui: http://registro.ig.com.br/

#1 lore raw
Quoted 18 lines · RCS

Thanks, but which assembler must I use for this code? GNU as? I'm asking that because I am only familiar with nasm.

Quoted 15 lines

.data
hello:
.string "hello world\n"
.text
.globl _start
_start:
movl 4,%eax // 4 - sys function 'write'
movl 1,%ebx // fd = fileno(stdio)
movl $hello,%ecx // buf = str
movl $12,%edx // count
int $0x80

movl 1,%eax // sys function 'exit'
xorl %ebx,%ebx
int $0x80

This is GNU as syntax. You can use 'intel2gas' to convert from gas to nasm and vice versa. (see
http://www.niksula.cs.hut.fi/~mtiihone/intel2gas )

Regards,
Stephan

#2 lore raw

RE: Intel2GAS (was How interrupts work)

As I discovered two weeks ago, Intel2Gas is no longer available. I found an older version of it's source code using a Internet cache service. But if anyone can provide the most recent binary, I'd appreciate it.

Jim Watters

-----Original Message-----
From: Stephan Walter

This is GNU as syntax. You can use 'intel2gas' to convert from gas to nasm and vice versa. (see
http://www.niksula.cs.hut.fi/~mtiihone/intel2gas )

#3 lore raw

Re: Intel2GAS (was How interrupts work)

Quoted 6 lines · Jim Watters

As I discovered two weeks ago, Intel2Gas is no longer available. I found an older version of it's source code using a Internet cache service. But if anyone can provide the most recent binary, I'd appreciate it.

I had no problems downloading the source it from:
http://www.niksula.cs.hut.fi/~mtiihone/intel2gas/

and there's even an Debian package...

You can try the attached binary... might work if you've got the right libs :-)

Regards,
Stephan

#4 lore raw

RE: Intel2GAS (was How interrupts work)

Great! Thanks Stephan. I had spent many hours looking for this.

Jim Watters

-----Original Message-----
From: Stephan Walter

I had no problems downloading the source it from:
http://www.niksula.cs.hut.fi/~mtiihone/intel2gas/

and there's even an Debian package...

You can try the attached binary... might work if you've got the right libs :-)

Regards,
Stephan