Podcast
Questions and Answers
Which directive in assembly language is used to declare a string variable?
Which directive in assembly language is used to declare a string variable?
What is the purpose of the '.word' directive in assembly language?
What is the purpose of the '.word' directive in assembly language?
Which register in assembly language is recommended for main program variables?
Which register in assembly language is recommended for main program variables?
What should be done with registers designated as 'preserved across calls' before and after a subprogram call?
What should be done with registers designated as 'preserved across calls' before and after a subprogram call?
Signup and view all the answers
Which category of registers should be avoided in assembly language due to their use by the operating system or assembler?
Which category of registers should be avoided in assembly language due to their use by the operating system or assembler?
Signup and view all the answers
What is the purpose of assembly language?
What is the purpose of assembly language?
Signup and view all the answers
Which type of instructions do assembly directives control?
Which type of instructions do assembly directives control?
Signup and view all the answers
What does the 'MOV' mnemonic represent in assembly language?
What does the 'MOV' mnemonic represent in assembly language?
Signup and view all the answers
Which directive in assembly language starts a data declaration section?
Which directive in assembly language starts a data declaration section?
Signup and view all the answers
What is the primary function of assembly directives?
What is the primary function of assembly directives?
Signup and view all the answers
Study Notes
Assembly language, also known as assembler language, is a low-level programming language that utilizes mnemonic codes representing machine code instructions for a specific computer architecture. It is an intermediate language between human-readable source code and the machine code that can be directly executed by the computer. Assembly language provides a way to write programs without the need to understand the underlying machine code, making it easier to program directly at the level of machine instructions.
Instructions
Assembly language consists of instructions that directly correspond to the machine instructions of the target computer architecture. These instructions are written using mnemonic codes, which are short, easily-remembered abbreviations for the machine code instructions. For example, the "MOV" mnemonic represents the "Move" instruction, which copies the value from one register to another.
Assembly Directives
Assembly directives are instructions to the assembler itself, specifying actions to be taken during the assembly process. They do not directly correspond to machine instructions but are used to control the behavior of the assembler. Assembly directives can be used to declare variables, reserve memory, break up the program into sections, and specify other tasks related to the assembly process.
For instance, the ".data" directive starts a data declaration section, while the ".text" directive starts an instruction section. The ".globl" directive declares labels to be global, which is useful for ensuring that the program starts executing at the correct address. The ".word" directive declares a C int variable, specifying an initial value and the number of repetitions. The ".asciiz" directive declares a string variable, enclosing the string in double quotes.
Registers
Assembly language uses a variety of registers, each with different purposes. For simple programs, it is recommended to use registers such as $zero for the constant 0, $s0 - $s8 for main program variables, $t0 - $t8 for subprogram variables, $a0 - $a3 for subprogram and syscall parameters, and $v0, $v1 for subprogram return values and syscall codes and return values.
For more complex programs, there are register usage conventions that specify how main programs and subprograms should coordinate their use of registers. Registers designated as "preserved across calls" should be saved and restored before and after a subprogram call, while registers designated as "not preserved across calls" can be used freely by subprograms without the need to save and restore their values. Registers designated as "dangerous to use" should be avoided, as they are used either by the operating system or the assembler.
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.
Description
Test your knowledge of assembly language fundamentals, including instructions, assembly directives, and registers. Learn about mnemonic codes, declaration directives, register conventions, and more.