Assignment 14 for Computer Systems | ELEC 2220, Assignments of Electrical and Electronics Engineering

Material Type: Assignment; Class: COMPUTER SYSTEMS; Subject: Electrical and Computer En; University: Auburn University - Main Campus; Term: Fall 2008;

Typology: Assignments

Pre 2010

Uploaded on 08/16/2009

koofers-user-ugm
koofers-user-ugm 🇺🇸

8 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
ELEC 2220 - Computer Systems
Homework #14
Due: Friday, 10-3-08
1. Six ASCII characters, representing six decimal digits entered from a keyboard, are stored beginning at data
address STRG. Write a program to convert this string of characters to a packed BCD number and store it at
data address PACK. (A program would need to do this when numbers are entered from a keyboard.)
For example, if you type the number 135876 on the keyboard, the characters would be stored in memory as
follows: STRG => '1' (31h) - Most significant digit (100000’s)
STRG+1 => '3' (33h) Next most significant digit (10000’s)
STRG+2 => '5' (35h) Next most significant digit (1000’s)
STRG+3 => '8' (38h) - Next most significant digit (100’s)
STRG+4 => '7' (37h) Next most significant digit (10’s)
STRG+5 => '6' (36h) - Least significant digit (1’s)
Your program is to convert this to packed BCD format. The above would be stored in memory (most
significant byte first) as follows:
PACK => 13h
PACK+1 => 58h
PACK+2 => 76h
Demonstrate your program in CodeWarrior by initializing the six bytes of STRG as shown above, and the
three bytes of PACK to 00. Print the debug window showing the final values of these memory locations after
executing the program. (You might also want to test your program on additional sets of data.)
2. Write a program to do the inverse of the above operation, i.e. given the three-byte packed BCD number
starting at PACK, unpack and convert it to a string of six ASCII characters, representing the digits, storing
them in array STRG.
Demonstrate your program in CodeWarrior by initializing the six bytes of STRG to 00, and the three bytes of
PACK to the values shown above. Print the debug window showing the final values of these memory
locations after executing the program.

Partial preview of the text

Download Assignment 14 for Computer Systems | ELEC 2220 and more Assignments Electrical and Electronics Engineering in PDF only on Docsity!

ELEC 2220 - Computer Systems Homework # Due: Friday, 10-3-

  1. Six ASCII characters, representing six decimal digits entered from a keyboard, are stored beginning at data address STRG. Write a program to convert this string of characters to a packed BCD number and store it at data address PACK. (A program would need to do this when numbers are entered from a keyboard.)

For example, if you type the number 135876 on the keyboard, the characters would be stored in memory as follows: STRG => '1' (31h) - Most significant digit (100000’s) STRG+1 => '3' (33h) – Next most significant digit (10000’s) STRG+2 => '5' (35h) – Next most significant digit (1000’s) STRG+3 => '8' (38h) - Next most significant digit (100’s) STRG+4 => '7' (37h) – Next most significant digit (10’s) STRG+5 => '6' (36h) - Least significant digit (1’s)

Your program is to convert this to packed BCD format. The above would be stored in memory (most significant byte first) as follows: PACK => 13h PACK+1 => 58h PACK+2 => 76h

Demonstrate your program in CodeWarrior by initializing the six bytes of STRG as shown above, and the three bytes of PACK to 00. Print the debug window showing the final values of these memory locations after executing the program. (You might also want to test your program on additional sets of data.)

  1. Write a program to do the inverse of the above operation, i.e. given the three-byte packed BCD number starting at PACK, “unpack” and convert it to a string of six ASCII characters, representing the digits, storing them in array STRG.

Demonstrate your program in CodeWarrior by initializing the six bytes of STRG to 00, and the three bytes of PACK to the values shown above. Print the debug window showing the final values of these memory locations after executing the program.