1. What is Machine Language? In computer programming, machine code, consisting of machine language instructions, is a low-level programming language used to directly control a computer's central processing unit (CPU). Each instruction causes the CPU to perform a very specific task, such as a load, a store, a jump, or an arithmetic logical unit (ALU) operation on one or more units of data in the CPU's registers or memory.
2. What is Assembly Language? In computer programming, assembly language (or assembler language), often abbreviated asm, is any low-level programming language in which there is a very strong correspondence between the instructions in the language and the architecture's machine code instructions.- assembly depends on the machine code instructions.
- every assembler has its own assembly language which is designed for exactly one specific computer architecture.
- Assembly language may also be called symbolic machine code.
- assembly depends on the machine code instructions.
- every assembler has its own assembly language which is designed for exactly one specific computer architecture.
- Assembly language may also be called symbolic machine code.
pass1
input scanning, collect symbols, generate a token list
pass2
generate object code from the token list
input scanning
symbol table
The predefined symbols are opcode, r0..r31, conditional. the opcode is ld st jmp jal jr add sub mul div and or xor shl shr trap. conditional are: always eq neq lt le ge gt.
pass1
collect symbols and resolve referencebuild symbol table
store token list
token list is an array of tokens. Each token stores type, mode, reference and line number (refer to source code line number). line number is used in reporting an error. Type is sym num op dot. The mode is addressing mode: absolute, displacement, index, immediate, reg-reg, reg-imm, special.
For example ld r1 @lv1 base will generate the list of four tokens:
( notation : {type,mode,ref} )
{ {op,disp,ld}, {sym,reg,r1}, {sym,disp,lv1}, {sym,reg,base} }
pass 2
generate code from the token listthe output format is suitable for a loader of the simulator
a num set address
{l,d,x} num+ instruction
w num defined word
e end of file
Comments
Post a Comment