Understanding Assembly Language: Instructions and Assemblers
Understanding Assembly Language
Assembly language is a low-level programming language where instructions are written using mnemonic codes rather than binary machine language. An assembler translates these instructions into executable machine code.
Classification of Assembly Instructions
Assembly language instructions are categorized into three primary types:
- Imperative Statements (IS): Specify operations for the processor to perform. These generate executable machine code. Examples include:
STOP,ADD,SUB,MULT,MOVER,MOVEM,COMP,BC,DIV,READ, andPRINT. - Declarative Statements (DL): Used for memory allocation and data definition.
DS(Define Storage) reserves memory locations, whileDC(Define Constant) stores a constant value in memory. - Assembler Directives (AD): Provide instructions to the assembler and do not generate machine code. Key directives include:
START(starting address),END(program termination),ORIGIN(changes Location Counter),EQU(assigns values to symbols), andLTORG(allocates storage for literals).
The Location Counter (LC)
The Location Counter (LC) is used by the assembler to assign addresses to instructions and data. It is initialized by the START directive and increments as each instruction is processed. Declarative statements reserve memory, and literals receive addresses when LTORG or END is encountered.
Example Program Analysis
START 200 LOOP MOVER AREG, ='5' ADD AREG, NUM MOVEM AREG, RESULT SUB AREG, ='1' BC ANY, LOOP NUM DC 10 RESULT DS 1 END
LC Processing Breakdown:
STARTinitializes LC to 200.MOVER(200),ADD(201),MOVEM(202),SUB(203),BC(204).NUM(DC) receives address 205;RESULT(DS) receives address 206.- At
END, literals are assigned:='5'(207) and='1'(208).
Symbol and Literal Tables
- Symbol Table: Stores symbol names and their addresses (e.g.,
LOOP: 200,NUM: 205,RESULT: 206). - Literal Table: Stores literals and their assigned addresses (e.g.,
='5': 207,='1': 208).
During Pass I of the assembler, LC processing is performed, and the Symbol and Literal Tables are generated to facilitate machine code generation.
English with a size of 2.8 KB