Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

Building a Bit-string Set from a Character String in Assembly Language, Exercises of Computer Architecture and Organization

An assembly language code snippet that builds a bit-string set from a given character string. Each bit in the bit-string corresponds to a letter, and is set to 1 if the letter is in the set, and 0 otherwise. The code uses a loop to iterate through each character in the string and sets the corresponding bit in the bit-string based on its ascii value.

Typology: Exercises

2012/2013

Uploaded on 04/27/2013

arundhati
arundhati 🇮🇳

4.5

(23)

89 documents

1 / 4

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
1. Sometimes you want to manipulate individual bits in a “string of bits”. For example, you can represent a set
of letters using a bit-string. Each bit in the bit-string is associated with a letter: bit position 0 with ‘A’, bit
position 1 with ‘B’, ..., bit position 25 with ‘Z’. Bit-string bits are set to ‘1’ to indicate that their corresponding
letters are in the set, and ‘0’ if not in the set. For example, the set { ‘A’, ‘B’, ‘D’ } would be represented as:
'A''B''C''D''E'
'Z' 'Y' 'X' . . .
bit position: 25 24 23 4 3 2 1 0
{ 'A', 'B', 'D' } is 0 0 0 0 1 0 1 1 0 0 0 0 0 0
unused
: r5
Complete the following code that uses the NULL-terminated character STRING in memory to build the
corresponding set of letters in r5.
AREA SHIFT_AND_LOGIC, CODE, READONLY
ENTRY
MOV r4, #'A' ; MOVE ASCII VALUE OF 'A'
MOV r5, #0 ; r5 IS THE EMPTY SET INITIALLY
MOV r0, #1 ; r0 HOLDS 1 TO BE SHIFTED TO BUILD THE MASK
ADR r6, STRING
WHILE
B WHILE
END_WHILE
STOP B STOP
AREA SHIFT_AND_LOGIC, DATA, READWRITE
STRING DCB "BAD",0
END
Computer Org. Lecture 18 Name:_______________
Lecture 18 Page 1
Docsity.com
pf3
pf4

Partial preview of the text

Download Building a Bit-string Set from a Character String in Assembly Language and more Exercises Computer Architecture and Organization in PDF only on Docsity!

  1. Sometimes you want to manipulate individual bits in a “ string of bits ”. For example, you can represent a set of letters using a bit-string. Each bit in the bit-string is associated with a letter: bit position 0 with ‘A’, bit position 1 with ‘B’, ..., bit position 25 with ‘Z’. Bit-string bits are set to ‘1’ to indicate that their corresponding letters are in the set, and ‘0’ if not in the set. For example, the set { ‘A’, ‘B’, ‘D’ } would be represented as:

'Z' 'Y' 'X'... 'E' 'D' 'C' 'B' 'A'

bit position: (^25 24 23 4 3 2 1 )

{ 'A', 'B', 'D' } is 0 0 0 0 0 0 0 0 0 0 1 0 1 1

unused

: r

Complete the following code that uses the NULL-terminated character STRING in memory to build the corresponding set of letters in r5.

AREA SHIFT_AND_LOGIC, CODE, READONLY ENTRY MOV r4, #'A' ; MOVE ASCII VALUE OF 'A' MOV r5, #0 ; r5 IS THE EMPTY SET INITIALLY MOV r0, #1 ; r0 HOLDS 1 TO BE SHIFTED TO BUILD THE MASK ADR r6, STRING WHILE

B WHILE

END_WHILE

STOP B STOP

AREA SHIFT_AND_LOGIC, DATA, READWRITE

STRING DCB "BAD",

END

Over simplified idea of branching hardware: