10 Programs for practical , Semester II, Microprocessor II

 

Assembly Language Programs

Final 10 Programs for practical

Semester II

Microprocessor II

Q.1) Program Title: WALP to mask the lower nibble of 8 bit number and store the result on memory location [2000]. DS=0200H

Register Used: - AX, AL, [2000], DS

Data: -0200 H, 88H, F0 H

A2000

Address

Op-code

Label

Mnemonics

Operand

Comments

0000:2000

B8,00,02

 

MOV

AL,0200

Initialization of  DS

        :2003

8E,D8

 

MOV

DS,AX

        :2005

B0,88

 

MOV

AL,88H

Copy 88H in AL

        :2007

24,F0

 

AND

AL,F0

AND F0 with AL

        :2009

88,06,00,

20

 

MOV

[2000],AL

Copy contents of AL on [2000]

       :200F

CC

 

INT

3

Stop

 

Result:-

            0200: [2000]: 80H


 

Q.2) Program Title: WALP to mask the upper nibble of 8 bit number and store the result on memory location [3000]. DS=0400H

Register Used: - AX, AL, [3000], DS

Data: -88H, 0FH, 0400

A2000

Address

Op-code

Label

Mnemonics

Operand

Comments

0000:2000

B8,00,04

 

MOV

AL,0200

Initialization of  DS

        :2003

8E,D8

 

MOV

DS,AX

        :2005

B0,88

 

MOV

AL,88H

Copy 88H in AL

        :2007

24,F0

 

AND

AL,0F

AND 0F with AL

        :2009

88,06,00,

20

 

MOV

[3000],AL

Copy contents of AL on [3000]

       :200F

CC

 

INT

3

Stop

 

Result:-

            0200: [3000]: 08H


 

Q.3) Program Title: WALP to mask upper nibble of all data store as a block, block begins from [2000]. Length of block is 0A H.

Register Used: - DS, SI, CL, [2000]

Data: - DS:0200:2000- 11, 22, 33, 44, 55,66, 77, 88, 99, AA H

A2000

Address

Op-code

Label

Mnemonics

Operand

Comments

0000:2000

B8,00,04

 

MOV

AL,0200

Initialization  of  DS

        :2003

8E,D8

 

MOV

DS,AX

        :2005

BE,00,20

 

MOV

SI, 2000

2000 H copy in SI Register

        :2008

B1, 0A

 

MOV

CL,0A

Copy 0A in CL

        :200A

B2, 0F

 

MOV

DL, 0F

Copy 0F in DL

        :200C

20,14

 BACK:

AND

[SI],DL

AND operation between contents of DL with contents of memory location which is present in SI register and store result on memory location.

        :200E

46

INC

SI

Increase  SI

        :200F

FE, C9

DEC

CL

Decrease CL

        :2011

75,F9

JNZ

BACK

Jump if not zero to 200C

         :2013

CC

INT

3

Stop

S0200 : 2000,  2009

Result:-

0200: 2000: 01H

          :2001: 02H

          :2002:03H

          :2003:04H

          :2004:05H

:2005:06H

:2006:07H

:2007:08H

:2008:09H

:2009:0AH

 


 

Q.4) Program Title: WALP to find the factorial of a given number. Store the result on memory location [2000] given number is 05.

Register Used: - [2000], DS, AX, CL, AL

Data: - 05H, 0200H

A2000

Address

Op-code

Label

Mnemonics

Operand

Comments

0000:2000

B8,00,02

 

MOV

AL,0200

Initialization  of  DS

        :2003

8E,D8

 

MOV

DS,AX

        :2005

B0,01

 

MOV

AL, 01 H

Copy 01 H in AL

        :2007

B1, 05

 

MOV

CL,05 H

Copy 05 H in CL

        :2009

F6,E1

 BACK:

MUL

CL

Multiply contents of CL with contents of AL

        :200B

FE,C9

 

DEC

CL

Decrease CL

        :200D

14,46

JNZ

BACK

Jump if not zero to 2009

        :201F

FE, C9

MOV

[2000],AL

Copy contents of AL on memory location [2000]

        :2013

CC

INT

3

Stop

S0200 : 2000,  2009

Result:-

            0200: [2000]: 78 H

 

 


 

Q.5) Program Title: - WALP to 44H & 57H in AL & BL register respectively, perform the addition & store the sum on memory location [2000]. DS = 0200H

 

Register & Memory Address Used: - AL, BL & [2000]

Data: - 44H, 57H & 0200H

A7000

Address

Op-code

Label

Mnemonic

Operand

Comments

0000:7000

B8,00,02

 

MOV

AX,0200

Initialization of DS

      :7003

8E,D8

 

MOV

DS,AX

 

      :7005

B0,44

 

MOV

AL,44H

;COPY 44H IN AL

      :7007

B3,57

 

MOV

BL,57H

;COPY 55H IN BL

      :7009

02,C3

 

ADD

AL,BL

;ADD CONTENTS OF BL WITH AL & RESULT SOTRED IN AL

      :700B

88,06,00,20

 

MOV

[2000],AL

COPY CONTENTS OF AL ON MEMORY LOCATION [2000]

      :700F

CC

 

INT

03

STOP

 

Result:-

DS : OFFSET : DATA

0200:  [2000]    : 9B H


 

Q.6)  Program Title: -WALP to store 55H & 22H in DL & AH register respectively, perform the Subtraction & store the result on memory location [4000]. DS = 0300H

Register & Memory Address Used: - DL, AH & [4000]

Data: - 55H, 22H & 0300H

A8000

Address

Op-code

Label

Mnemonic

Operand

Comments

0000:8000

B8,00,03

 

MOV

AX,0300

Initialization of DS

         :8003

8E,D8

 

MOV

DS,AX

 

         :8005

B2,55

 

MOV

DL,55H

;COPY 55H IN DL

         :8007

B4,22

 

MOV

AH,22H

;COPY 22H IN AH

         :8009

2A,D4

 

SUB

DL,AH

;SUBTRACT CONTENTS OF AH FROM DL & RESULT SOTRED IN DL

         :800B

88,16,00,40

 

MOV

[4000],DL

COPY CONTENTS OF DL ON MEMORY LOCATION [4000]

         :800F

CC

 

INT

03

STOP

 

Result:-

DS   : OFFSET : DATA

0300:  [4000]    : 33H

 


Q.7)  Program title:-WALP(write assembly language program)to transfer the block of data of 10 elements from M.L[3000] onwards to M.L[2000] onwards .DS=0400 .

Abstract:-DS, AX, SI, DI, CL, AL.

Data:-0400:3000 -01,02,03,04,05,06,07,08,09,0A.

A2000

Address

Opcode

Label

Mnemonics

Operand

Comments

:2000

B8,00,04

 

MOV

AX,0400

Initialization

Of DS

:2003

8E,D8

 

MOV

DS,AX

:2005

BE,00,10

 

MOV

SI,3000

;3000 H copy in SI Register

:2008

BF,00,20

 

MOV

DI,2000

;2000 H copy in DI Register

 

:200B

B1,0A

 

MOV

CL,0A

;copy 0A in CL

:200D

8E,04

BACK:

MOV

AL,[SI]

;contents of SI copy on AL

:200F

88,05

 

MOV

[DI],AL

;copy contents of AL on DI

:2011

46

 

INC

SI

;increase SI

:2012

47

 

INC

DI

;increase DI

:2013

FE,C9

 

DEC

CL

;decrease CL

:2015

75,F6

 

JNZ

BACK

;jump if not zero;

:2017

CC

 

INT

03

;stop

 

RESULT:-D0200:2000:2009

                 0400:2000:-01

                      :2001:-02

                       2002:-03

2003:-04

2004:-05

2005:-06

2006:-07

2007:-08

2008:-09

2009:-0A

Q.8) Program Title-WALP(write assembly language program ) to find the given number is odd or even if number is odd store 00H on memory location [4000]else store FF H the number is 44H in a BL register.

[if d0 is the ‘1’the number is odd if d0 bit is ‘0’the number is even]

Abstract: AX, DS, BL, AL, DL, [4000]

Data:0200H, 44H, 01H, 11H, 0FFH

A2000

Address

Opcode

Label

Mnemonics

Operand

Comments

:2000

B8,00,02

 

MOV

AX,0200

Initialization

Of DS

:2003

8E,D8

 

MOV

DS,AX

:2005

B3,44

 

MOV

BL,44

;copy 44 in BL

:2007

D0,CB

 

ROR

BL,1

;check D0 bit

:2009

72,07

 

JC

ODD

;jump with carry

:200B

B2,FF

 

MOV

DL,0FF

;copy 0FF in DL

:200D

88,16,00,40

 

MOV

[4000],DL

;the no is even

:2011

EB,FA

 

JMP

END

;jump

:2013

B0,11

ODD:

MOV

AL,11

;the no. is odd

:2015

88,06,00,40

 

MOV

[4000],AL

;copy contents of AL on memory location [4000]

:2019

CC

END:

INT

03

;stop

 

RESULT:- 0200:[4000]:FF (number is even)

Q.9) Program Title:- WALP(write assembly language progam) to store 88H in AL register &find the number is +ve or –ve .if number is +ve store FF H on memory location [5000] otherwise store 00H.DS=0200H.

[if D7 is bit 0 the number is +ve, if D7 bit is 1 the number is –ve ]

Abstract:-AX, DS, AL, DL, [5000]


Data:-
0200H, 88H, 01H, 00H, 0FFH

A2000

Address

Operand

Label

Mnemonic

Operand

Comments

:2000

B8,00,02

 

MOV

AX,0200

Initialization

Of DS

:2003

8E,D8

 

MOV

DS,AX

:2005

B0,88

 

MOV

AL,88

;copy 88 in  AL

:2007

D0,C0

 

ROL

AL,1

;check D7bit

:2009

72,07

 

JC

NEG

;jump with carry

:200B

B2,FF

 

MOV

DL,FF

;no is +ve copy FF in DL.

:200D

88,16,00,50

 

MOV

[5000],DL

;and DL contents on memory location

:2011

CC

 

INT

3

;stop execution

:2012

B2,00

NEG:

MOV

DL,00

;no is –ve copy 00 in DL

:2014

88,16,FC,4F

 

MOV

[5000],DL

And DL content on Memory location .

:2018

CC

 

INT

3

;stop execution

 

Result:-0200:[5000]:00H(number is –ve)

Q.10)Program Title:-WALP(Write assembly language program)to find smallest number in block of 5 elements .block begins from memory location [2000].store the smallest number on memory location [5000].DS=0200.

Abstract: AX, DS, SI, CL, AL, [2000], [5000]

Data: DS:0200:[2000]:88

                            [2001]:22H

                           [2002]:33H

                            [2003]:77H

                           [2004]:55H

A2000

 

Address

Operand

Label

Mnemonic

Operand

Comments

:2000

B8,00,02

 

MOV

AX,0200

Initialization

Of DS

:2003

8E,D8

 

MOV

DS,AX

:2005

B8,00,20

 

MOV

SI,2000

2000 H copy in SI register

:2008

B1,04

 

MOV

CL,04

;copy 04 in CL

:200A

8A,04

 

MOV

AL,[SI]

;contents of memory location SI copy on AL register

:200C

46

BACK:

INC

SI

;increase SI

:200D

3A,04

 

CMP

AL,[SI]

;comparison for +ve or –ve

:200F

72,FC

 

JC

NEXT

;jump with carry

:2011

8A,04

 

MOV

AL,[SI]

;copy contents of SI memory location in AL register

:2013

FE,C9

NEXT:

DEC

CL

;decrease CL

:2015

75,F5

 

JNZ

BACK

;jump if not zero

:2017

88,06,00,50

 

MOV

[5000],AL

;copy  contents of AL on memory location [5000]

:201B

CC

 

INT

3

;stop

 

 

Result:-0200:[5000]:22H

 

 

 

Post a Comment

0 Comments