SAL (Simple Abstract Language) In the following, x must be a register or the label of an address in memory. However, y and z may be registe(y), labels or constants. (y) implies "contents of y". 1. INSTRUCTIONS Call Arg 1 Arg 2 Arg3 Operation add x y z (x) <- (y) + (z) and x y z (x) <- (y) AND (z) b label PC <- (label) beq y z label PC <- (label) if (y) = (z) beqz y label PC <- (label) if (y) = 0 bge y z label PC <- (label) if (y) >= (z) bgez y label PC <- (label) if (y) >= 0 bgt y z label PC <- (label) if (y) > (z) bgtz y label PC <- (label) if (y) > 0 ble y z label PC <- (label) if (y) <= (z) blez y label PC <- (label) if (y) <= 0 blt y z label PC <- (label) if (y) < (z) bltz y label PC <- (label) if (y) < 0 bne y z label PC <- (label) if (y) != (z) bnez y label PC <- (label) if (y) != 0 cvt x y x <- (y) with type conversion div x y z (x) = (y) DIV (z) done stop running; return control to OS get x (x) <- value typed on keyboard getc x (x) <- ASCII code of value typed on keyboard j label PC <- (label) la x label (x) <- address of label move x y (x) <- (y) mul x y z (x) = (y) * (z) nop no operation nor x y z (x) = (y) NOR (z) or x y z (x) = (y) OR (z) put x write (x) to the screen putc y write character with ASCII code = (y) on the screen puts string write (string) to the screen* rem x y z (x) <- (y) MOD (z) rol x y sa (x) <- (y) rotated left by sa bits ror x y sa (x) <- (y) rotated right by sa bits sll x y sa (x) <- (z) shifted left by sa bits sra x y sa (x) <- (z) shifted right by sa bits, sign-extended srl x y sa (x) <- (z) shifted right by sa bits, 0-extended sub x y z (x) <- (y) - (z) xor x y z (x) <- (y) XOR (z) *string must be NULL terminated, like a variable declared with a .asciiz directive Reference: James Goodman and Karen Miller, "A Programmer's View of Computer Architecture" (Saunders College Publishing, 1993) 2. ASSEMBLER DIRECTIVES .data what follows are initial data .text what follows are instructions label: .ascii string A string is placed in memory (one byte per character) starting at location label. string is an ASCII string enclosed in double quotes (" "). label: .asciiz string A NULL-terminated string is placed in memory (one byte per character) starting at location label. string is an ASCII string enclosed in double quotes (" "). label: .byte value[:num_elements] An ASCII character (initially containing value) is located at label. A character value is specified by enclosing the character in single quotes. value is an optional field; if it is omitted, then the word at label is initialized to 0. If num_elements is present, it specifies the number of words to be allocated and initialized to value. label: .float value[:num_elements] AN IEEE single-precision floating- point number (initially containing value) is located at label. value is an optional field; if it is omitted, then the word at label is initialized to 0. If num_elements is present, it specifies the number of bytes to be allocated and initialized to value. label: .space number_of_bytes A section of memory consisting of number_of_bytes bytes and starting at location label is initialized and set aside. label: .word value[:num_elements] 2's complement integer (initially containing value) is located at label. value is an optional field; if it is omitted, then the word at label is initialized to 0. If num_elements is present, it specifies the number of bytes to be allocated and initialized to value.