Low-level Programming Language Review on Machine Cycle Long long time ago… Each cycle includes four steps: 1. Fetch register 2. Decode 3. Execute 4. Store => an instruction is executed (completed)!! Register (accumulator) Instruction One instruction Eg. 1011 1001 0011 0100 0001 0010 ~One machine cycle Levels of programming language High level language(3GL,4GL) Low level language *Assembly language(2GLs) assembler *Machine language(1GLs) CPU 1st-generation languageMachine languages The format of an instruction Eg. Load a value into register 8, taken from the memory cell 68 cells after the location listed in register 3 : [opcode|source|destination| memory address ] 35 3 8 68 100011 00011 01000 00000 00001 000100 Opcode Operands * The format of a instruction : opcode + operand(S) decimal binary 1st-generation languageMachine languages The format of an instruction *Opcode : (operation code) -indicate the command (instruction) to be executed ~ NAME OF THE FUNCTION *Operands: -indicate the registers, values or memory addresses used in the function ~PARAMETER 1st-generation languageMachine languages Features: 1. Understood and executed by a computer at once - binary code =>tedious 2. Each statement represents one instruction => lengthy 3 * Machine-dependent Platform-dependent (each model of CPUModels has oftheir own CPU (intel) instructionEg.set) X86 machine language 1011 1001 0011 0100 0001 0010 1st-generation languageAssembly language * The format of a instruction also consists : opcode + operand(S) Example : Set CX register to be 1234H Mov CX, 1234H Opcode Operands Opcode : makes use of mnemonics (~memory aid) -”looks” like the meaning -symbolic and meaningful Mnemonics Opcode Operand meaning INP XXX Input data to XXX OUT XXX Output content of XXX STA XXX Store accumulator to XXX LDA XXX Load acc. with content of XXX INC XXX Increment content of XXX by 1 DEC XXX Decrement content of XXX by 1 JPN XXX Jump to address XXX For your reference only! 1st-generation languageAssembly language Features: 1. 1 instruction in assembly language = 1 instruction in machine language => still lengthy 2. Machine-dependent => not portable 3. Easier to be understand and remember (make use of meaningful codes like mnemonics) Machine language V.S. Assembly language • Similarities – Lengthy – Machine independent • Low portability – Execute quickly • Difference – 2GLs uses meaningful codes • Easier to remember • Can be written comparatively efficiently • Less errors – 2GLs need to be translated before running Application?? • Why learning assembly language is still a good idea? • system programs – driver programs – utility programs