Assembly Language For x86 Processors
Assembly Language For x86 Processors
7th Edition
Kip Irvine
(c) Pearson Education, 2015. All rights reserved. You may modify and copy this slide show for your personal use, or
for use in the classroom, as long as this copyright statement, the author's name, and the title are not changed.
Chapter Overview
• Integer constants
• Integer expressions
• Character and string constants
• Reserved words and identifiers
• Directives and instructions
• Labels
• Mnemonics and Operands
• Comments
• Examples
• Examples:
• Instruction Mnemonics
• memory aid
• examples: MOV, ADD, SUB, MUL, INC, DEC
• Operands
• constant
• constant expression
• register
• memory (data label)
• No operands
• stc ; set Carry flag
• One operand
• inc eax ; register
• inc myByte ; memory
• Two operands
• add ebx,ecx ; register, register
• sub myByte,25 ; memory, constant
• add eax,36 * 25 ; register, constant-
expression
.386
.model flat,stdcall
.stack 4096
ExitProcess PROTO, dwExitCode:DWORD
.code
main PROC
mov eax,5 ; move 5 to the EAX register
add eax,6 ; add 6 to the EAX register
INVOKE ExitProcess,0
main ENDP
END main
Bit 11 10 9 8 7 6 5 4 3 2 1 0
Txt OF DF IF SF ZF AF PF CF
VS OV UP EI PL ZR AC PE CY
; Description:
; Author: .386
; Creation Date: .model flat,stdcall
.stack 4096
; Revisions:
ExitProcess PROTO, dwExitCode:DWORD
; Date:
; Modified by: .data
; declare variables here
.code
main PROC
; write your code here
INVOKE ExitProcess,0
main ENDP
• Assemble-Link-Execute Cycle
• Listing File
• Map File
11: .code
12: main PROC
13: mov ax, bx
00401010 66 8B C3 mov ax,bx
14: nop
00401013 90 nop
• BYTE, SBYTE
• 8-bit unsigned integer; 8-bit signed integer
• WORD, SWORD
• 16-bit unsigned & signed integer
• DWORD, SDWORD
• 32-bit unsigned & signed integer
• QWORD
• 64-bit integer
• TBYTE
• 80-bit integer
• REAL4
• 4-byte IEEE short real
• REAL8
• 8-byte IEEE long real
• REAL10
• 10-byte IEEE extended real
value1 BYTE 10
• Example:
val1 DWORD 12345678h
• Example:
val1 DWORD 12345678h
• Equal-Sign Directive
• Calculating the Sizes of Arrays and Strings
• EQU Directive
• TEXTEQU Directive
COUNT = 500
.
.
mov ax,COUNT
count = 5
mov al, count
...
count = 100
mov al, count
...
.code
setupAL ; generates: "mov al,10"