A Simple Example in VCpp-Assembly Language Programming-Lab Slides, Slides of Assembly Language Programming

Prof. Abhay Aggrawal delivered this lecture at Birla Institute of Technology and Science for lab of Assembly Language Programming. It includes: Glance, Assembly, High Language, Software, Abstractions, Architecture, Microarchtecture, Accessing, Macros

Typology: Slides

2011/2012

Uploaded on 07/26/2012

parina
parina 🇮🇳

4.4

(67)

222 documents

1 / 52

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
7/14/2012 1
A Simple Example in VC++
docsity.com
pf3
pf4
pf5
pf8
pf9
pfa
pfd
pfe
pff
pf12
pf13
pf14
pf15
pf16
pf17
pf18
pf19
pf1a
pf1b
pf1c
pf1d
pf1e
pf1f
pf20
pf21
pf22
pf23
pf24
pf25
pf26
pf27
pf28
pf29
pf2a
pf2b
pf2c
pf2d
pf2e
pf2f
pf30
pf31
pf32
pf33
pf34

Partial preview of the text

Download A Simple Example in VCpp-Assembly Language Programming-Lab Slides and more Slides Assembly Language Programming in PDF only on Docsity!

A Simple Example in VC++

docsity.com

First Glance at Assembly Language

English: Display the sum of A times B plus C.C++: cout << (A * B + C);Assembly Language:mov eax,Amul Badd eax,Ccall WriteInt

Intel Machine Language:A1 00000000F7 25 0000000403 05 00000008E8 00500000

docsity.com

First Glance at Assembly Language

Low-level language

Each instruction performs a much lower-level taskcompared to a high-level language instruction

Most high-level language instructions need more thanone assembly instruction

One-to-one correspondence between assemblylanguage and machine language instructions

For most assembly language instructions, there is amachine language equivalent

Directly influenced by the instruction set andarchitecture of the processor (CPU)

docsity.com

Comparisons with High-level Languages

Advantages of Assembly Languages  Space-efficiency (e.g. hand-held device softwares, etc)  Time-efficiency(e.g. Real-time applications, etc )  Accessibility to system hardwares(e.g., Network interfaces, device drivers, video games, etc)

Advantages of High-level Languages  Development  Maintenance (Readability)  Portability (compiler, virtual machine) docsity.com

This Course

Why Taking the Course?

Basic Concepts of

Computer

Organization

Computer Design

System

Software

Computer OrganizationComputer Architecture

Assembler, Linker, Loader

Compiler, Operating System, …

AssemblyLanguage

docsity.com

Time Comparison

Number of calls (in millions)

Time (seconds)

Multiplication time comparison on a 2.4-GHz Pentium 4 system

C version

ASM version

docsity.com

Assembly Language

Level 4

Instruction mnemonics that have a one-to-one correspondence to machinelanguage

Calls functions written at the operatingsystem level (Level 3)

Programs are translated into machinelanguage (Level 2)

docsity.com

Operating System

Level 3

Provides services to Level 4 programs

Translated and run at the instruction setarchitecture level (Level 2)

docsity.com

Microarchitecture

Level 1

Interprets conventional machineinstructions (Level 2)

Executed by digital hardware (Level 0)

docsity.com

Digital Logic

Level 0

CPU, constructed from digital logic gates

System bus

Memory

docsity.com

Accessing Parts of Registers

Use 8-bit name, 16-bit name, or 32-bit name

Applies to EAX, EBX, ECX, and EDX

AH AL 16 bits 8 AX EAX 8 8 bits + 8 bits 32 bits docsity.com

Some specialized register uses

General-Purpose

EAX – accumulator (automatically used by divisionand multiplication)

ECX – loop counter

ESP – stack pointer (should never be used forarithmetic or data transfer)

ESI, EDI – index registers (used for high-speedmemory transfer instructions)

EBP – extended frame pointer (stack)

docsity.com

Status Flags

•^

Carry (CF)

unsigned arithmetic out of range

•^

Overflow (OF)

signed arithmetic out of range

•^

Sign (SF)

result is negative

•^

Zero (ZF)

result is zero

•^

Auxiliary Carry (AC)

carry from bit 3 to bit 4 in 8-bit operand

•^

Parity (PF)

sum of 1 bits in least-significant byte is an evennumber

docsity.com

Assembly language Statements

Three types of assembly language statements 

Instructions

Directives

Macros

docsity.com