CSE 331 Computer Architecture Lecture 02 PDF
Document Details
Uploaded by Deleted User
null
Dr Ayman
Tags
Summary
This document is a lecture on Computer Architecture, specifically focusing on the conversion of high-level programming languages to machine language and related topics such as data representation and program translation. It covers fundamental concepts and introduces critical elements of computer science.
Full Transcript
Welcome to CSE 331 Computer Architecture Agenda Converting High Level Languages to Machine Language Program translation process Data Representation (Number System) of Unsigned Positional Number Systems Define the decimal, binary, octal, and hexadecimal numbering systems and be able to con...
Welcome to CSE 331 Computer Architecture Agenda Converting High Level Languages to Machine Language Program translation process Data Representation (Number System) of Unsigned Positional Number Systems Define the decimal, binary, octal, and hexadecimal numbering systems and be able to convert from one numbering or coding system to another. Define the terms bit, byte, word, least significant bit (LSB), and most significant bit (MSB) as they apply to binary memory locations Fractions (Binary, Decimal) © 2016 Pearson Education, Inc., Hoboken, NJ. All rights reserved. Converting High Level Languages to Machine Language High level languages (HLLs), like C, C++,Python and Java, are designed to be written and read by humans. However, computer hardware can’t understand HLLs, so it translates HLL programs into machine language (ML). MLs are languages consisting of two numbers—1s and 0s. We refer to each “letter” as a binary digit or bit. Because of to speak to electronic hardware, you need to send electrical signals. Computer hardware understands only 1’s and 0’s, so instructions are encoded as binary numbers in a format called a machine language. An instruction set architecture (ISA), which serve as an interface between hardware and software, define every ML. Common ISAs include ARM, MIPS, RISC-V, and 80×86). Machine Language (ML) and Machine Code Machine Code also called object code or executable code. ML and “machine code” are often used as synonyms. However, machine language != machine code. A program’s ML is the language it is written in (e.g., MIPs), while a specific program converted to an ML is machine code. i.e. Machine code is a specific instance of a program (that might be written in MIPS assembly), while MIPS assembly is machine language. Think of machine code as a book (i.e., a program) written in English (i.e., a machine language). Program translation process Created by Warren R. Carithers; styled by Olivia Gallucci. https://oliviagallucci.com/converting-high-level-languages-to-machine-language/ High Level Program to Machine Level Compilation Compiler It is a program that translates each HLL statement into assembly language statements (RISC-V, MIPS..etc.) or machine code. Compiler translates higher programming language directly into machine instructions of the target processor Cross-compilation: program translation for a different processor ISA than is used on machine to compile program Assembler an assembler is a program that translates the symbolic instructions to binary instructions (ML code format) inside an object module (again, ML format). Programming in assembler (assembly language) is often inefficient, hard, takes a long time and application is fixed to one ISA. Assembly Language provides a symbolic representation of machine instructions. Instructions are commands that computer hardware understands and obeys. High Level Program to Machine Level Compilation Linker Once the assembler produces one or more object modules, the linker takes these object modules and library, and outputs an executable load module (ML format). This executable module is commonly referred to as an “executable” or “executable file,” and it can be run by users on the operating system. Loader and memory The loader is a program in the operating system; it gets the program ready to be ran in memory. i.e. Once the program reaches the loader step, it is an executable (ML format). In other words, the file has to already be an executable in order to go into the loader. High Level Program to Machine Level Compilation A computer program that translates a HLL into machine language is commonly known as a "compiler" or an "interpreter.“ Both compilers and interpreters perform the essential task of translating human-readable high-level programming languages into machine-readable code that the computer's CPU can understand and execute. The choice between using a compiler or an interpreter often depends on the programming language, its purpose, and specific project requirements. Compilers and Interpreters A compiler is a software tool that translates the entire source code written in a high-level programming language into machine code in a single step. The resulting machine code can be directly executed by the computer's CPU. Interpreter: translates and executes the source code line by line. It reads each line of high-level code, converts it into machine code, and immediately executes it. Interpreters are commonly used in scripting languages like Python, JavaScript, and Ruby. Compilers vs. Interpreter Interpreter. Compiler Interpreters usually take less amount of time Compilers usually take a large amount of time to analyze the source code. However, the to analyze the source code. However, the overall execution time is comparatively slower overall execution time is comparatively faster than compilers. than interpreters. No Object Code is generated, hence are Generates Object Code which further requires memory efficient. linking, hence requires more memory. Programming languages like JavaScript, Programming languages like C, C++, Java use Python, Ruby, and Basic use interpreters. compilers. Converting High Level Languages to Machine Language High level language … void main(void) C/C++ Language -readable { (Text Files) -machine independent cout