X-posted to asm group as well.
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