raphael | 3 Sep 19:16 2005
Picon

newbie question

Hello list

I would like to know how i can manage to read the entry
on the keyboard without using C functions like scanf or get.

thank you for the help and forgive my poor english

Raphael

-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

jeff | 3 Sep 19:36 2005
Picon

Re: newbie question

On 09/03/2005 10:16 am, raphael wrote:
> I would like to know how i can manage to read the entry
> on the keyboard without using C functions like scanf or get.

You can use kernel calls.  The keyboard operates in two
modes and you need to select the mode first.

In raw mode each key press is provided.  In cooked mode
a whole line of data is provided when <enter> key pressed.

There are lots of examples, but the code looks like this:
 1. select mode, save previous mode
 2. wait for key press
 3. restore mode

Here is some code from asmlib.  It shows handling of multi
byte keys and the mouse.  This is probably does more than
you want, but may be useful.

  [section .text]

 extern raw_set2
 extern raw_unset2
 extern kbuf
 extern key_poll
 extern mouse_check
 extern poll_rtn
 extern kbuf_end
 extern key_flush

(Continue reading)

Martin Fflores | 3 Sep 22:10 2005
Picon

Re: newbie question

hi people, how i can have noticie that a key was pressed , but reading at 
port 60h, my problem is that i cant find a good documentation, if some one 
have some sourcecode(in ATT Assembly)Documentation or web link that will be 
great.

Take Folks.

_________________________________________________________________
Don’t just search. Find. Check out the new MSN Search! 
http://search.msn.click-url.com/go/onm00200636ave/direct/01/

-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Martin Fflores | 3 Sep 22:10 2005
Picon

Reading at port 60h

hi people, how i can have noticie that a key was pressed , but reading at 
port 60h, my problem is that i cant find a good documentation, if some one 
have some sourcecode(in ATT Assembly)Documentation or web link that will be 
great.

Take Folks.

_________________________________________________________________
FREE pop-up blocking with the new MSN Toolbar - get it now! 
http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/

-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Richard Cooper | 4 Sep 04:56 2005

Re: Reading at port 60h

> how i can have noticie that a key was pressed , but reading at port 60h,

You aren't doing that in Linux are you?  Linux reads the keyboard via an  
interrupt, if you're polling through port 0x60/0x64, you're not going to  
get anything because the kernel will get to it first.

You can have the kernel give you the scancodes from the keyboard on your  
stdin by using ioctls.  You can get more information about that by typing  
"man console_ioctl"

Basically, you call KDGKBMODE to get the current mode and save it, then  
call KDSKBMODE to set "RAW" mode, and when your program exits, you set   
the keyboard mode back like it was.  However, before that, you have to  
install signal handlers to catch if your program crashes or someone tries  
to kill it, because if your program doesn't set the keyboard mode back,  
the kernel isn't going to do it.  Also, before calling KDSKBMODE, you need  
to call TCSETSW to change the TTY settings, otherwise scancode 3 will be  
interpreted as contol-c, and scancode 13 will be translated to 10, and 127  
will be translated to 8, and probably some more.  You also have to use  
TCGETS to save those settings, so you can restore them too.  Then you have  
to watch for Alt-Fn and signal the kernel via VT_ACTIVATE to switch  
consoles, because it doesn't watch for Alt-Fn when they keyboard is in RAW  
mode.  On the plus side, you don't have to switch back to non-raw mode  
when you call VT_ACTIVATE, because the kernel keeps each console in it's  
own mode.

It's a mess of work, but it's doable, and will certainly work better than  
direct access.

> my problem is that i cant find a good documentation,
(Continue reading)

Richard Cooper | 8 Sep 04:21 2005

Child Detection

Is there some way in Linux to detect if your process has any children?
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

jeff | 8 Sep 19:08 2005
Picon

Re: Child Detection

On 09/07/2005 07:21 pm, Richard Cooper wrote:
> Is there some way in Linux to detect if your process has any children?
> -
I have not found a good way to do this, but the following features cam
be used to do it:

1. sending kill to any process with ecx=0 will  return its status, this
    contains the parent process.

 2. It is possible to walk through all the process by using the /proc
     file system. 

AsmLib has functions to walk the /proc file system and return status
of a process.  I think most programs keep track of their processes and
do not need to do a search.

My kernel documentation says the PID's are assigned by increment the
parent id?  If this is true it is possible to do a quick search for children
by encrementing the parent id and checking status?

 all the best, jeff

-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

James Colannino | 12 Sep 08:50 2005

Question about GCC and stack

Hey everyone.  First off, I just wanted to say hi as this is the first 
time I've posted to this list.  I've been subscribed for a while and 
have been archiving the messages, but haven't said anything because I 
haven't really begun to get started in Assembly until recently.  Now 
that I'm posting you can expect more messages from me in the future :)  
Hopefully I won't be too annoying ;)

That being said,  I have some questions regarding the way GCC handles 
the stack when it initializes a function.  Consider the following code 
(AT&T syntax; output from gcc -S sourcefile.c):

pushl   %ebp
movl    %esp, %ebp
subl    $8, %esp
andl    $-16, %esp
movl    $0, %eax
subl    %eax, %esp
leave

This was generated from an empty main() function initialized like so:

sourcefile.c:

int main() {
}

I understand that GCC, at least under Linux, has an unusual way of 
entering into a function (which, as I understand, is why it doesn't use 
the enter instruction.)  I'm trying to figure out exactly what's going 
on here in detail.  I can piece together some things but am having 
(Continue reading)

Tavis Ormandy | 12 Sep 20:09 2005
Picon

Re: Question about GCC and stack

--On Sunday, September 11, 2005 23:50:43 -0700 James Colannino
<james <at> colannino.org> wrote:
> I understand that GCC, at least under Linux, has an unusual way of
> entering into a function (which, as I understand, is why it doesn't use
> the enter instruction.)

Actually, I believe the enter instruction is avoided as it's considerably
slower than manually opening the frame, there's no reason you cant
substitute the enter instruction into this fragment if you wanted to.

> Is it copying the address of the top of the stack ebp?  Why?

Yes, consider that as you manipulate the stack, accessing arguments and
local variables stored there can get complicated as you normally access
them  as offset to the sp, for example, sp+4, sp-16, etc.

Obviously some object at sp+4 will be at sp+8 if you push some value onto
the stack, as the stack pointer will have moved. In a complex function this
could become unmanageable (at least to a human programmer, gcc can handle
this in order to gain an extra free register, but at some sacrifice).

The function prologue backs up the %ebp from the caller, then copies the sp
onto it. Now stack variables and arguments are at fixed offsets from the
%ebp throughout, no matter what stack manipulation you perform.

If you try manipulating arguments/stack variables in the function and take
a look at the code generated, you will see how the frame pointer is used to
address them, eg movl -8(%ebp), %foo (for comparison, try compiling the
code with -fomit-frame-pointer).

(Continue reading)

Brian Raiter | 12 Sep 22:50 2005

Re: Question about GCC and stack

> The subl instruction is pointless, I dont know why it's inserted. It
> could be just generic stub code that gcc always inserts for
> allocating stack variables, but as in this case you dont use any, it
> allocates $0 bytes...I'm sure someone will correct me if there's a
> good reason for it :)

I expect that the instructions obtained by the original poster were
created by gcc without optimization. Run gcc with -O2 or so would
probably yield a simpler set of instructions.

b
-
To unsubscribe from this list: send the line "unsubscribe linux-assembly" in
the body of a message to majordomo <at> vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Gmane