Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Assembly Language > switch between ...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 1 of 10 Topic 5016 of 5113
Post > Topic >>

switch between functions

by Phoe6 <orsenthil@[EMAIL PROTECTED] > May 23, 2008 at 09:07 PM

Hi,

I need help in writing the following program.  This is an assignment
program, so I would not require the solution, but guidance would be
really helpful to me to get started and proceed in the correct
direction.

- I am learning assembly language programming. Confused with so many
options available and so many different ways to do things. I am not
settled as which way I should program.

- I use gcc, nasm and on Linux 32 bit.

The problem is here:

Write a C program for a linux OS running in Pentium that performs  the
following. The program has two functions, say A and B.  Initially, A
is called
, and it prints that the program is in function A for the first time.
Then B is
called, and it prints the same info. Then you should toggle between
function A and B repeatedly without using function call, each time
printing that you are in the function A or B for the nth time. You may
sleep for appropriate duration after each printing so that the output
is clearly visible.

Hint:   Use assembly language statement using asm statement. For more
help, see the following. You should use a common switch_to function
and each function should use a separate stack.

(i) The macro switch_to in the file linux-2.6.17.11/include/asm-386/
system.h

(ii) The function __switch_to in the file linux-2.6.17.11/arch/i386/
kernel/process.c.

---

If I look into the __switch_to function and macro, I see that they
reference the kernel tasks and does things other than just the
switching.

I tried it this way, wrote a simple C program with two functions and
calling each other (using a function call) and tried gcc -S ( to
produce the assembly). It actually did not help me to understand.

Any guidance would be appreciable.

Thank you,
Senthil
 




 10 Posts in Topic:
switch between functions
Phoe6 <orsenthil@[EMAI  2008-05-23 21:07:43 
Re: switch between functions
"Rod Pemberton"  2008-05-24 05:31:57 
Re: switch between functions
Frank Kotler <fbkotler  2008-05-24 12:24:26 
Re: switch between functions
Frank Kotler <fbkotler  2008-05-24 16:48:31 
Re: switch between functions
Phoe6 <orsenthil@[EMAI  2008-05-24 04:58:04 
Re: switch between functions
"Rod Pemberton"  2008-05-25 01:33:09 
Re: switch between functions
"Rod Pemberton"  2008-05-25 01:40:47 
Re: switch between functions
Robert Redelmeier <red  2008-05-24 13:51:31 
Re: switch between functions
Phoe6 <orsenthil@[EMAI  2008-05-24 22:01:51 
Re: switch between functions
Frank Kotler <fbkotler  2008-05-27 10:28:01 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Sat Sep 6 15:35:58 CDT 2008.