Assembly Language
Reference
• Ytha Yu, Charles Marut, Assembly
Language Programming and Organziation
of the IBM PC
requirement
• Exercise+ Program homework 40%
• Midterm examination 30%
• Final examination 30%
• Ps:
Outline
• Microcomputer Systems
• Representation of Numbers and
Characters
• Organization of the IBM Personal
Computers
• Introduction to IBM PC Assembly
Language
Outline
• Flow Control Instructions
• Logic, Shift, ad Rotate Instructions
• The Stack and Introduction to Procedures
• Multiplication and Division Instructions
• Arrays and Addressing Modes
• The String Instructions
Outline
• Macros
• Memory Management
• BIOS and DOS Interrupt
• Color Graphics
• Recursion
• Advanced Arithmetic
schdular
6
5
4
3
2
1
備註
進度
日期
schdular
15
14
13
12
11
10
備註
進度
日期
Microcomputer Systems
• Overview
– Introduction to the architeture of
microcomputers in general and to the IBM PC
in particular.
Microcomputer System
(component)
• The components o a microcomputer
system
– System unit
– Keyboard
– display screen
– Disk drives
Microcomputer System
(component)
• Computer circuits
– Central processing unit (CPU)
– I/O circuits
• Microcomputer
– CPU is a single-chip processor
(microprocessor)
Microcomputer System
(component)
• Bytes – eight bits
• Address – identified by a number
• Content– the data stored in a memory byte.
content
:
0 1 1 0 0 0 0 1
Address
:
3
2
Microcomputer System
(component)
• Example 1.1 Suppose a processor uses
20 bits for an address. How many memory
bytes can be accessed?
Microcomputer System
(component)
• Word – typical microcomputer, two bytes
form a word
• Bit position
Byte bit position
Word bit position
Microcomputer system
(component)
• RAM and ROM
• Bus
Microcomputer system
(component)
• In any case, each instruction that the CPU
executes is a bit string
• This language of 0’s and 1’s is called machine
language
• The instructions performed by a CPU are called
instruction set.
Microcomputer system
(component)
• EU (Execution Unit)
– Arithmetic
• +-*/
– Logic unit
• AND, OR, NOT
– Registers
Microcomputer system
(component)
• EIU ( Bus Interface Unit)
– Communication between the EU and the
memory or I/O circuits
– Registers
Microcomputer system
(component)
Microcomputer system
(instruction execution)
• Instruction Execution
• Machine instruction
– Opcode : the type of operation
– Operand : given as memory address to he
data to be operated on.
Microcomputer system
(instruction execution)
• Fetch-execute cycle
– Fetch
• Fetch an instruction from memory
• Decde he inctruction to determine the operation
• Fetch data from memory if necessary.
– Execute
Microcomputer system
(I/O Devices)
• Magnetics disks
• Keyboard
• Display monitor
• printers
Microcomputer system
(programming languages)
• Machine language
Add 4 to AX
00000101 00000100 00000000
Fetch the content of memory word
to and put it in register AX
10100001 00000000 00000000
operation
Machine instruction
Microcomputer system
(programming languages)
• Assembly language
Add 4 to AX
ADD AX,4
Fetch the content of location A and
put it in register AX
MOV AX,A
operation
Assembly language
Microcomputer system
(programming languages)
• Assembler
• compiler
Microcomputer system
(programming languages)
• Advantage of high-level languages
– Closer to natural language
– Reduce Coding time
– Executed on any machine
• Advantage of assembly language
– Efficiency
Microcomputer system
(assembly languages)
ch1.asm
TITLE PGM1_1: SAMPLE PROGRAM .MODEL SMALL .STACK 100H .DATA A DW 2 B DW 5 SUM DW ? .CODE MAIN PROC ;initialize DS MOV AX,@DATA MOV DS,AX ;add the numbers
MOV AX,A ADD AX,B MOV SUM,AX
Microcomputer system
(Debug)
• assemble A [address]
• compare C range address
• dump D [range]
• enter E address [list]
• fill F range list
• go G [=address] [addresses]
• hex H value1 value2
• input I port
• load L [address] [drive] [firstsector] [number]
• move M range address
Microcomputer system
(Debug)
• proceed P [=address] [number]
• quit Q
• register R [register]
• search S range list
• trace T [=address] [value]
• unassemble U [range]
• write W [address] [drive] [firstsector] [number]
• allocate expanded memory XA [#pages]
• deallocate expanded memory XD [handle]
• map expanded memory pages XM [Lpage] [Ppage] [handle]
• display expanded memory status XS
Microcomputer system
(tasm)
• Syntax: TASM [options] source [,object] [,listing] [,xref] • /a,/s Alphabetic or Source-code segment ordering • /c Generate cross-reference in listing
• /dSYM[=VAL] Define symbol SYM = 0, or = value VAL • /e,/r Emulated or Real floating-point instructions • /h,/? Display this help screen
• /iPATH Search PATH for include files
• /jCMD Jam in an assembler directive CMD (eg. /jIDEAL) • /kh# Hash table capacity # symbols
• /l,/la Generate listing: l=normal listing, la=expanded listing
• /ml,/mx,/mu Case sensitivity on symbols: ml=all, mx=globals, mu=none • /mv# Set maximum valid length for symbols
• /m# Allow # multiple passes to resolve forward references • /n Suppress symbol tables in listing
• /os,/o,/op,/oi Object code: standard, standard w/overlays, Phar Lap, or IBM • /p Check for code segment overrides in protected mode
• /q Suppress OBJ records not needed for linking • /t Suppress messages if successful assembly