170 likes | 256 Views
Ştefan Stăncescu. First part System Utilities. Lecture 3 ASSEMBLER. ASSEMBLER. von Neumann architecture : Stored program computer (H/W): CPU(ALU+REG+PC+CPU_CTRL) + MEM + I/O Shared memory <= data + code (program) all in binary CPU(H/W) works only on a dedicated instruction set
E N D
Ştefan Stăncescu First partSystem Utilities Lecture 3 ASSEMBLER
ASSEMBLER • von Neumann architecture : • Stored program computer (H/W): CPU(ALU+REG+PC+CPU_CTRL) + MEM + I/O • Shared memory <= data + code (program) all in binary • CPU(H/W) works only on a dedicated instruction set • Object program: • list of activities carried out by the CPU and rest of H/W • list of simple CPU instructions, all in binary • => flexibility by creative lists of fixed instructions • => complex activities => complex applications
ASSEMBLER • Flexibility => changing the list of microinstruction - binary • (running different programs on same H / W) • Program object (S/W - in binary) • directly controls the machine (vN) • for a given (complex) application • Application on the vN machine • “code” processes "data" - in binary • in same memory space - in binary • takes data in => data out - in binary • ALL BINARY
ASSEMBLER • The human programmer - creator of useful applications • Originally used binary model (1/0) of vN architecture • for the faithful exact copy of the H/W vN machine • => machine language. • difficult to understand even for simple programs. • For readability, another vN machine model, abstract (MV?) • w/human readable signs: • literal mnemonic for instructions op-codes • alphanumerical identificators (+-*/ operators, :; etc. ) • => assembly language • Between the two languages - bi-univocal correspondence
ASSEMBLER • Source program – solution representation of some problem • draft list of standardized CPU intelligible activities • organized as a list of H/W instructions of the vN machine • A program line format => instruction mnemonic + operands • strongly attached to the H/W structure of vN machine • Assembly language: • mechanism of solutions representation • with mnemonic instructions ("opcode") • with literal representation of H/W circuit activity • human understandable - the first level of abstraction
ASSEMBLER • Assembling a source program to machine language • => automatic operation of passing from • literal representation of mnemonic instructions to • binary representation of instructions • Human intelligibility (literal A-Z a-z 1-9 + / * -., “ etc.). • to machine intelligibility (vN machine - binary - 1/0) • Assembler – S/W system utility that automate assembling • automatically translate - source files => object files • (+ additional means of development - list, sym, etc)
ASSEMBLER • Format type of one line from assembly source file language : • tag: op-code operands ;comment • Essential operation of an assembler: • converting • source file (lines of characters) to • object file (their equivalent binary representation) • Adjacent lines in the source file => • => adjacent bytes in object file • Result of assembly = binary representation of the solution • = vN machine understandable (executable) = • = the "object" file (program in “image memory”) .
ASSEMBLER • The “data” in assembly language • data structures varying in sizes and structure • ex. complex structures - strings, arrays, etc. • Assembler invents for them and for programmer help, • operations that not exist in H/W, called • “pseudo instructions” or “pseudo functions” • as abstract maneuvers, operations that not exist in H/W, • facilities of programming, addressing, etc. called • “directives”
ASSEMBLER • Object files are intermediate products of assemblers • Object file formats are • data structures for machine code loaders • intended to be processed by the link-loaders as • system utilities dedicated for • loading in machine physical memory and for • starting the corresponding process as active • solution from the initial program source • Auxiliary formats and products: list file, symbol list, etc. • for interactive operations as development, debug, test, etc.
ASSEMBLER Data structures of one assembler • OPTABop-codestable • R/O table with symbolic names (mnemonics) of microinstructions fixed by the structure of H/W (uP). • SYMTABsymbolic names table, • R/W table, with attributes of the symbols and names invented by programmer or deducted from solution program, with content specific for each application • determined by the programmer imagination; • table fulfilled before binary conversion by • scanning the source file and • finding the names invented by programmer. • LOCCTR instruction location memory counter
ASSEMBLER Operations performed in the first assembler pass • setting addresses in the memory space of the CPU for all source program instructions using LOCCTR; • setting addresses LOCTTR labels and save them in SYMTAB; • calculation expressions that define symbols; • fulfillment of directives as RESB, RESW, DB, DW; • implementation of the amending directives of the current address in the program with LOCCTR; • grammatical control of the source file in accordance with assembly language grammar used in reporting errors.
ASSEMBLER Operations performed in the second assembler pass • translate the mnemonic instructions into machine code using OPTAB; • operands calculation in expressions, replacing the symbols with attributes from SYMTAB; • generate data according to directives DB, DW; • execution of other directives; • format the obtained file object as a standard format suitable to linker and loader; • format the listing file with information required for documentation and debugging the program, including addresses, conversions, assembly error codes, etc.