+ All Categories
Home > Documents > Assembly Language Lecture 04-06 BY SHERY KHAN [email protected] Review By Sultan Fahad April 26...

Assembly Language Lecture 04-06 BY SHERY KHAN [email protected] Review By Sultan Fahad April 26...

Date post: 16-Dec-2015
Category:
Upload: gloria-manson
View: 220 times
Download: 0 times
Share this document with a friend
Popular Tags:
26
Assembly Language Assembly Language Lecture 04-06 Lecture 04-06 BY SHERY KHAN [email protected] www.sherykhan.jimdo.com Review By Sultan Fahad April 26 2013
Transcript

Assembly LanguageAssembly Language

Lecture 04-06Lecture 04-06BY

SHERY [email protected]

www.sherykhan.jimdo.com

Review BySultan Fahad

April 26 2013

October 21, 2005 LACUNY Web Roundtable [email protected]

2

AgendaAgenda

• To day we learn about• Recap & Exercise (Page 15)• Data Declaration (Page 17)• Direct Addressing (page 17) • Size Mismatch Errors (page 21)• Register Indirect Addressing (page 22)

[email protected] 26 2013

October 21, 2005 LACUNY Web Roundtable [email protected]

3

RECAP & EXERCISERECAP & EXERCISE

• Last Lecture we can discuss the Few Important Topics Now on the basis of previous knowledge we can Solve the Exercise

[email protected] 26 2013

October 21, 2005 LACUNY Web Roundtable [email protected]

4

ExerciseExerciseHow the Processor uses the Address Bus ,Data bus and control Bus?

[email protected]

Processor Execute Operation and memory contain data element Memory is a Dump Device in which Data resides Key point is that Processor want to read or write Data so for reading data or writing purposes are achieved by Address bus & data Bus & Control Bus Address bus is Used When Processor Want to Certain read or write operation. Data Bus is Used to move data form Memory to Processor in Read Operation & Processor to Memory For Write Operation. Control BUS is independent lines used to inform Memory about Certain operation

April 26 2013

October 21, 2005 LACUNY Web Roundtable [email protected]

5

EXERCISEEXERCISEQno2 Which of the Following are Uni & Bi DirectionalQno2 Which of the Following are Uni & Bi Directional

• Address Bus Is Uni Directional because Address Always Travel From Processor to Memory & Memory Cannot Predict which Element the Processor want to read or Write

• DATA BUS: data Travel From Both processor to memory& vice versa So data Bus is Bi Directional

• Control Bus Is Bi directional

[email protected]

October 21, 2005 LACUNY Web Roundtable [email protected]

6

What is The Size of the Accumulator of 64 bit Processor?What is The Size of the Accumulator of 64 bit Processor?

• The Size of Accumulator of 64 bit processor is 64 bit According to defination

• “ the Word size of processor is defined by the width of accumulator”

[email protected] 26 2013

October 21, 2005 LACUNY Web Roundtable [email protected]

7

How many Instruction Classified into groups?How many Instruction Classified into groups?

• There are Four Categories of Instructions.• Data Movement Instruction• Arithmetic Logic instruction• Program Control Instruction• Special Instructions

[email protected]

October 21, 2005 LACUNY Web Roundtable [email protected]

8

A combination of 8 bit are Byte what is name of Four Bit & 16 bit??A combination of 8 bit are Byte what is name of Four Bit & 16 bit??

• Four BITS: are called as NIBBLE

• Four Bytes : Are Called double Word (32bit)

• 16 Bits : are called word (2 byte long)

[email protected]

October 21, 2005 LACUNY Web Roundtable [email protected]

9

What is Maximum Memory 8088 can access??What is Maximum Memory 8088 can access??

• The 8088 can Allow Whole MEGA BYTE• Which can be Accessed with 20 bits

[email protected]

October 21, 2005 LACUNY Web Roundtable [email protected]

10

List the 14 register of 8088 ?List the 14 register of 8088 ?

• HERE TO New the Register the Afd View

[email protected]

October 21, 2005 LACUNY Web Roundtable [email protected]

11

What is Difference Little Endean & Big EndianWhat is Difference Little Endean & Big Endian

• Little Endian: Big Endian:• Least Significant Most Significant• More Significant Less Significant• Most Significant Least Significant• For e.g. 0123 For e.g. 3 2 1 0

[email protected]

October 21, 2005 LACUNY Web Roundtable [email protected]

12

Which Format was Used by INTEL 8088

• Little Endian Order is used By Intel8088

[email protected]

October 21, 2005 LACUNY Web Roundtable [email protected]

13

Give the Value of Zero flag carry flag sign flag and overflow flagafter each of the Following instructions

mov ax 0x1254 mov bx 0x0FFF

add ax,0xEDAB Zero FLAG:0

CF:0SF:1OF:0

Add ax,bxZF:0CF:0SF:0oF:0

Add bx,0xf001ZF:0, CF:1 SF:0 OF:0

[email protected]

October 21, 2005 LACUNY Web Roundtable [email protected]

14

13. For each of the following words identify the byte that is stored at lower memory address and the byte that is stored at higher memory

address in a little endian computer.

• a. 1234b. ABFCc. B100d. B800

• FEW SLIDE SHOW WE DISCUSS THE LITTLE ENDIAN

• Above the 1234 Followed the Definition So this Is our desired Result

• 1234

[email protected]

October 21, 2005 LACUNY Web Roundtable [email protected]

15

15. What is the offset at which the first executable instruction of a COMfile must be placed?

• The First Instruction of COM File Must be Offset at 0x0100(decimal 255) as required

• What is the difference between an instruction mnemonic and its opcode?

• Opcode

• Short for operational code, it is a number that determines the computer instruction to be

• executed. (machine language representation of an instruction

[email protected] 26 2013

What flags are defined in the 8088 FLAGS register? Describe the function of thezero flag, the carry flag, the sign flag, and the overflow flag.

Zero flag?????

• The Zero flag is set if the last mathematical or logical instruction has produced a zero in

• its destination.

• Carry flag

• When two 16bit numbers are added the answer can be 17 bits long or when two 8bit

• numbers are added the answer can be 9 bits long. This extra bit that won’t fit in the target

• register is placed in the carry flag where it can be used and tested.

• Sign flag

• A signed number is represented in its two’s complement form in the computer. The most

• significant bit (MSB) of a negative number in this representation is 1 and for a positive

• number it is zero. The sign bit of the last mathematical or logical operation’s destination

• is copied into the sign flag.

• Overflow flag

• The overflow flag is set during signed arithmetic, e.g. addition or subtraction, when the

• sign of the destination changes unexpectedly. The actual process sets the overflow flag

• whenever the carry into the MSB is different from the carry out of the MSB.

16

What are the contents of memory locations 200, 201, 202, and 203 if the word1234 is stored at offset 200 and the word 5678 is stored at offset 202?

• In Little Endean, least significant byte is stored first at lower addresses; most significant

• byte is stored after it. Like for example the number 0x1234 is stored at memory address

• 0x123 then it will appear like as below:

• Address Contents

• …

• 0x123 34

• 0x124 12

• …

• Do try it for the given memory addresses with given numbers.

17

Why was segmentation originally introduced in 8088 architecture?

• Four windows of 64K

• Code window

• Data window

• Stack window

• The segmented memory model allows multiple functional windows into

• the main memory, a code window, a data window etc. The processor sees

• code from the code window and data from the data window. The size of

• one window is restricted to 64K. 8085 software fits in just one such

• window. It sees code, data, and stack from this one window, so

• downward compatibility is attained.

18

What are the first and the last physical memory addresses accessible using the following segment values?

• First 0x0000 and last 0xFFFF

• First physical address Last physical address

• a. 1000

• 0x10000 0x10000

• +0x00000 +0x0FFFF

• =0x10000 =0x1FFFF

• b. 0FFF

• 0x0FFF0 0x0FFF0

• +0x00000 +0x0FFFF

• =0x0FFF0 =0x1FFEF

• 1002

• 0x10020 0x10020

• +0x00000 +0x0FFFF

• =0x10020 =0x2001F

• d. 0001

• 0x00010 0x00010

• +0x00000 +0x0FFFF

• =0x00010 =0x1000F

• E000

• 0xE0000 0xE0000

• +0x00000 +0x0FFFF

• =0xE0000 =0xEFFFF

19

Why a segment start cannot start from the physical address 55555??.

• For any segment base address, segment first physical address will have 0 in the least

• significant position in hexadecimal format.

• Let say,our Segment base =0x1234, and we calculate segment first physical address as

• 0x12340 <- 0x12340 + 0x00000 (Segment First Address)

• Thusall segments starting physical address has 0 at its least significant position. In case

• of 55555 as segment first physical address there in no 0 at least significant positions so

• this cannot be a segment starting physical address.

20

Q21 Write a program in assembly language that Calculate the Square ?

• [org 0x0100]» Mov ax, 6

» Add ax, 6

» Add ax, 6

» Add ax, 6

» Add ax, 6

» Add ax, 6

» Mov ax, 0x4c00

» Int 0x21

April 26 2013 [email protected] 21

Table of Hexa To Deci

October 21, 2005 [email protected] 22

The ASCII and EBCDIC Tables

.

(Next) (Previous) (Table-of-Contents) ( Decimal 000-031 ) ( Hexadecimal 00-1F )

DEC HEX EBCDIC ASCII BINARY DEC HEX EBCDIC ASCII BINARY 000 00 NUL NUL 0000 0000 016 10 DLE DLE 0001 0000

001 01 SOH SOH 0000 0001 017 11 DC1 DC1 0001 0001

002 02 STX STX 0000 0010 018 12 DC2 DC2 0001 0010

003 03 ETX ETX 0000 0011 019 13 DC3 DC3 0001 0011

004 04 SEL EOT 0000 0100 020 14 RES/ENP DC4 0001 0100

005 05 TAB ENQ 0000 0101 021 15 NL NAK 0001 0101

006 06 RNL ACK 0000 0110 022 16 BS SYN 0001 0110

007 07 DEL BEL 0000 0111 023 17 POC ETB 0001 0111

008 08 GE BS 0000 1000 024 18 CAN CAN 0001 1000

009 09 SPS TAB 0000 1001 025 19 EM EM 0001 1001

010 0A RPT LF 0000 1010 026 1A UBS SUB 0001 1010

011 0B VT VT 0000 1011 027 1B CU1 ESC 0001 1011

012 0C FF FF 0000 1100 028 1C IFS FS 0001 1100

013 0D CR CR 0000 1101 029 1D IGS GS 0001 1101

014 0E SO SO 0000 1110 030 1E IRS RS 0001 1110

015 0F SI SI 0000 1111 031 1F ITB/IUS US 0001 1111

(Next) (Previous) (Table-of-Contents) ( Decimal 032-063 ) ( Hexadecimal 20-3F )

DEC HEX EBCDIC ASCII BINARY DEC HEX EBCDIC ASCII BINARY 032 20 € Space 0010 0000 048 30 0 0011 0000

033 21 SOS ! 0010 0001 049 31 1 0011 0001

034 22 FS " 0010 0010 050 32 SYN 2 0011 0010

035 23 WUS # 0010 0011 051 33 IR 3 0011 0011

036 24 BYP/INP $ 0010 0100 052 34 PP 4 0011 0100

037 25 LF % 0010 0101 053 35 TRN 5 0011 0101

038 26 ETB & 0010 0110 054 36 NBS 6 0011 0110

039 27 ESC ' 0010 0111 055 37 EOT 7 0011 0111

040 28 SA ( 0010 1000 056 38 SBS 8 0011 1000

041 29 SFE ) 0010 1001 057 39 IT 9 0011 1001

042 2A SM/SW * 0010 1010 058 3A RFF : 0011 1010

043 2B CSP + 0010 1011 059 3B CU3 ; 0011 1011

044 2C MFA , 0010 1100 060 3C DC4 < 0011 1100

• What are the first and the last physical memory addresses accessible using the following segment values? (2 mark each)

• 0000

• FFFF

• Answer:

• a)

• First physical address = 00000 + 00000 = 00000

• Last physical address = 00000 + 0FFFF = 0FFFF

•  

• b)

• First physical address = FFFF0 + 00000 = FFFF0

• Last physical address = FFFF0 + 0FFFF = 10FFEF = 0FFEF (wraparound)

26 April 2013 Shery khan 23

October 21, 2005 LACUNY Web Roundtable [email protected]

24

TODAY LECTURE05

DATA DECLARATION:

[email protected]

IMMEDIATE OPERANDS: In our previous Programs We use a Immediate operand but in Meaningful Programs we use data from Memory instead of Constant because constant cannot change Constant cannot appear as destination operand which is Ilegal if we place it as Destination we know that

operation destination, sourceoperation destination

operation sourceoperation

October 21, 2005 LACUNY Web Roundtable [email protected]

25

DATA DECLARATION:

• Only Register or data Can be placed in memory can be changed

• So real data is one stored in memory with

Few constant so there is Mechanism which is used And is Called Data Declaration

[email protected]

October 21, 2005 LACUNY Web Roundtable [email protected]

26

DATA DECLARATION:

• To Declare a part of our program as holding data instead of instruction we need a Special Directives which are Following

• DEFINE BYTE: (db) I byte

• DEFINE WORD :(dw) 16 bits(2 byte)

• Db: reserve one single byte cell in memory dw:reserve whole 16 bits instead of Byte

[email protected]


Recommended