Pass One of Two Pass Assembler sourcecodesonline.blogspot.com
C Program for Pass One of Two Pass Assembler.
Pass Two of Two Pass Assembler sourcecodesonline.blogspot.com
C Program for Pass Two of Two Pass Assembler.
Single Pass Assembler sourcecodesonline.blogspot.com
C Program for Single Pass Assembler.
Macro Processor sourcecodesonline.blogspot.co
C Program for Macro Processor.
Absolute Loader sourcecodesonline.blogspot.com
C Program for Absolute Loader.
Relocating Loader sourcecodesonline.blogspot.com
C Program for Relocating Loader.
Pass One of a Direct-Linking Loader sourcecodesonline.blogspot.com
C Program for Pass One of a Direct-Linking Loader.
Pass Two of a Direct-Linking Loader sourcecodesonline.blogspot.com
C Program for Pass Two of a Direct-Linking Loader.
“When it comes to winning, you need the skill and the will.” - Frank Tyger. This blog is an initiative idea to provide the skill and will to win.
Saturday, March 31, 2012
Lab Programs for 1 - 3 - System Software Lab MC9227
Shared Memory Program - System Software Lab
Lab Program - 13 - Shared Memory - System Software Lab
#include “sys/types.h”
#include “sys/ipc.h”
#include “sys/shm.h”
#include “stdio.h”
#define SHMSZ 27
main()
{
char c;
int
shmid;
key_t key;
char *shm,*s;
/* The shared memory is named as 2012 */
key
= 2012;
if
((shmid = shmget(key, SHMSZ, IPC_CREAT | 0666)) < 0) {
perror("shmget");
exit(1);
}
/* Mapping the Shared Memory */
if
((shm = shmat(shmid, NULL, 0)) == (char *) -1) {
perror("shmat");
exit(1);
}
s =
shm;
/* Storing some text in the Shared Memory */
for
(c = 'a'; c <= 'z'; c++)
*s++ = c;
*s
= NULL;
/* Wait for the other process that reads the
shared memory and alters the content */
while (*shm != '*')
sleep(1);
printf("\n End of the Server Program - Shared Memory");
exit(0);
}
#include “sys/types.h”
#include “sys/ipc.h”
#include “sys/shm.h”
#include “stdio.h”
#define SHMSZ 27
main()
{
int
shmid;
key_t key;
char *shm, *s;
/* The shared memory given a
name as 2012 */
key
= 2012;
if
((shmid = shmget(key, SHMSZ, 0666)) < 0) (< = <)
{
perror("shmget");
exit(1);
}
/* Map
the Shared Memory */
if ((shm = shmat(shmid, NULL, 0)) == (char *)
-1)
{
perror("shmat");
exit(1);
}
/* Read the content from the Shared Memory */
for
(s = shm; *s != NULL; s++)
putchar(*s);
putchar('\n');
/* Change the first character of the Shared
memory to * to indicate the server the content were read */
*shm = '*';
printf("\n End of Client Program - Shared Memory");
exit(0);
}
Thursday, March 29, 2012
Monday, March 26, 2012
Java Magazine - March/April 2012 Issue
Welcome to the March/April 2012 issue of Java Magazine!
The Java ecosystem is only as vibrant as its community.
In this issue's cover story, we profile some of the new, young Java developers who are delivering on the future of the platform
The New Java Developers
Meet some of the young developers creating the future of Java.
Today Decides Tomorrow
The Oracle Academy helps students embrace Java with the launch of a new Java curriculum.
JavaMail Delivers
Use JavaMail and Facelets to create a Web application that can send e-mail.
Clustering and High Availability Made Simple with GlassFish
Enable high-availability support for applications and session failover.
Sharing Data Among Threads Without Contention
Trisha Gee introduces the Disruptor, a 2011 Duke’s Choice Award Winner.
Fix This
Jonathan Giles offers up a JavaFX 2.0 code puzzler.
And more!
The Java ecosystem is only as vibrant as its community.
In this issue's cover story, we profile some of the new, young Java developers who are delivering on the future of the platform
The New Java Developers
Meet some of the young developers creating the future of Java.
Today Decides Tomorrow
The Oracle Academy helps students embrace Java with the launch of a new Java curriculum.
JavaMail Delivers
Use JavaMail and Facelets to create a Web application that can send e-mail.
Clustering and High Availability Made Simple with GlassFish
Enable high-availability support for applications and session failover.
Sharing Data Among Threads Without Contention
Trisha Gee introduces the Disruptor, a 2011 Duke’s Choice Award Winner.
Fix This
Jonathan Giles offers up a JavaFX 2.0 code puzzler.
And more!
PHP Questions asked in Interview
- What is the use of obj_start()?
- Difference between mysql_connect and mysql_pconnect?
- What is the difference between Split and Explode?
- What is the difference between session_register and $_session?
- How i can make a chat page in php in simple?
- Explain about the $_GET variable of PHP?
- How do you capture audio/video in PHP?
- How can I maintain the count of how many persons have hit my site?
- Describe about PHP error and logging information?
- How To Write the FORM Tag Correctly for Uploading Files?
- How would you initialize your strings with single quotes or double quotes?
- How to prevent form hijacking in PHP?
- Where does the PHP session stored, either client side or server side?
- Would I use print "$a dollars" or "{$a} dollars" to print out the amount of dollars in this example?
- What are new features that are in added in PHP5?
- What is difference between mysql_connect and mysql_pconnect?
- How do download in php ?
- How to handle drop down box change event without refreshing page?
- What is difference between require_once(), require(), include()?
Because above three function usefully use to call a file in another file.
- What
are the different tables present in MySQL? Which type of table is
generated when we are creating a table in the following syntax: create
table employee(eno int(2),ename varchar(10))?
- How can we submit a form without a submit button?
- What are the valid values for xlink:actuate and xlink:show?
- What Is a Persistent Cookie?
- What is meant by urlencode and urldecode?
- I am trying to assign a variable the value of 0123, but it keeps coming up with a different number, what’s the problem?
- Which will execute faster on php POST or GET? Explain
- How
i will check that user is, logged in or not. i want to make it a
function and i want to use in each page and after login i want to go in
current page(same page. where i was working)?
- How do we know browser properties?
- What is difference between mysql_fetch_array(),mysql_fetch_row() and mysql_fetch_object()
please insert with example?
- What is meant by PEAR in php?
- Explain about PHP filter and why it should be used?
- How can I maintain the count of how many persons have hit my site?
- Explain about looping in PHP?
- How to add multiple categories through PHP?
- Name and explain five of the PHP error constants?
- What is the difference between mysql_fetch_object and mysql_fetch_array?
- What is the use of sprintf() function?
- difference between require() and include()
- What is the difference between echo and print statement?
- What does the URI used as an XML namespace name point to?
Tuesday, March 20, 2012
Message Queue - System Software Lab - Program 10
Message Queue - System Software Lab - Program 10
____________________________________________________
Server Program stores Message into the Message Queue - Sender Program.
Message
queues are one of the three IPC (Inter Process Communication) facilities
provided by the UNIX operating system apart from semaphores and shared memory.
Message queues appeared in an early release of UNIX system V release III as a
means of passing messages between processes in an asynchronous way.
Client and Server Program for Message Queue
Client Program Reads the Message from the Message Queue - receiver.
#include “sys/types.h”
#include “sys/ipc.h”
#include “sys/msg.h”
#include “stdio.h”
#define MSGSZ 128
typedef struct msgbuf {
long
mtype;
char
mtext[MSGSZ];
} message_buf;
main()
{
int msqid;
key_t key;
message_buf
rbuf;
printf("\n\tLab program 10 : Message
Queue - Reading content from the queue\n");
key = 10;
if ((msqid = msgget(key, 0666)) < 0) {
perror("msgget");
exit(1);
}
if (msgrcv(msqid, &rbuf, MSGSZ, 1, 0)
< 0) {
perror("msgrcv");
exit(1);
}
printf("\nThe Message read from the
Message Queue : %s\n", rbuf.mtext);
exit(0);
}
____________________________________________________
Server Program stores Message into the Message Queue - Sender Program.
#include “sys/types.h”
#include “sys/ipc.h”
#include “sys/msg.h”
#include “stdio.h”
#include “string.h”
#include “fcntl.h”
#include “unistd.h”
#include “stdlib.h”
#define MSGSZ 128
typedef struct msgbuf {
long mtype;
char mtext[MSGSZ];
} message_buf;
main()
{
int
msqid;
int
msgflg = IPC_CREAT | 0666;
key_t key;
message_buf sbuf;
size_t buf_length;
char tmsg[100];
key
= 10;
printf("\n\tLab 10 : Message Queue - Sending Message to the Message
Queue\n\n");
printf("\nEnter a line to store as Message in the Queue : ");
fgets(tmsg,100,stdin);
printf("\nCalling
msgget with key %#lx and flag %#o\n",key,msgflg);
if
((msqid = msgget(key, msgflg )) < 0) {
perror("msgget");
exit(1);
}
else
printf("\nmsgget: msgget succeeded: msqid = %d\n", msqid);
sbuf.mtype = 1;
printf("\nmsgget: msgget succeeded: msqid = %d\n", msqid);
(void) strcpy(sbuf.mtext,tmsg);
printf("\nmsgget: msgget succeeded: msqid = %d\n", msqid);
buf_length = strlen(sbuf.mtext) + 1 ;
if
(msgsnd(msqid, &sbuf, buf_length, IPC_NOWAIT) < 0) {
printf ("\n%d, %d, %s, %d\n", msqid, sbuf.mtype, sbuf.mtext,
buf_length);
perror("msgsnd");
exit(1);
}
else
printf("\nMessage: \"%s\" Sent\n", sbuf.mtext);
exit(0);
}
System Software - Question Bank - Unit - IV
MC9224 - System Software - Question Bank
Unit I & Unit II Unit - III
UNIT - IV
1. What is the operation of macroprocessor?
Unit I & Unit II Unit - III
UNIT - IV
1. What is the operation of macroprocessor?
A macroinstruction
is simply a notational convenience for the programmer. A macro represents a
commonly used group of statements in the source programming language. The macro
processor relocates each macroinstruction with the corresponding group of
source language statements. This called expanding macros.
The function of a
macro processor essentially involves the substitution of one group of
characters or lines for another.
2. Write notes on
macro definition and expansion?
Two assembler
directives are used in macro definitions. The first MACRO statement identifies
the beginning of a macro definition. The second MEND assembler directive marks
the end of the macro definition.
RDBUF
MACRO &INDEV,&BUFADR,&RECLTH
TD
=X’ &INDEV’
MEND
In the above source
code, the symbol in the label field (RDBUF) is the name of the macro, and the
entries in the operand field identify the parameters of the macroinstruction.
3. What are the data structures involved in
macro processor?
DEFTAB
– macro definition table, the macro definitions are stored in this table.
NAMTAB – macro names are entered into this table. It is served as the index to
DEFTAB. ARGTAB – argument table, which is used during the expansion of macro
invocation.
4.
Write the procedure PROCESSLINE in the one-pass macro processor algorithm?
Procedure PROCESSLINE Begin Search NAMTAB for OPCODE
If
found then
EXPAND
Else if OPCODE = ‘MACRO’ then
DEFINE
Else write source line to expanded file
end
Else if OPCODE = ‘MACRO’ then
DEFINE
Else write source line to expanded file
end
5. What are the
features of machine independent macro processors?
The various features are
·
Concatenating macroinstruction
parameters with other character strings.
·
Generating unique
labels within macro expansions, which avoid the need for extensive use of
relative addressing.
·
Macro expansions.
This ability is to alter the expansion of a macro by using control statements.
·
The definition
and use of keyword parameters in macroinstructions.
6. How concatenation
of macro parameters is performed?
Most macro processors allow parameters to be concatenated
with other character strings. The following statement will do the concatenation
DA X&ID1
In which the parameter &ID is concatenated after the
character string X and before the character string 1.
One problem about this is that the beginning of the macro
parameter is identified by the starting symbol & , however the end of the
parameter is not marked.
Most macro processors deal with this problem by providing a
special concatenation operator. In SIC macro language, this
operator is the character � . Thus the previous statement would be written as
LDA X&ID�1
7. Write notes on
generation of unique labels in macroprocessors?
The
duplicate definition would prevent correct assembly of the resulting expanded
program. Many macro processors avoid these problems by allowing the creation of
special types of labels within macro instructions.
Labels used within the macro body begin with the special
character $. Each symbol beginning with $ has been modified by replacing $ with
$AA. More generally the character $ will be replaced by $xx, where xx is a two
character alphanumeric counter of the number of macro instruction expanded. For
example AA,AB,AC, etc.
8. Write the conditional statement in macros?
The use of macro time variable makes it clear that the same
logical condition is involved in to IF statements. Examining the values of the
variable may also be faster than repeating the original test.
The implementation of conditional macro expansion is very
simple. The macro processor must maintain a symbol table that contains the
values of all macro time variables used. The table is used to look up the
current value of a macro time variable whenever it is required.
The testing of Boolean expression in IF statements occur at
the time macros is expanded.
9. Write notes on WHILE statement in macros?.
The WHILE statement specifies that the following lines ,
until the next ENDW statement ate to be generated repeatedly as long as the
looping are done while true.
Ex:
WHILE (&CTR � &EORCT)
WHILE (&CTR � &EORCT)
ENDW
When a WHILE statement is encountered during macro
expansion, the specified Boolean expression is evaluated. If the value of this
expression is FALSE the macro processor skips ahead until it finds the next
ENDW statement, and then resumes normal macro expansion. If the value of this
expression is TRUE, the macro processor continues to processes lines in the
usual way until the next ENDW statement. Then proceed to the WHILE for
revaluation.
This method does not allow for nested WHILE structures.
10. Write notes on conditional macro expansion?
Most
macro processors, however, can also modify the sequence of statements generated
for a macro expansion, depending on the arguments supplied in the macro
invocation.
The term conditional
assembly is commonly used to describe this feature.
11.
Define macro time variable?
&EORCK
SET 1
The symbol &EORCK is a macro time variable, which can
be used to store working values during the macro expansion. Any symbol that
begins with the character & and that is not a macro instruction parameter
is assumed to be a macro-time variable. All such variables are
initialized to a value of 0.
The use of macro time variable makes it clear that the same
logical condition is involved in to IF statements. Examining the values of the
variable may also be faster than repeating the original test.
12. Write notes on positional parameters in
macroprocessors?
The macro definitions defined in ordinary way are positional
parameters. That is, the parameters and arguments were associated with
each other according to their positions in the macro prototype and the macro
invocation statement.
GENER
,,DIRECT,,,,,3.
13. Write notes on Keyword parameters in macroprocessors?
If a macro has a large number of parameters, and only a few
of these are given values in a typical invocation. A different form of
specification is useful. This is called keyword parameters. In
keyword parameters each argument value is written with a keyword that names the
corresponding parameters.
RDBUF MACRO &INDEV = F1, &BUFADR=, &RECLTH=,
&EOR = 04, &MAXLTH = 4096
14. How to invoke the macro which has keyword parameters?
In the macro prototype, each parameter name is followed by
an equal sign, which identifies a keyword parameter. After the equal sign, a
default value is specified for some of the parameters. The parameter is assumed
to have this default value if its name does not appear in the macro invocation
statement.
GENER TYPE = DIRECT,CHANNEL = 3.
15.
How to define one macro instruction in another macro?
16.
How to invoke a macro by another by another macro?
It is also possible to define one macro instruction in
another macro.
MACROS
|
MACRO
|
{ ---}
|
RDBUF
|
MACRO
|
&INDEV,&BUFADR,&RECLTH
|
MEND
|
||
MEND
|
The invocation of macro by another is as follows RDBUF
MACRO &BUFADR, &RECLTH, &INDEV
RDCHAR &INDEG
MEND
17. What happened when we apply
one pass macro processor algorithm for invocating a macro by another macro?
When
we apply the one pass macro processor algorithm for invocation of a macro by
another in the above macro code, the procedure EXPAND would be called when the
macro was recognized. The arguments from the macro invocation would be entered
into ARGTAB. The Boolean variable EXPANDING would be set to TRUE, and expansion
of the macro invocation would begin.
18. Write notes on general
purpose macro processors?
These
are not depend on any particular programming language, but can be used with a
variety of different languages. Advantage of general purpose of macro processor
is that the programmer does not need to learn about a different macro facility
for each compiler of assembler language, so much of the time and expenses
involved in training are eliminated.
19. What are the problems in
general purpose macro processors?
A
more general problem involves the tokens of the programming language. The
restriction on the length of identifiers and the rules for the formation of
constants. Another problem is the syntax used for macro definitions and macro
invocation statements.
20. What is a line by line
macro processor?
Using
this approach, the macro processor reads the source program statements and
performs all of its function as usual. However, the output lines are passed to
the language translator as they are generated, instead of being written to an
expanded source file.
21. What are the advantages of
line-by-line macro processor?
It
avoids making an extra pass over the source program, so it can be more
efficient than using a macro preprocessor. Some of the data structures required
by the macro processor and the language translator can be combined. A
line-by-line macro processor can also makes it easier to give diagnostic
messages that are related to the source statement containing error.
22. What is an integrated macro
processor?
The main form of communication between the two functions is
the passing of source statements form one to another. It is possible to have
even closer cooperation between the macroprocessor and the assembler or
compiler. Such a scheme can be thought of as a language translator with an
integrated macro processor.
An integrated macro processor can potentially make use of
any information about the source program that is extracted by the language
translator.
23. Write notes on MASM Macro processor?
The macro processor of MASM is integrated with pass1 of the
assembler. It supports all of the main macro processor functions, including the
definition and invocation of macro instructions within macros.
The comment line which begins with ;; is a macro comment.
It serves only as documentation for the macro definition, it is ignored when
the macro is expanded. The comment line begins with ; is an ordinary assembler
language comment.
24. Write notes on ANSI C Macro language?
In the ANSI C language, definition and invocations of
macros are handled by a preprocessor. This preprocessor is generally not
integrated with the rest of the compiler.
Two exampled of ANSI definitions are
# define NULL 0
# define EOF (-1)
# define EOF (-1)
After these definitions appear in the program, every
occurrence of NULL will be replaced by 0, and every occurrence of EOF will be
replaced by (-1).
ANSI macros can also be defined with
parameters.
# define ABSDIFF(X,Y) ((X) > (Y) ? (X)
– (Y) : (Y) –(X) )
25. Write notes on ELENA Macro processor?
ELENA was developed as a research tool, not as a commercial
software product.
Macro
definitions in ELENA are composed of a header and a body, as with most macro
processors. It consists of a sequence of keyword and parameter markers.
ELENA also provides macro-time variables and macro-time
instructions that can be used to control the macro expansion.
The ELENA macro processor uses a macro definition table
that is similar to the one we discussed for SIC. The macro is identified by the
sequence of keywords that appear in its header.
Subscribe to:
Posts (Atom)