search
Log In
9 votes
1.3k views

State whether the following statements are True or False with reasons for your answer:

  1. Coroutine is just another name for a subroutine.
  2. A two pass assembler uses its machine opcode table in the first pass of assembly.
in Compiler Design
edited by
1.3k views
5

Subroutine will always starts its execution from the beginning(first line) but a co-routine will start from where it left last time.

This is why we say, co-routine has multiple entry points whereas sub-routine has only one.

Yield 'remembers' where the co-routine is so when it is called again it will continue where it left off.

For example:

  coroutine foo {
    yield 1;
    yield 2;
    yield 3;
  }
  print foo();
  print foo();
  print foo();

Prints: 1 2 3

Note: Coroutines may use a return, and behave just like a subroutine

  coroutine foo {
    return 1;
    return 2; //Dead code
    return 3;
  }
  print foo();
  print foo();
  print foo();

Prints: 1 1 1

Source - Stack Overflow

4 Answers

8 votes
  1. True
    Subroutine are special cases of coroutine. Coroutine are generalized form of subroutine which is nonpreemptive multitasking
    https://en.wikipedia.org/wiki/Coroutine
  2. True. Basically machine opcode table is the symbol table which requires in 1st pass of two pass assembler
    http://users.cis.fiu.edu/~downeyt/cop3402/two-pass.htm

edited by
9
symbol table is created in first pass and it is used in second pass, (b) should be false
1
@srestha if coroutines are generalized form then can we say it is just another name of subroutine?It seems from your definition that coroutines can have multiples things and one of them is subroutine.So i think first is false
0
@ Arjun sir Please check it . I think that (b) is False.
1

@srestha i think 2nd statement is false 

http://users.cis.fiu.edu/~downeyt/cop3402/two-pass.htm

0

no @Sonam check these lines

scan the code twice. The first time, just count how long the machine code instructions will be, just to find out the addresses of all the labels. Also, create a table that has a list of all the addresses and where they will be in the program. This table is known as the symbol table.

0
This para also suggests that B is false right?
1

In pass 1, using Pseudo Opcode, POT is consulted for processing some pseudo opcode like DS, DC, START, END, etc

 

 

http://www.ques10.com/p/3118/with-reference-to-assembler-explain-following-ta-1/ 

@srestha read this. I think for part b answer is correct but explanation is wrong. Symbol table and opcode table are different.

0

for part b -In question MOT(machine opcode table)  is asked and Not symbol table ….It is used in both the passes hence true.

for pass 1 – it is used to get length of mnemonics and modify location counter.

for pass 2- it is used to obtain respective  machine code .

 

source- http://bcaq.blogspot.com/2013/02/draw-flowchart-for-pass-1-assembler-and.html

http://www.ques10.com/p/3118/with-reference-to-assembler-explain-following-ta-1/ 

 

Note-symbol table  and Literal table is created in first pass and it is used in second pass

 

2 votes

A. TRUE: A subroutine and a function are essentially the same thing, with one difference: A function returns some sort of value (usually via the stack or CPU register), while a subroutine does not. Whether subroutine or function, it is a block of executable code, having exactly one point of entry. A co-routine is also a block of executable code, and, just like a subroutine, it has one point of entry. However, it also has one or more points of re-entry.

ref: https://www.google.co.in/url?sa=t&rct=j&q=&esrc=s&source=web&cd=4&cad=rja&uact=8&ved=0ahUKEwjawbP86t3WAhWLOo8KHXxhCpsQFgg5MAM&url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F24780935%2Fdifference-between-subroutine-co-routine-function-and-thread&usg=AOvVaw3yAD5Td224hZer_CQWxfAQ

B. TRUE

0 votes
a) False

b) True
0 votes
A is true

B is False

Related questions

15 votes
2 answers
1
1.2k views
State whether the following statements are True or False with reasons for your answer A subroutine cannot always be used to replace a macro in an assembly language program. A symbol declared as ‘external’ in an assembly language program is assigned an address outside the program by the assembler itself.
asked Oct 6, 2014 in Compiler Design Kathleen 1.2k views
30 votes
2 answers
2
6.4k views
The pass numbers for each of the following activities object code generation literals added to literal table listing printed address resolution of local symbols that occur in a two pass assembler respectively are $1, 2, 1, 2$ $2, 1, 2, 1$ $2, 1, 1, 2$ $1, 2, 2, 2$
asked Oct 9, 2014 in Compiler Design Kathleen 6.4k views
14 votes
4 answers
3
2.4k views
A grammar $G$ is in Chomsky-Normal Form (CNF) if all its productions are of the form $A \to BC$ or $A \to a$, where $A,B$ and $C$, are non-terminals and $a$ is a terminal. Suppose $G$ is a CFG in CNF and $w$ is a string in $L(G)$ of length $n$, then how long is a derivation of $w$ in $G$?
asked Oct 6, 2014 in Compiler Design Kathleen 2.4k views
22 votes
4 answers
4
2.3k views
Match the following items ...
asked Oct 4, 2014 in Compiler Design Kathleen 2.3k views
...