0% found this document useful (0 votes)
156 views

COAL Assignment 2

This document contains 8 questions for an assembly language assignment. The questions involve: 1) Storing a date in a register in Day/Month/Year format using data labels for the components 2) Swapping every pair of bits in a register 3) Swapping the nibbles in each byte of a register 4) Calculating ones in a register and complementing an equal number of bits in another register 5) Copying a byte from a buffer to a register split across two bytes 6) Complementing a bit in one register based on the value in another 7) Repeatedly counting ones in a register until it contains a single one and tracking iterations 8) Writing an algorithm
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
156 views

COAL Assignment 2

This document contains 8 questions for an assembly language assignment. The questions involve: 1) Storing a date in a register in Day/Month/Year format using data labels for the components 2) Swapping every pair of bits in a register 3) Swapping the nibbles in each byte of a register 4) Calculating ones in a register and complementing an equal number of bits in another register 5) Copying a byte from a buffer to a register split across two bytes 6) Complementing a bit in one register based on the value in another 7) Repeatedly counting ones in a register until it contains a single one and tracking iterations 8) Writing an algorithm
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Assembly Language

(A,B,C) Fall 2017


Assignment-2
Submission: Monday 9th October (on xeon until labs are open)

Question 1:
There are three data labels in memory
Month: dw 7
Day: dw 20
Year: 88 ; year can be from 0 to 99 i.e., 2017 will be mentioned as 17
Write a program to store this date in one register in following format
Day/month/year

Question 2:
Write a program to swap every pair of bits in the AX register

Question 3:
Write a program to swap the nibbles in each byte of the AX register.

Question 4:
Calculate the number of one bits in BX and complement an equal number of least significant bits in AX.
HINT: Use the XOR instruction

Question 5:
Declare a 32byte buffer containing random data. Consider for this problem that the bits in these 32 bytes
are numbered from 0 to 255. Declare another byte that contains the starting bit number. Write a program
to copy the byte starting at this starting bit number in the AX register. Be careful that the starting bit
number may not be a multiple of 8 and therefore the bits of the desired byte will be split into two bytes.

Question 6:
AX contains a number between 0-15. Write code to complement the corresponding bit in BX. For
example if AX contains 6; complement the 6th bit of BX.

Question 7:
AX contains a non-zero number. Count the number of ones in it and store the result back in AX. Repeat
the process on the result (AX) until AX contains one. Calculate in BX the number of iterations it took to
make AX one. For example BX should contain 2 in the following case:
AX = 1100 0101 1010 0011 (input – 8 ones)
AX = 0000 0000 0000 1000 (after first iteration – 1 one)
AX = 0000 0000 0000 0001 (after second iteration – 1 one) STOP

Question 8:
Write an algorithm for extended multiplication of two 64 bit numbers. (extend the algorithm that we did
in class).

You might also like