OSDev.org

The Place to Start for Operating System Developers
It is currently Thu Mar 28, 2024 7:09 am

All times are UTC - 6 hours




Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next
Author Message
 Post subject: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 2:53 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
I'm in user mode, using gdb the debugger just steps over the int instruction.
Interrupts are enabled according to EFLAGS.

any thoughts ?

_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 3:03 am 
Offline
Member
Member

Joined: Wed Aug 09, 2017 7:37 am
Posts: 80
Hello.

If this is Linux Assembly, please can I have the code where it doesn't work.

Thanks
Steve.


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 3:11 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
What gdb instruction are you using to single-step your code?


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 4:53 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
iansjack wrote:
What gdb instruction are you using to single-step your code?

si

_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 4:58 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
stevewoods1986 wrote:
Hello.

If this is Linux Assembly, please can I have the code where it doesn't work.

Thanks
Steve.

This is not a Linux assembly.
It's a flat binary file I jump into once I switch to user mode and execute it.

The code for it:

Code:
   0:   e8 02 00                call   0x5
   3:   00 00                   add    %al,(%bx,%si)
   5:   eb fe                   jmp    0x5
   7:   55                      push   %bp
   8:   89 e5                   mov    %sp,%bp
   a:   cd 80                   int    $0x80
   c:   b8 00 00                mov    $0x0,%ax
   f:   00 00                   add    %al,(%bx,%si)
  11:   5d                      pop    %bp
  12:   c3                      ret   
  13:   00 14                   add    %dl,(%si)
  15:   00 00                   add    %al,(%bx,%si)
  17:   00 00                   add    %al,(%bx,%si)
  19:   00 00                   add    %al,(%bx,%si)
  1b:   00 01                   add    %al,(%bx,%di)
  1d:   7a 52                   jp     0x71
  1f:   00 01                   add    %al,(%bx,%di)
  21:   7c 08                   jl     0x2b
  23:   01 1b                   add    %bx,(%bp,%di)
  25:   0c 04                   or     $0x4,%al
  27:   04 88                   add    $0x88,%al
  29:   01 00                   add    %ax,(%bx,%si)
  2b:   00 1c                   add    %bl,(%si)
  2d:   00 00                   add    %al,(%bx,%si)
  2f:   00 1c                   add    %bl,(%si)
  31:   00 00                   add    %al,(%bx,%si)
  33:   00 d3                   add    %dl,%bl
  35:   ff                      (bad) 
  36:   ff                      (bad) 
  37:   ff 0c                   decw   (%si)
  39:   00 00                   add    %al,(%bx,%si)
  3b:   00 00                   add    %al,(%bx,%si)
  3d:   41                      inc    %cx
  3e:   0e                      push   %cs
  3f:   08 85 02 42             or     %al,0x4202(%di)
  43:   0d 05 48                or     $0x4805,%ax
  46:   c5 0c                   lds    (%si),%cx
  48:   04 04                   add    $0x4,%al


_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


Last edited by stdcall on Sun Aug 13, 2017 8:19 am, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 5:11 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
If the code isn't running under Linux, how is it running? (It looks like real mode.) Is there actually an int 0x80 handler?


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 5:30 am 
Offline
Member
Member
User avatar

Joined: Thu Aug 11, 2005 11:00 pm
Posts: 1110
Location: Tartu, Estonia
stdcall wrote:
The code for it:
Code:
00000000 <.data>:

I see a contradiction here.

_________________
Programmers' Hardware Database // GitHub user: xenos1984; OS project: NOS


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 6:04 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
BTW, note that the interrupt flag has no connection with a software interrupt.


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 6:17 am 
Offline
Member
Member

Joined: Wed Aug 09, 2017 7:37 am
Posts: 80
iansjack wrote:
BTW, note that the interrupt flag has no connection with a software interrupt.


True, it could be an exception (fault). What platform is he/she using? Int 0x80 is Linux.


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 6:38 am 
Offline
Member
Member
User avatar

Joined: Sat Mar 31, 2012 3:07 am
Posts: 4591
Location: Chichester, UK
A software interrupt cannot be an exception.


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 8:04 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
stevewoods1986 wrote:
iansjack wrote:
BTW, note that the interrupt flag has no connection with a software interrupt.


True, it could be an exception (fault). What platform is he/she using? Int 0x80 is Linux.


This is no Linux, this is my OS. there's a dedicated isr 0x80 handler I've written and placed in the IDT. and event if there wasn't I would expect to see a general exception fault.

_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 8:06 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
XenOS wrote:
stdcall wrote:
The code for it:
Code:
00000000 <.data>:

I see a contradiction here.


That's not a contradiction, the format I use for executable is just plain binrary, there are no sections like in ELF.
so basically to dump the assembly out of the binary I typed:
Code:
objdump -D -b binary -mi386 -Maddr16,data16 ./binary_code

program:     file format binary

Disassembly of section .data:

00000000 <.data>:
   0:   e8 02 00                call   0x5
....


So basically, the .data section you think you saw is not really a section at all.

_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 8:30 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
I found a workaround around this but I don't seem to understand why it didn't work.
I changed the int number to 0x40 instead of 0x80 and now it works perfectly.
I don't get it.

_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 8:59 am 
Offline
Member
Member

Joined: Thu Aug 13, 2015 4:57 pm
Posts: 384
stdcall wrote:
I found a workaround around this but I don't seem to understand why it didn't work.
I changed the int number to 0x40 instead of 0x80 and now it works perfectly.
I don't get it.

You haven't really said anything about the context of your issue.

Are you running Linux, on which you run Qemu, on which you run your own OS, on which you run some test app you compiler that tries to use int 0x80? And you are using gdb from the host Linux to connect to Qemu and single stepping over said int 0x80?

Are you using a recent version of Qemu or something ancient? Did you compile it or use a packaged one? Are you using KVM with Qemu or..?


Top
 Profile  
 
 Post subject: Re: assemby int x80 doesn't do anything
PostPosted: Sun Aug 13, 2017 11:29 am 
Offline
Member
Member

Joined: Thu Mar 14, 2013 1:30 am
Posts: 78
LtG wrote:
stdcall wrote:
I found a workaround around this but I don't seem to understand why it didn't work.
I changed the int number to 0x40 instead of 0x80 and now it works perfectly.
I don't get it.

You haven't really said anything about the context of your issue.

Are you running Linux, on which you run Qemu, on which you run your own OS, on which you run some test app you compiler that tries to use int 0x80? And you are using gdb from the host Linux to connect to Qemu and single stepping over said int 0x80?

Are you using a recent version of Qemu or something ancient? Did you compile it or use a packaged one? Are you using KVM with Qemu or..?


I'm Running Linux, on top of that I run Qemu and I'm connecting to the os using remote GDB protocol and Qemu offers.
The OS bootstraps and then runs a process in user mode. the process is a flat binary that is loaded via grub modules.
It appears that even before switching to user mode, int 0x80 doesn't do anything.
changing the number from 0x80 to something else (0x40) solved the issue, now the interrupt occurs.

_________________
“Meaningless! Meaningless!”
says the Teacher.
“Utterly meaningless!
Everything is meaningless.” - Ecclesiastes 1, 2

Educational Purpose Operating System - EPOS


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 18 posts ]  Go to page 1, 2  Next

All times are UTC - 6 hours


Who is online

Users browsing this forum: No registered users and 54 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group