From owner-freebsd-hackers@FreeBSD.ORG Thu Jul 31 13:13:17 2003 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 11D9E37B401 for ; Thu, 31 Jul 2003 13:13:17 -0700 (PDT) Received: from neuroflux.com (ns1.neuroflux.com [204.228.228.84]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6192443F93 for ; Thu, 31 Jul 2003 13:13:16 -0700 (PDT) (envelope-from ryans@gamersimpact.com) Received: (qmail 28957 invoked by uid 85); 31 Jul 2003 20:12:28 -0000 Message-ID: <20030731201227.28952.qmail@neuroflux.com> From: "Ryan Sommers" To: freebsd-hackers@freebsd.org Date: Thu, 31 Jul 2003 16:12:27 -0400 Mime-Version: 1.0 Content-Type: text/plain; format=flowed; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Virus-Scanned: by AMaViS 0.3.12pre8 Subject: Assembly Syscall Question X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jul 2003 20:13:17 -0000 When making a system call to the kernel why is it necessary to push the syscall value onto the stack when you don't call another function? Example: access.the.bsd.kernel: int 80h ret func: mov eax, 4 ; Write call access.the.bsd.kernel ; End Works. However: func: mov eax, 4 ; Write int 80h ; End Doesn't. Now, if you change it to: func: mov eax, 4 ; Write push eax int 80h ; End It does work. I was able to find, "By default, the FreeBSD kernel uses the C calling convention. Further, although the kernel is accessed using int 80h, it is assumed the program will call a function that issues int 80h, rather than issuing int 80h directly," in the developer's handbook. But I can't figure out why the second example doesn't work. Is the call instruction pushing the value onto the stack in addition to pushing the instruction pointer on? Thank you in advance. PS I'm not on the list. -- Ryan "leadZERO" Sommers Gamer's Impact President ryans@gamersimpact.com ICQ: 1019590 AIM/MSN: leadZERO -= http://www.gamersimpact.com =-