Docsity

Assembly Language Programming - CS401 Power Point Slides , Lecture notes of Microprocessor and Assembly Language Programming

Partial preview of the text

Download Assembly Language Programming - CS401 Power Point Slides and more Lecture notes Microprocessor and Assembly Language Programming in PDF only on Docsity!

CS-

Computer Architecture & Assembly

Language Programming

Lecture- Addressing Modes Branching

In the Last Lecture

We discussed memory addresses

Addressing Modes

Base Addressing

; Default segment = ds mov ax, [bx] mov byte [bx], 10 mov word [bx], 10 ; Default segment = ss mov ax, [bp] mov byte [bp], 10 mov word [bp], 10

Addressing Modes

Index Addressing ; Default segment = ds mov ax, [si] mov byte [di], 10 mov word [si], 10

Addressing Modes

Index + Offset Addressing ; Default segment = ds mov ax, [si+0x0100] mov byte [di+0x100], 10 mov word [di+0x100], 10 mov byte [si+0x10], 10 mov word [si+0x0100], 10

Addressing Modes

Base + Index Addressing ; Default segment = ds mov ax, [bx+si] mov byte [bx+si], 10 mov word [bx+di], 10 ; Default segment = ss mov byte [bp+si], 10 mov word [bp+di], 10

Addressing Modes

General Form [base + index + offset]

Illegal Addressing

Example mov al, [bl] ; Address cannot be 8-bit ; has to be 16-bit

Illegal Addressing

Example mov ax, [bx-si] ; Registers cannot be ; subtracted

Illegal Addressing

Example mov ax, [bx+bp] ; Two bases cannot be ; used in one addressing

Physical Address Calculation

[cs:bx+si+0x0700] BX = 0x SI = 0x CS = 0x Effective Address = EA = Base + Index + Offset EA = 0x0100 + 0x0200 + 0x = 0x0A Physical Address = Segment0x10+EA = 0x10000x10+0xA = 0x10A

Physical Address Calculation

[bx+0x7000] BX = 0x DS = 0x Effective Address = EA = Base + Index + Offset = 0x9100 + 0x0000 + 0x = 0x 10100 ; 17-bits! = 0x0100 ; Segment wrap ; around

Physical Address Calculation

[bx+0x0100] BX = 0x DS = 0xFFF Effective Address = EA = Base + Index + Offset = 0x0100 + 0x0000 + 0x = 0x Physical Address = Segment0x10+EA = 0xFFF00x10+0x = 0x 100100 ; 21-bits! = 0x00100 ; memory wrap ; around

CMP

Subtracts the source (src) from destination (dest) Does not change contents of src or dest. Affects AF,CF,OF,PF,SF and ZF. The relation is of destination to source.