0% found this document useful (0 votes)
52 views2 pages

Assignment 1

This document contains 8 questions regarding assembly language code generated from Java code, the differences between compiler and interpreter output for Java code, using Flex to validate email addresses and mobile numbers, and counting lowercase characters in a string. The questions cover topics like writing assembly code for Java statements, showing compiler and interpreter output for a Java for loop, installing and using Flex to validate regular expressions, and comparing a Flex program to a program in another language for a text processing task.

Uploaded by

simranbehera2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
52 views2 pages

Assignment 1

This document contains 8 questions regarding assembly language code generated from Java code, the differences between compiler and interpreter output for Java code, using Flex to validate email addresses and mobile numbers, and counting lowercase characters in a string. The questions cover topics like writing assembly code for Java statements, showing compiler and interpreter output for a Java for loop, installing and using Flex to validate regular expressions, and comparing a Flex program to a program in another language for a text processing task.

Uploaded by

simranbehera2004
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Assignment-1

Q-1: Write the assembly language code for program given below by using one register and two temporary
locations

a = b + c * d;

Comment the instructions for better understanding

Ans:

Q-2: Show the output of a Java native code compiler, in any typical assembly language, for the following Java input
string using one register

while (x<a+b) x = 2*x;

Ans:

Q-3:Show the compiler output and the interpreter output for the following Java source code:

for (i=1; i<=4; i++) System.out.println (i*3);

Solution:
Compiler Output

Interpreter Output

Q-4: Show assembly language for a machine of your choice, corresponding to


each of the following Java statements:
(a) a = b + c;
(b) a = (b+c) * (c-d);
(c) for (i=1; i<=10; i++) a = a+i;

Q-5: Show assembly language for a machine of your choice, corresponding to


each of the following Java statements:
(a) a = b + c;
(b) a = (b+c) * (c-d);
(c) for (i=1; i<=10; i++) a = a+i;

Q-6: Which of the following Java source errors would be detected at compile
time, and which would be detected at run time?
(a) a = b+c = 3;
(b) if (x<3) a = 2
else a = x;
(c) if (a>0) x = 20;
else if (a<0) x = 10;
else x = x/a;
(d) MyClass x [] = new MyClass[100];
x[100] = new MyClass();

Q-7: Install Flex in Linux or Windows machine. (With Introduction to the


Flex lecture)
Q2. (i) Write a regular expression for a valid mobile number (pen and
paper). Then, write a program in Flex to recognize a valid mobile
number. (ii) Write a regular expression for a valid email address (with pen and
paper). Then, write a program in Flex to recognize a valid email
address. (iii) Following the problem statement of (b), the valid email address
should contain at least 3 and at most 10 characters before @, write
a program in Flex to recognize it. (iv) Finally, to feel the power of (new language)
Flex, write a program for any of the above problems with a known programming
language.

Q-8: Write a program in Flex to count the number of lowercase


characters in a string. (ii)Again, to feel the power of Flex (in general to process the
text), write a program for the above problem with a known
programming language.

You might also like