Docsity

computer orgnization, Lecture notes of Computer Science

Toggle sidebar
bg1
Assembly Language
Assembly Language
1
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

Partial preview of the text

Download computer orgnization and more Lecture notes Computer Science in PDF only on Docsity!

Assembly LanguageAssembly Language

A machine’s own languageA machine’s own language

For understanding how computers work,

we need familiarity with the computer’s

own language (called “machine language”)

It’s LOW-LEVEL language (very detailed)

It is specific to a machine’s “architecture”

It is a language “spoken” using voltages

Humans represent it with zeros and ones

What is assembly language?What is assembly language?

Assembly language is a low level

programming language. you need to get some

knowledge about computer structure in order

to understand anything.

Essential ToolsEssential Tools  (^) Assembler is a program that converts source-code programs into a machine language ( object fil e).Linker joins together two or more object files and produces a single executable file.Debugger loads an executable program, displays the source code, and lets the programmer step through the program one instruction at a time, and display and modify memory.  (^) Emulator allows you to load and run assembly language programs, examine and change contents of registers. Example: EMU

Assembly Language Fundamentals Assembly Language Fundamentals

Chapter 3 Chapter 3

Basic Elements of Assembly LanguageBasic Elements of Assembly Language

Assembling, Linking, and DebuggingAssembling, Linking, and Debugging

Numeric Constants Numeric Constants

Numeric constants are made of numerical

digits with, possibly, a sign and a suffix.

Ex:

-23 (a negative integer, base 10 is default)  1011b (a binary number)  1011 (a decimal number)  0A7Ch (an hexadecimal number)  A7Ch (this is the name of a variable, an hexadecimal number must start with a decimal digit )

Character and String Constants Character and String Constants

Any sequence of characters enclosed

either in single or double quotation marks.

Embedded quotes are permitted. Ex:

 (^) ‘A’  ‘ABC’  “Hello World!”  “123” (this is a string, not a number)  (^) “This isn’t a test”  ‘Say “hello” to him’

Irvine, Kip R. Assembly Language for x86 Processors 6/e, 2010. (^13) Instructions Instructions

Assembled into machine code by assembler

Executed at runtime by the CPU

An instruction contains:

Label (optional)  Mnemonic (required)  Operand (depends on the instruction)  Comment (optional)  The general format is: [name] mnemonic [operands] [;comment]

Names Names

A name identifies either:

a label  (^) a variable  a symbolic constant (name given to a constant)  a keyword (assembler-reserved word).

Names (cont.) Names (cont.)A variable is a symbolic name for a location in memory that was allocated by a data allocation directive. Ex:  (^) count db 50 ; allocates 1 byte to variable countA label is a name that appears in the code area. Must be followed by ‘:’

Names (cont.) Names (cont.)

The first character must be a letter or any

one of ‘_’, ‘$’, ‘?’, ‘@’

subsequent characters can include digits  A programmer chosen name must be different from an assembler reserved word or predefined symbol. 

avoid using ‘@’ as the first character since many

predefined symbols start with it

By default, the assembler is case

insensitive

Reserved WordsReserved Words  (^) Reserved words have special meaning in Assembler  (^) There are different types of reserved words:  (^) Instruction mnemonics, such as MOV, ADD, and MUL  (^) Register names  (^) Directives, which tell MASM how to assemble programs  (^) Attributes, which provide size and usage information for variables and operands. Example are BYTE and WORD  Operators, used in constant expressions  Predefined symbols, such as @data, which return constant integer values at assembly time