Вы находитесь на странице: 1из 3

# 'I"'WrglUll;ft8UV..

## Example 2.6 : data:

Consider the memory system of a computer storing the following

## Data stored (binary)

2000

01.11O00'

2001

00110100

2002

00110010

2003

00111001

Interpret the storage as numbers in the manner indicated below and find their decimal values in each case.
i) Big-endian storage of 2 hex words of 4-digits each.
ii) Big-endian storage of 2 BCD words of 4 -digits each.
iii) Little-endian storage, in ASCII, of a 4-digit signed hex word. iv) Little endian
storage, in ASCII, of a 4-digit BCD word.
Solution: We know that, big endian storage uses lower byte address for more-significant bytes and little-endian
storage uses lower byte address for less-significant bytes. Therefore, in big-endian storage given two words are :
3834H, 3239H and in little-endian storage given two words are : 3932H, 3438H.
i) Big-endian storage of 2 hex words of 4-digit each are : 3834H, 3239H

3239H

## BCD words of 4-digit each are : 3834, 3239.

3834 (BCD) = 3834 decimal 3239 (BCD) = 3239 decimal
ill) Little-endian storage in ASCII, of 4-digit signed hex word is: 9248H. Note: We
subtract 30H from ASCll code to get the digit value in hex.
9248H = 9x163 +2x162 +4x161 +8x16 = 37448 decimal
iv) Little-endian storage, in ASCII, of a 4-digit BCD word is : 9248
9248 BCD = 9248 decimal

locations. After execution of decision making instruction we have to f, two program sequences. In such
cases we can not use straight-line Sl we have to use branch instructions to transfer the program cc
sh'aight-line sequence to another straight-line sequence of instructic following program.
For example, see the program given for operation I A - B I. In f have to check whether A > B or B >
A and accordingly we have to p A - B or B - A.
MOV NUMl, RO MOV NUM2, Rl CMP RO,
Rl JB NEXT
SUB RO, Rl MOV R2, Rl
; Get the number 1 into RO ; Get the number 2 into Rl ; NUMI
; If NUMI < Num2
; Jump to another program se< ; NUMI ~ NUMI - NUM2
; Store the result in R2

- NUM2

SUB Rl, RO

## ; NUM2 ~ NUM2 - NUMI

MOV R2, RO
; Store the result in R2
In the above program we have used JB NEXT instruction to tran control to the instruction SUB Rl,
RO if NUMl is less than NLTM: decided to branch the program control after checking the conditi
instructions are called conditional branch instructions. We discuss
section 2.4.6. In branch instructions the new address called target a4 target is loaded into PC and
instruction is fetched from the new ac the instruction at the location that follows the branch instruction in
s order.
The conditional branch instructions are used for program loopinj program is instructed to execute
certain set of instructions repeate particular task number of times. For example, to add ten nwnbE
consecutive memory locations we have to perform addition ten times.
The program loop is the basic structure which forces the proo sequence of instructions. Loops have
four sections.

NEXT:

1. Initialization section.
2. Processing section. 3. Loop control section
4. Result section.
Computer Organization I 423
In binary notation, any signed integer is represented withn bits with lower (n-l) bits representing magnitude (value)
of the number and the highest bit, MSb (most significant bit) reserved for indicating sign of the number. If sign bit is
0, number is treated as positive and if sign bit is I, the number is taken as negative number. Since the last bit is not
available, the effective range of values that can be represented is halved. There are three formats of representat~on
for signed numbers. In all the formats, positive number representation remain the same. Negative numbers are
represented differently as for as magnitude is considered, even though the sign bit must be 1 in any format.
Generally, 2's-complement format is used for computer arithmetic on signed numbers. In this case, the total range of
values range from - 2n-l to + 2n-l_l.
Also, Refer p 24.
An integer of 32 bit size is stored in memory location in the little endian fashion. Indicate using a pseudo
program, how a big endian 16-bit processor could rearrange the number and store it properly for its use, back
in the
same location.
- July 2005
Soln: Let the number be 11223344 in decimal notation. In little etldian scheme, lowest byte is stored at lower
address. Assuming, byte addressable memory, this requires 4 memory locations to store the number.
A 16-bit processor can read/write 16-bit data parallely. Since it is bigend ian, the highest byte must be stored
The starting memory location is named NUM. Let RO, Rl and R2 be the 16bit registers available in the
processor. The pseudo code is written below.
Move (RO), Rl ; copy first 16-bit data to Rl

#2, RO

## Move (RO), R2 ; copy next 16-bit data to R2

Move Rl, (RO) ; store the first data in last locations
Sub

#2, RO

## Move R2, (RO)

Q.
; store the last data in starting locations

. CHAPTER 3

Q. Show the control sequences for execution of Add (R3), Rl and explain. Soln: Refer p 102
- Jan 2005
Q. Write assembly language program to solve the expression ax2 + bx + c. Soln: Refer p 414
- Jan 2005
Distinguish between unsigned and signed integers. With examples, indicate
when each type of integers will be useful.
- July 2005
Soln: Integers are whole numbers with decimal point to the rightmost position and a trailing zero after
the decimal point, and hence the decimal point is neglected. In unsigned integer representation, all numbers
are treated as positive numbers. For example, in a 4-bit system, the decimal values range from a to 15. So, in
an n-bit system, the values of the unsigned integers range from a to 211-1.

Q.