This slides present a knowledge of computer, memory, programming languages etc. That is required before learning C programming language.
http://www.learnbywatch.com
The document provides information about a C programming module including:
- It is a 15 credit module comprising 50 hours of lectures and 50 hours of self-study.
- Assessment includes a CAT worth 60 marks and a final exam worth 40 marks.
- The module aims to teach students how to write and debug C programs, structured program design, and use C language constructs to solve problems in various areas.
The document discusses computer programming in C. It provides:
1) An overview of computer architecture including the input unit, central processing unit, output unit, primary memory, secondary memory, and control unit.
2) Details on different units of memory including bits, bytes, kilobytes, megabytes, gigabytes, and terabytes.
3) An explanation of key concepts in C programming including data types, variables, operators, control structures, functions, and pointers.
4) The importance of C including its portability, ability to do low-level programming, use in operating systems, and support for memory management.
This document provides an overview of programming fundamentals with C++. It discusses basic concepts like computer programs, software, SDLC, programming languages, programmers, translators, source and object code, and the fetch-decode-execute cycle. It also covers basic concepts of C++ like what C++ is, the differences between C and C++, a brief history of C++, popular IDEs for C++, and the basic structure of a C++ program. The document concludes with references for further learning about C++ programming.
C is a general-purpose programming language developed in the 1970s. It produces very fast executable code and is widely used for operating systems, compilers, and many other applications. Some key reasons for its popularity include its portability, ability to access hardware directly, and large existing code base. The document provides an overview of C's history, why it is still useful today, basic C program structure, and other programming concepts like tokens, keywords, identifiers, and constants.
The document provides an overview of computers and programming languages, describing the hardware and software components of a computer system, the evolution of programming languages from machine code to modern high-level languages like C++, and the typical process of analyzing a problem, designing an algorithm to solve it, implementing the algorithm in code, and executing the program. It also gives examples of algorithms for calculating the perimeter and area of a rectangle to illustrate the problem-solving approach.
This chapter provides an overview of computers and programming languages. It discusses the hardware and software components of a computer system and how a C++ program is processed. It also describes the evolution of programming languages from machine code to high-level languages like C++. Finally, it covers structured and object-oriented programming methodologies and how problems are solved through analysis, design of algorithms, and implementation in code.
Chapter 1 Introduction to computer componentsBoonsaaMulataa
The document provides an introduction to computer components and their functions. It discusses the basic definition of a computer, its main activities of input, processing, and output. It then describes the typical hardware components of a personal computer system, including the system unit, input/output devices, motherboard, power supply, drives, and adapter cards. It also gives an overview of software types like system software and application software, as well as programming languages at different levels including machine language, assembly language, and high-level languages. The document concludes by covering topics like algorithm development, pseudo code, flowcharts, and providing examples.
The document provides an introduction to C programming, including:
- The session objectives are to learn the elements of C programs, variable declarations and data types, operators and expressions, and input/output operations.
- The session topics include an introduction to C programming, the history of C, operators and expressions, and data input/output.
- C is a general purpose programming language invented by Dennis Ritchie in 1972 for implementing operating systems and has since been widely used for other applications as well.
C is a general-purpose programming language developed in the early 1970s. It was designed to be compiled using a minimal compiler for portability. C is still widely used today due to its speed, flexibility and ability to access low-level hardware which makes it suitable for system programming tasks like operating systems, language compilers, databases etc. The document provides an overview of the history and evolution of C, why it is still useful, basic C programming concepts like variables, data types, expressions and operators.
C is a general-purpose programming language developed in the early 1970s. It produces very fast executable code and is widely used for operating systems, language compilers, utilities and other system software. The document provides an overview of the history and development of C, why it is still useful today, basic C programming concepts like tokens, constants, variables and data types, and the overall structure and execution of a C program.
C is a general-purpose programming language developed in the early 1970s. It has been widely used for operating systems, language compilers, text editors and other system-level programs due to its high performance and portability. The document provides an overview of C programming basics including the history of C, why C is still useful today, C character set, tokens, constants, variables, data types, expressions and operators. It also describes the basic structure of a C program and the execution process.
Low level, High level and Middle level programming languages
,Bug and Debugging ,difference between compiler and interpreter,instructions and program,source code and object code ,language translators
This document discusses number systems and complement notation in computing. It begins by explaining that complement is the negative equivalent of a number. There are two types of complement: r's complement and (r-1)'s complement. Shortcut methods are provided for calculating both types of complement in various number systems like binary, octal, decimal, and hexadecimal. Examples are given to illustrate complement calculations. The document also discusses the use of complement for performing subtraction using addition.
The document provides an overview of a compilers design and construction course. It discusses the various phases of compilation including lexical analysis, syntax analysis, semantic analysis, code generation, and optimization. The course aims to introduce the principles and techniques used in compiler construction and the issues that arise in developing a compiler. The course will cover topics like lexical analysis, syntax analysis, semantic analysis, intermediate code generation, control flow, code optimization and code generation over its 12 weeks.
C is a general-purpose programming language widely used to develop operating systems and compilers. An algorithm is a finite sequence of instructions to solve a problem, with characteristics like precision, uniqueness, finiteness, inputs, outputs, and generality. Flowcharts use standard symbols to visually represent algorithms through a diagram. C was created to write the UNIX operating system and produces efficient, low-level programs that can be compiled on many machines.
Programming 8051 with C and using Keil uVision5.pptxShyamkant Vasekar
This document provides an introduction to embedded C programming using the Keil development environment. It defines embedded systems and describes how C became the dominant programming language for embedded applications. The document outlines the basics of embedded C, including common data types, compilers versus cross compilers, and how to set up a basic project in Keil uVision. It also includes examples of simple embedded C programs to blink an LED and output the maximum value from an array to a port.
Embedded c c++ programming fundamentals masterHossam Hassan
This document provides an overview of embedded C/C++ programming fundamentals. It discusses what embedded systems and microcontrollers are. It also discusses typical development tools and processes like compilers, linkers, and debugging. Several programming languages are discussed at different levels like machine code, assembly language, and high-level languages like C/C++. C/C++ are recommended for embedded programming due to efficiency and ability to access I/O while assembly is used for speed-critical code. The document also outlines basic C/C++ programming concepts like program structure with directives, declarations, and statements.
The document provides an introduction to assembly language and how it relates to high-level languages and machine language. It discusses how assembly language allows programmers to understand how computers work at a low level while still using mnemonics and symbolic addresses to write readable code. It provides an example of translating a simple math problem into assembly code for an Intel Pentium processor.
This document discusses the key components and characteristics of computer systems and programming languages. It begins by defining a computer as a machine that executes instructions to process data according to a program. It then covers the components of a basic computer system including the central processing unit (CPU), memory, input/output devices, and storage units. The document also discusses different types of programming languages from machine code to high-level languages. It provides examples of common programming languages and tools used for program development. Finally, the document outlines some important characteristics of good programming languages.
C is the building block for many other programming languages. Programs written in C are highly portable. Several standard functions are there (like in-built) that can be used to develop programs. C programs are collections of C library functions, and it's also easy to add functions to the C library.
Programming refers to creating a list of stored instructions that tell a computer what to do. A programming language provides a platform to describe computer jobs through instructions. There are two main categories of programming languages: high-level languages that are human-readable and easier for programmers, and low-level languages that are machine-oriented and provide better machine efficiency. C is a widely-used programming language that combines the virtues of high-level languages with low-level language efficiency. A basic C program structure includes standard libraries, a main function, and statements like printf to output text.
This document provides an introduction to programming concepts such as algorithms, pseudocode, and flowcharts. It defines computer programming as the process of writing code to instruct a computer, and explains that programming languages allow users to communicate instructions to computers. The document outlines different types of computer languages including low-level languages like machine language and assembly language, and high-level languages like procedural, functional, and object-oriented languages. It also discusses specialized languages, translator programs, and program logic design tools for solving problems algorithmically through pseudocode and flowcharts.
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...Infopitaara
A feed water heater is a device used in power plants to preheat water before it enters the boiler. It plays a critical role in improving the overall efficiency of the power generation process, especially in thermal power plants.
🔧 Function of a Feed Water Heater:
It uses steam extracted from the turbine to preheat the feed water.
This reduces the fuel required to convert water into steam in the boiler.
It supports Regenerative Rankine Cycle, increasing plant efficiency.
🔍 Types of Feed Water Heaters:
Open Feed Water Heater (Direct Contact)
Steam and water come into direct contact.
Mixing occurs, and heat is transferred directly.
Common in low-pressure stages.
Closed Feed Water Heater (Surface Type)
Steam and water are separated by tubes.
Heat is transferred through tube walls.
Common in high-pressure systems.
⚙️ Advantages:
Improves thermal efficiency.
Reduces fuel consumption.
Lowers thermal stress on boiler components.
Minimizes corrosion by removing dissolved gases.
This chapter provides an overview of computers and programming languages. It discusses the hardware and software components of a computer system and how a C++ program is processed. It also describes the evolution of programming languages from machine code to high-level languages like C++. Finally, it covers structured and object-oriented programming methodologies and how problems are solved through analysis, design of algorithms, and implementation in code.
Chapter 1 Introduction to computer componentsBoonsaaMulataa
The document provides an introduction to computer components and their functions. It discusses the basic definition of a computer, its main activities of input, processing, and output. It then describes the typical hardware components of a personal computer system, including the system unit, input/output devices, motherboard, power supply, drives, and adapter cards. It also gives an overview of software types like system software and application software, as well as programming languages at different levels including machine language, assembly language, and high-level languages. The document concludes by covering topics like algorithm development, pseudo code, flowcharts, and providing examples.
The document provides an introduction to C programming, including:
- The session objectives are to learn the elements of C programs, variable declarations and data types, operators and expressions, and input/output operations.
- The session topics include an introduction to C programming, the history of C, operators and expressions, and data input/output.
- C is a general purpose programming language invented by Dennis Ritchie in 1972 for implementing operating systems and has since been widely used for other applications as well.
C is a general-purpose programming language developed in the early 1970s. It was designed to be compiled using a minimal compiler for portability. C is still widely used today due to its speed, flexibility and ability to access low-level hardware which makes it suitable for system programming tasks like operating systems, language compilers, databases etc. The document provides an overview of the history and evolution of C, why it is still useful, basic C programming concepts like variables, data types, expressions and operators.
C is a general-purpose programming language developed in the early 1970s. It produces very fast executable code and is widely used for operating systems, language compilers, utilities and other system software. The document provides an overview of the history and development of C, why it is still useful today, basic C programming concepts like tokens, constants, variables and data types, and the overall structure and execution of a C program.
C is a general-purpose programming language developed in the early 1970s. It has been widely used for operating systems, language compilers, text editors and other system-level programs due to its high performance and portability. The document provides an overview of C programming basics including the history of C, why C is still useful today, C character set, tokens, constants, variables, data types, expressions and operators. It also describes the basic structure of a C program and the execution process.
Low level, High level and Middle level programming languages
,Bug and Debugging ,difference between compiler and interpreter,instructions and program,source code and object code ,language translators
This document discusses number systems and complement notation in computing. It begins by explaining that complement is the negative equivalent of a number. There are two types of complement: r's complement and (r-1)'s complement. Shortcut methods are provided for calculating both types of complement in various number systems like binary, octal, decimal, and hexadecimal. Examples are given to illustrate complement calculations. The document also discusses the use of complement for performing subtraction using addition.
The document provides an overview of a compilers design and construction course. It discusses the various phases of compilation including lexical analysis, syntax analysis, semantic analysis, code generation, and optimization. The course aims to introduce the principles and techniques used in compiler construction and the issues that arise in developing a compiler. The course will cover topics like lexical analysis, syntax analysis, semantic analysis, intermediate code generation, control flow, code optimization and code generation over its 12 weeks.
C is a general-purpose programming language widely used to develop operating systems and compilers. An algorithm is a finite sequence of instructions to solve a problem, with characteristics like precision, uniqueness, finiteness, inputs, outputs, and generality. Flowcharts use standard symbols to visually represent algorithms through a diagram. C was created to write the UNIX operating system and produces efficient, low-level programs that can be compiled on many machines.
Programming 8051 with C and using Keil uVision5.pptxShyamkant Vasekar
This document provides an introduction to embedded C programming using the Keil development environment. It defines embedded systems and describes how C became the dominant programming language for embedded applications. The document outlines the basics of embedded C, including common data types, compilers versus cross compilers, and how to set up a basic project in Keil uVision. It also includes examples of simple embedded C programs to blink an LED and output the maximum value from an array to a port.
Embedded c c++ programming fundamentals masterHossam Hassan
This document provides an overview of embedded C/C++ programming fundamentals. It discusses what embedded systems and microcontrollers are. It also discusses typical development tools and processes like compilers, linkers, and debugging. Several programming languages are discussed at different levels like machine code, assembly language, and high-level languages like C/C++. C/C++ are recommended for embedded programming due to efficiency and ability to access I/O while assembly is used for speed-critical code. The document also outlines basic C/C++ programming concepts like program structure with directives, declarations, and statements.
The document provides an introduction to assembly language and how it relates to high-level languages and machine language. It discusses how assembly language allows programmers to understand how computers work at a low level while still using mnemonics and symbolic addresses to write readable code. It provides an example of translating a simple math problem into assembly code for an Intel Pentium processor.
This document discusses the key components and characteristics of computer systems and programming languages. It begins by defining a computer as a machine that executes instructions to process data according to a program. It then covers the components of a basic computer system including the central processing unit (CPU), memory, input/output devices, and storage units. The document also discusses different types of programming languages from machine code to high-level languages. It provides examples of common programming languages and tools used for program development. Finally, the document outlines some important characteristics of good programming languages.
C is the building block for many other programming languages. Programs written in C are highly portable. Several standard functions are there (like in-built) that can be used to develop programs. C programs are collections of C library functions, and it's also easy to add functions to the C library.
Programming refers to creating a list of stored instructions that tell a computer what to do. A programming language provides a platform to describe computer jobs through instructions. There are two main categories of programming languages: high-level languages that are human-readable and easier for programmers, and low-level languages that are machine-oriented and provide better machine efficiency. C is a widely-used programming language that combines the virtues of high-level languages with low-level language efficiency. A basic C program structure includes standard libraries, a main function, and statements like printf to output text.
This document provides an introduction to programming concepts such as algorithms, pseudocode, and flowcharts. It defines computer programming as the process of writing code to instruct a computer, and explains that programming languages allow users to communicate instructions to computers. The document outlines different types of computer languages including low-level languages like machine language and assembly language, and high-level languages like procedural, functional, and object-oriented languages. It also discusses specialized languages, translator programs, and program logic design tools for solving problems algorithmically through pseudocode and flowcharts.
"Feed Water Heaters in Thermal Power Plants: Types, Working, and Efficiency G...Infopitaara
A feed water heater is a device used in power plants to preheat water before it enters the boiler. It plays a critical role in improving the overall efficiency of the power generation process, especially in thermal power plants.
🔧 Function of a Feed Water Heater:
It uses steam extracted from the turbine to preheat the feed water.
This reduces the fuel required to convert water into steam in the boiler.
It supports Regenerative Rankine Cycle, increasing plant efficiency.
🔍 Types of Feed Water Heaters:
Open Feed Water Heater (Direct Contact)
Steam and water come into direct contact.
Mixing occurs, and heat is transferred directly.
Common in low-pressure stages.
Closed Feed Water Heater (Surface Type)
Steam and water are separated by tubes.
Heat is transferred through tube walls.
Common in high-pressure systems.
⚙️ Advantages:
Improves thermal efficiency.
Reduces fuel consumption.
Lowers thermal stress on boiler components.
Minimizes corrosion by removing dissolved gases.
In tube drawing process, a tube is pulled out through a die and a plug to reduce its diameter and thickness as per the requirement. Dimensional accuracy of cold drawn tubes plays a vital role in the further quality of end products and controlling rejection in manufacturing processes of these end products. Springback phenomenon is the elastic strain recovery after removal of forming loads, causes geometrical inaccuracies in drawn tubes. Further, this leads to difficulty in achieving close dimensional tolerances. In the present work springback of EN 8 D tube material is studied for various cold drawing parameters. The process parameters in this work include die semi-angle, land width and drawing speed. The experimentation is done using Taguchi’s L36 orthogonal array, and then optimization is done in data analysis software Minitab 17. The results of ANOVA shows that 15 degrees die semi-angle,5 mm land width and 6 m/min drawing speed yields least springback. Furthermore, optimization algorithms named Particle Swarm Optimization (PSO), Simulated Annealing (SA) and Genetic Algorithm (GA) are applied which shows that 15 degrees die semi-angle, 10 mm land width and 8 m/min drawing speed results in minimal springback with almost 10.5 % improvement. Finally, the results of experimentation are validated with Finite Element Analysis technique using ANSYS.
Passenger car unit (PCU) of a vehicle type depends on vehicular characteristics, stream characteristics, roadway characteristics, environmental factors, climate conditions and control conditions. Keeping in view various factors affecting PCU, a model was developed taking a volume to capacity ratio and percentage share of particular vehicle type as independent parameters. A microscopic traffic simulation model VISSIM has been used in present study for generating traffic flow data which some time very difficult to obtain from field survey. A comparison study was carried out with the purpose of verifying when the adaptive neuro-fuzzy inference system (ANFIS), artificial neural network (ANN) and multiple linear regression (MLR) models are appropriate for prediction of PCUs of different vehicle types. From the results observed that ANFIS model estimates were closer to the corresponding simulated PCU values compared to MLR and ANN models. It is concluded that the ANFIS model showed greater potential in predicting PCUs from v/c ratio and proportional share for all type of vehicles whereas MLR and ANN models did not perform well.
The role of the lexical analyzer
Specification of tokens
Finite state machines
From a regular expressions to an NFA
Convert NFA to DFA
Transforming grammars and regular expressions
Transforming automata to grammars
Language for specifying lexical analyzers
its all about Artificial Intelligence(Ai) and Machine Learning and not on advanced level you can study before the exam or can check for some information on Ai for project
Raish Khanji GTU 8th sem Internship Report.pdfRaishKhanji
This report details the practical experiences gained during an internship at Indo German Tool
Room, Ahmedabad. The internship provided hands-on training in various manufacturing technologies, encompassing both conventional and advanced techniques. Significant emphasis was placed on machining processes, including operation and fundamental
understanding of lathe and milling machines. Furthermore, the internship incorporated
modern welding technology, notably through the application of an Augmented Reality (AR)
simulator, offering a safe and effective environment for skill development. Exposure to
industrial automation was achieved through practical exercises in Programmable Logic Controllers (PLCs) using Siemens TIA software and direct operation of industrial robots
utilizing teach pendants. The principles and practical aspects of Computer Numerical Control
(CNC) technology were also explored. Complementing these manufacturing processes, the
internship included extensive application of SolidWorks software for design and modeling tasks. This comprehensive practical training has provided a foundational understanding of
key aspects of modern manufacturing and design, enhancing the technical proficiency and readiness for future engineering endeavors.
We introduce the Gaussian process (GP) modeling module developed within the UQLab software framework. The novel design of the GP-module aims at providing seamless integration of GP modeling into any uncertainty quantification workflow, as well as a standalone surrogate modeling tool. We first briefly present the key mathematical tools on the basis of GP modeling (a.k.a. Kriging), as well as the associated theoretical and computational framework. We then provide an extensive overview of the available features of the software and demonstrate its flexibility and user-friendliness. Finally, we showcase the usage and the performance of the software on several applications borrowed from different fields of engineering. These include a basic surrogate of a well-known analytical benchmark function; a hierarchical Kriging example applied to wind turbine aero-servo-elastic simulations and a more complex geotechnical example that requires a non-stationary, user-defined correlation function. The GP-module, like the rest of the scientific code that is shipped with UQLab, is open source (BSD license).
Analysis of reinforced concrete deep beam is based on simplified approximate method due to the complexity of the exact analysis. The complexity is due to a number of parameters affecting its response. To evaluate some of this parameters, finite element study of the structural behavior of the reinforced self-compacting concrete deep beam was carried out using Abaqus finite element modeling tool. The model was validated against experimental data from the literature. The parametric effects of varied concrete compressive strength, vertical web reinforcement ratio and horizontal web reinforcement ratio on the beam were tested on eight (8) different specimens under four points loads. The results of the validation work showed good agreement with the experimental studies. The parametric study revealed that the concrete compressive strength most significantly influenced the specimens’ response with the average of 41.1% and 49 % increment in the diagonal cracking and ultimate load respectively due to doubling of concrete compressive strength. Although the increase in horizontal web reinforcement ratio from 0.31 % to 0.63 % lead to average of 6.24 % increment on the diagonal cracking load, it does not influence the ultimate strength and the load-deflection response of the beams. Similar variation in vertical web reinforcement ratio leads to an average of 2.4 % and 15 % increment in cracking and ultimate load respectively with no appreciable effect on the load-deflection response.
2. Logistics
• Meeting time: 2:20pm-5:20pm, Monday
Classroom: CSIE Room 103
• Classroom: CSIE Room 103
• Instructor: 莊永裕 Yung-Yu Chuang
T hi i t t 黃子桓/李根逸/蘇彥禎/張哲瀚
• Teaching assistants:黃子桓/李根逸/蘇彥禎/張哲瀚
• Webpage:
http://www.csie.ntu.edu.tw/~cyy/asm
id / password
p
• Forum:
http://www.cmlab.csie.ntu.edu.tw/~cyy/forum/viewforum.php?f=21
• Mailing list: [email protected]
Please subscribe via
https://cmlmail.csie.ntu.edu.tw/mailman/listinfo/assembly/
3. Prerequisites
• Better to have programming experience with
some high level languages such C C ++ Java
some high-level languages such C, C ++,Java …
• Note: it is not tested in your graduate school
entrance exam, and not listed as a required
course anymore.
5. References (TOY)
Princeton’s Introduction to CS,
htt // i t d /i t
http://www.cs.princeton.edu/intro
cs/50machine/
http://www.cs.princeton.edu/intro
cs/60circuits/
6. References (ARM)
ARM Assembly Language
P i P t K d
Programming, Peter Knaggs and
Stephen Welsh
ARM System Developer’s Guide,
Andrew Sloss, Dominic Symes and
Andrew Sloss, Dominic Symes and
Chris Wright
7. References (ARM)
Whirlwind Tour of ARM Assembly,
TONC J Vij
TONC, Jasper Vijn.
ARM System-on-chip Architecture
ARM System on chip Architecture,
Steve Furber.
8. References (IA32)
Assembly Language for Intel-Based
C t 5th Editi Ki I i
Computers, 5th Edition, Kip Irvine
Th A t f A bl L R d
The Art of Assembly Language, Randy
Hyde
9. References (IA32)
Michael Abrash' s Graphics Programming
Bl k B k
Black Book
C t S t A P '
Computer Systems: A Programmer's
Perspective, Randal E. Bryant and David
R O'H ll
R. O'Hallaron
10. Grading (subject to change)
• Assignments (4~5 projects, 52%), most graded
by performance
by performance
• Class participation (5%)
• Midterm exam (18%)
• Final project (25%)
p j ( )
– Examples from previous years
11. Computer Organization and Assembly language
• It is not only about assembly but also about
“computer organization”
computer organization .
20. My computers
Desktop
(Intel Pentium D
3GHz Nvidia 7900)
VAIO Z46TD
(I l C 2 D P9700 2 8GH )
3GHz, Nvidia 7900)
(Intel Core 2 Duo P9700 2.8GHz)
iPhone 3GS
(ARM Cortex-A8
GBA SP
833MHz)
GBA SP
(ARM7 16.78MHz)
21. Computer Organization and Assembly language
• It is not only about assembly but also about
“computer organization”
computer organization .
• It will cover
– Basic concept of computer systems and architecture
– ARM architecture and assembly language
– x86 architecture and assembly language
28. IA32
• IA-32 Processor Architecture
• Data Transfers Addressing and Arithmetic
• Data Transfers, Addressing, and Arithmetic
• Procedures
• Conditional Processing
g
• Integer Arithmetic
• Advanced Procedures
• Strings and Arrays
• High-Level Language Interface
• Real Arithmetic (FPU)
• SIMD
• Code Optimization
29. What you will learn
• Basic principle of computer architecture
H k
• How your computer works
• How your C programs work
• Assembly basics
• ARM assembly programming
• ARM assembly programming
• IA-32 assembly programming
S ifi t FPU/MMX
• Specific components, FPU/MMX
• Code optimization
• Interface between assembly to high-level
language
g g
30. Why taking this course?
• Does anyone really program in assembly
nowadays?
nowadays?
Yes at times you do need to write assembly
• Yes, at times, you do need to write assembly
code.
• It is foundation for computer architecture and
• It is foundation for computer architecture and
compilers. It is related to electronics, logic
design and operating system
design and operating system.
32. wikipedia
• Today, assembly language is used primarily for
direct hardware manipulation access to
direct hardware manipulation, access to
specialized processor instructions, or to address
critical performance issues Typical uses
critical performance issues. Typical uses
are device drivers, low-level embedded systems,
and real time systems
and real-time systems.
33. Reasons for not using assembly
• Development time: it takes much longer to
develop in assembly Harder to debug no type
develop in assembly. Harder to debug, no type
checking, side effects…
M i t i bilit t t d di t t i k
• Maintainability: unstructured, dirty tricks
• Portability: platform-dependent
34. Reasons for using assembly
• Educational reasons: to understand how CPUs
and compilers work Better understanding to
and compilers work. Better understanding to
efficiency issues of various constructs.
D l i il d b d th
• Developing compilers, debuggers and other
development tools.
• Hardware drivers and system code
• Embedded systems
y
• Developing libraries.
• Accessing instructions that are not available
• Accessing instructions that are not available
through high-level languages.
O ti i i f d
• Optimizing for speed or space
35. To sum up
• It is all about lack of smart compilers
• Faster code, compiler is not good enough
• Smaller code , compiler is not good enough, e.g.
mobile devices, embedded devices, also
, ,
Smaller code → better cache performance →
faster code
• Unusual architecture , there isn’t even a
compiler or compiler quality is bad eg GPU
compiler or compiler quality is bad, eg GPU,
DSP chips, even MMX.
37. Translating languages
English: Display the sum of A times B plus C
English: Display the sum of A times B plus C.
C++:
cout << (A * B + C);
cout << (A B + C);
Intel Machine Language:
Assembly Language:
mov eax,A
Intel Machine Language:
A1 00000000
F7 25 00000004
mul B
add eax,C
ll W it I t
F7 25 00000004
03 05 00000008
E8 00500000
call WriteInt E8 00500000
38. Virtual machines
Abstractions for computers
High-Level Language Level 5
Assembly Language Level 4
Operating System
Instruction Set
Level 3
Architecture
Microarchitecture Level 1
Level 2
Digital Logic Level 0
39. High-level language
• Level 5
• Application-oriented languages
• Programs compile into assembly language
Programs compile into assembly language
(Level 4)
cout << (A * B + C);
40. Assembly language
• Level 4
• Instruction mnemonics that have a one-to-one
correspondence to machine language
• Calls functions written at the operating
system level (Level 3)
y ( )
• Programs are translated into machine
language (Level 2)
language (Level 2)
mov eax, A
mul B
mul B
add eax, C
call WriteInt
41. Operating system
• Level 3
• Provides services
• Programs translated and run at the instruction
g
set architecture level (Level 2)
42. Instruction set architecture
• Level 2
• Also known as conventional machine language
• Executed by Level 1 program
y p g
(microarchitecture, Level 1)
A1 00000000
F7 25 00000004
03 05 00000008
E8 00500000
43. Microarchitecture
• Level 1
• Interprets conventional machine instructions
(Level 2)
• Executed by digital hardware (Level 0)
44. Digital logic
• Level 0
CPU d f di i l l i
• CPU, constructed from digital logic gates
• System bus
• Memory
45. Data representation
• Computer is a construction of digital circuits
with two states: on and off
with two states: on and off
• You need to have the ability to translate
b t diff t t ti t i
between different representations to examine
the content of the machine
• Common number systems: binary, octal,
decimal and hexadecimal
46. Binary representations
• Electronic Implementation
E t t ith bi t bl l t
– Easy to store with bistable elements
– Reliably transmitted on noisy and inaccurate wires
0 1 0
2.8V
3.3V
0.0V
0.5V
47. Binary numbers
• Digits are 1 and 0
( bi di it i ll d bit)
(a binary digit is called a bit)
1 = true
0 = false
• MSB –most significant bit
• LSB –least significant bit
MSB LSB
• Bit numbering: 1 0 1 1 0 0 1 0 1 0 0 1 1 1 0 0
MSB LSB
A bit string could have different interpretations
0
15
• A bit string could have different interpretations
48. Unsigned binary integers
• Each digit (bit) is either 1 or 0
• Each bit represents a power of 2: 1 1 1 1 1 1 1 1
27 26 25 24 23 22 21 20
Every binary
number is a
f
sum of powers
of 2
49. Translating binary to decimal
Weighted positional notation shows how to
Weighted positional notation shows how to
calculate the decimal value of each binary bit:
d (D 2n 1) (D 2n 2) (D 21) (D
dec = (Dn-1 2n-1) (Dn-2 2n-2) ... (D1 21) (D0
20)
D = binary digit
binary 00001001 = decimal 9:
(1 23) (1 20) 9
(1 23) + (1 20) = 9
50. Translating unsigned decimal to binary
• Repeatedly divide the decimal integer by 2. Each
remainder is a binary digit in the translated value:
remainder is a binary digit in the translated value:
37 = 100101
37 = 100101
51. Binary addition
• Starting with the LSB, add each pair of digits,
include the carry if present
include the carry if present.
1
carry:
0 0 0 0 0 1 0 0
1
(4)
carry:
0 0 0 0 0 1 1 1
+ (7)
0 0 0 0 1 0 1 1
0 0 0 0 1 0 1 1 (11)
0
1
2
3
4
bit position: 5
6
7 0
1
2
3
4
bit position: 5
6
7
52. Integer storage sizes
byte
16
8
Standard sizes: 16
32
word
doubleword
64
quadword
Standard sizes:
64
quadword
Practice: What is the largest unsigned integer that may be stored in 20 bits?
Practice: What is the largest unsigned integer that may be stored in 20 bits?
53. Large measurements
• Kilobyte (KB), 210 bytes
M b (MB) 220 b
• Megabyte (MB), 220 bytes
• Gigabyte (GB), 230 bytes
• Terabyte (TB), 240 bytes
• Petabyte
• Petabyte
• Exabyte
Z tt b t
• Zettabyte
• Yottabyte
54. Hexadecimal integers
All values in memory are stored in binary. Because long
binary numbers are hard to read we use hexadecimal
binary numbers are hard to read, we use hexadecimal
representation.
55. Translating binary to hexadecimal
• Each hexadecimal digit corresponds to 4 binary
bits.
• Example: Translate the binary integer
• Example: Translate the binary integer
000101101010011110010100 to hexadecimal:
56. Converting hexadecimal to decimal
• Multiply each digit by its corresponding
f 16
power of 16:
dec = (D3 163) + (D2 162) + (D1 161) + (D0 160)
H 1234 l (1 163) + (2 162) + (3 161) + (4
• Hex 1234 equals (1 163) + (2 162) + (3 161) + (4
160), or decimal 4,660.
• Hex 3BA4 equals (3 163) + (11 * 162) + (10 161)
Hex 3BA4 equals (3 16 ) + (11 16 ) + (10 16 )
+ (4 160), or decimal 15,268.
57. Powers of 16
Used when calculating hexadecimal values up to
8 digits long:
59. Hexadecimal addition
Divide the sum of two digits by the number base
(16) Th ti t b th l d
(16). The quotient becomes the carry value, and
the remainder is the sum digit.
36 28 28 6A
1
1
36 28 28 6A
42 45 58 4B
78 6D 80 B5
78 6D 80 B5
Important skill: Programmers frequently add and subtract the
addresses of variables and instructions
addresses of variables and instructions.
60. Hexadecimal subtraction
When a borrow is required from the digit to the
l ft dd 10h t th t di it' l
left, add 10h to the current digit's value:
C6 75
1
A2 47
24 2E
Practice: The address of var1 is 00400020. The address of the next
variable after var1 is 0040006A How many bytes are used by var1?
variable after var1 is 0040006A. How many bytes are used by var1?
61. Signed integers
The highest bit indicates the sign. 1 = negative,
0 i i
0 = positive
sign bit
sign bit
1 1 1 1 0 1 1 0
Negative
0 0 0 0 1 0 1 0 Positive
If the highest digit of a hexadecmal integer is > 7, the value is
negative Examples: 8A C5 A2 9D
negative. Examples: 8A, C5, A2, 9D
63. Binary subtraction
• When subtracting A – B, convert B to its two's
complement
complement
• Add A to (–B)
0 1 0 1 0 0 1 0 1 0
– 0 1 0 1 1 1 0 1 0 0
1 1 1 1 1
Advantages for 2’s complement:
Advantages for 2’s complement:
• No two 0’s
• Sign bit
• Remove the need for separate circuits for add
and sub
64. Ranges of signed integers
The highest bit is reserved for the sign. This limits
the range:
the range:
65. Character
• Character sets
St d d ASCII(0 127)
– Standard ASCII(0 – 127)
– Extended ASCII (0 – 255)
ANSI (0 255)
– ANSI (0 – 255)
– Unicode (0 – 65,535)
• Null-terminated String
– Array of characters followed by a null byte
• Using the ASCII table
– back inside cover of book
66. Representing Instructions
int sum(int x, int y)
{ PC sum
Alpha sum Sun sum
{
return x+y;
}
55
89
00
00
p
81
C3
– For this example, Alpha &
Sun use two 4-byte
E5
8B
45
30
42
01
E0
08
90
instructions
• Use differing numbers of
instructions in other cases
0C
03
45
80
FA
6B
02
00
09
instructions in other cases
– PC uses 7 instructions
with lengths 1, 2, and 3
08
89
EC
Diff t hi t t ll diff t
g , ,
bytes
• Same for NT and for Linux
EC
5D
C3
Different machines use totally different
instructions and encodings
• NT / Linux not fully binary
compatible
68. NOT
• Inverts (reverses) a boolean value
• Truth table for Boolean NOT operator:
Digital gate diagram for NOT:
N
O
T
N
O
T
69. AND
• Truth if both are true
• Truth table for Boolean AND operator:
Digital gate diagram for AND:
AND
70. OR
• True if either is true
• Truth table for Boolean OR operator:
Digital gate diagram for OR:
O R
71. Operator precedence
• NOT > AND > OR
• Examples showing the order of operations:
• Use parentheses to avoid ambiguity
Use parentheses to avoid ambiguity
72. Implementation of gates
• Fluid switch (http://www.cs.princeton.edu/introcs/lectures/fluid-computer.swf)
75. Truth Tables (1 of 2)
• A Boolean function has one or more Boolean
i d i l B l
inputs, and returns a single Boolean output.
• A truth table shows all the inputs and outputs
of a Boolean function
Example: X Y