hws/hw08.tex
changeset 941 66adcae6c762
parent 916 10f834eb0a9e
child 956 ae9782e62bdd
--- a/hws/hw08.tex	Thu Oct 05 14:36:54 2023 +0100
+++ b/hws/hw08.tex	Fri Oct 13 15:07:37 2023 +0100
@@ -19,6 +19,38 @@
 \item What is the main difference between the Java assembler
       (as processed by Jasmin) and Java Byte Code?
 
+\item Remember symbolic labels in the Jasmin-assembler are meant to
+      be used for jumps (like in loops or if-conditions). Assume
+      you generated a Jasmin-file with some redundant
+      labels, that is some labels are not used in your code for any jumps. For
+      example \texttt{L\_begin} and \texttt{L\_end} are not used
+      in the fol,lowing code-snippet:
+
+\begin{lstlisting}[language=JVMIS,numbers=none]
+L_begin:        
+ldc 1
+ldc 2
+ldc 3
+imul
+ldc 4
+ldc 3
+isub
+iadd
+iadd
+L_end:
+\end{lstlisting}
+      
+      Do these redundant labels affect the size of the generated
+      JVM-code? (Hint: What are the labels translated to by
+      the Jasmin-assembler?).
+
+      \solution{The answer is no. The reason is that assemblers
+        calculate for labels either relative or explicit adresses,
+        which are then used in the JVM-byte-code. Relative addresses
+        are like ``jump 10 bytes forward'' or ``12 bytes backward''. So
+      additional labels do not increase the size of the generated code.}
+
+      
 \item Consider the following Scala snippet. Are the two functions
 \texttt{is\_even} and \texttt{is\_odd} tail-recursive?