#CS536 classnote for Wednesday, April 23 #Dongqiao Li 1. About Jasmin Jasmin translates a JVM assembly file (*.j) into a JVM bytecode file (*.class). Each *.j file has three kinds of components: Directives: starting with '.'; Instructions: one per line, inludes both opcode and oprands; Labels: of the form 'id: ', on a seperate line. Example: .class public classname .super classname Java/Lang/Object .method public static F(II)V ldc 0 istore 1 ;stack is allocated per method basis .limit stack 25 ;be careful not to run out of stack limit .limit locals 1 ;only one local var used .end method Types used: B = Byte C = Char I = Int Z = Boolean V = Void [ = array of Lclasspath = as userdefined in calsspath Example: 1) void m(int,int) -> m(II)V 2) int f(String) -> f(Ljava/lang/String;)I 3) void m(int, int[]) -> m(I[I)V Hint: Can use unassebler Javap -c CLASS to search for desired JVM assembly code. 2. Code Generation 1) Write a cg() method for each AST node(some may be empty); 2) At the root of AST (classNode), create boolean codeGen(PrintStream asmFile). Utility routines are static members of ASTNode. Add a field to exprNode and SymbolInfo: int adr; One of: global local stack literal none Beginning from next class, we'll talk about the utility routines as well as the specific cg() methods for different classes.