0% found this document useful (0 votes)
21 views3 pages

EE337 Lab 2

This document describes three assembly language programming assignments for a microprocessors lab. 1. Write a program to add two 16-bit numbers stored in memory locations and store the 17-bit result in multiple memory locations. 2. Write a program to swap the contents of two memory locations using XOR logic. 3. Write a program to find the largest of 8 numbers stored in an array of memory locations and store the result in a specific memory location. The TA will check sample inputs for each program.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views3 pages

EE337 Lab 2

This document describes three assembly language programming assignments for a microprocessors lab. 1. Write a program to add two 16-bit numbers stored in memory locations and store the 17-bit result in multiple memory locations. 2. Write a program to swap the contents of two memory locations using XOR logic. 3. Write a program to find the largest of 8 numbers stored in an array of memory locations and store the result in a specific memory location. The TA will check sample inputs for each program.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

EE 337: Microprocessors Laboratory (Spring 2024)

Indian Institute of Technology Bombay


Lab 2: 20 points Date: January 12, 2024

1. [5 points] Write an assembly program to add two 16-bit numbers. Use the following
program as a starting point. Add your code in the ADD16 subroutine.

// -- DO NOT CHANGE ANYTHING UNTIL THE **** LINE--//


ORG 0H
LJMP MAIN
ORG 100H
MAIN:
CALL ADD16
HERE: SJMP HERE
ORG 130H
// *****************

ADD16:
// ADD YOUR CODE HERE
RET
END

• The first number x is stored at locations 70H and 71H, with its most significant
byte (MSB) in 70H and the least significant byte in 71H.
• The second number y is similarly stored at locations 72H (MSB) and 73H (LSB).
• Since the result z = x + y can be 17 bits long, store the result in memory
locations 74H, 75H, 76H.
• For z = z16 z15 z14 . . . z3 z2 z1 z0 where z0 is the least significant bit (LSB) and
z16 is the most significant bit (MSB), the memory location 74H should have
0000000z16 , the memory location 75H should have the bits z15 z14 . . . z8 , and the
memory location 76H should have the bits z7 z6 . . . z0 .

TA Checkpoint 1
Check the following two cases:

• x = 1234H, y = DCBAH.
• x = FFFFH, y = FFFFH.
2. [5 points] Write an assembly program to swap the contents of two memory locations
using XOR operation. Use the following program as a starting point. Add your codes
in the XOR SWAP subroutine.

Refer to XOR Swap Algorithm to understand how to perform the given task.

// -- DO NOT CHANGE ANYTHING UNTIL THE **** LINE--//


ORG 0H
LJMP MAIN
ORG 100H
MAIN:
CALL XORSWAP
HERE: SJMP HERE
ORG 130H
// *****************

XORSWAP:
// ADD YOUR CODE HERE
RET
END

• The inputs a and b are stored at locations 60H and 61H respectively.
• After the swap operation, location 60H must contain the value of b and location
61H must contain the value of a.

TA Checkpoint 2
Check the following two cases:

• a = 56H, b = 12H.
• a = 34H, b = E1H.
3. [10 points] Write an assembly program to find the largest of 8 given numbers. Use
the following program as a starting point. Add your codes in the MAX subroutine.

Refer to Largest Element in Array to understand how to perform the given task.

// -- DO NOT CHANGE ANYTHING UNTIL THE **** LINE--//


ORG 0H
LJMP MAIN
ORG 100H
MAIN:
CALL MAX
HERE: SJMP HERE
ORG 130H
// *****************

MAX:
// ADD YOUR CODE HERE
RET
END

• The input numbers must be stored in memory locations 60H to 67H.


• The result (largest value) must be stored in memory location 70H.
• To reduce the effort involved in adding multiple items in memory locations, you
can use the command window in Keil.
– Start a Keil debugging session.
– Enter the following command in the Keil command window to load an array
of 8 numbers represented in decimal format. The I:60h refers to indirect
addressing of location 60H. To inspect the memory, you should enter I:0x60
in the Keil memory window.

E char I:60h = 14h,69h,26h,5bh,7fh,1ah,00h,0c5h

TA Checkpoint 3
Check the following 2 cases:

• Inputs numbers = 14H, 69H, 26H, 5BH, 7FH, 1AH, 00H, C5H.
• Inputs numbers = D4H, CCH, C1H, AFH, 92H, D4H, 16H, 01H.

You might also like