-
Convert the following numbers to binary:
45 4CA9h
-
Convert the following numbers to decimal:
10111012 5Ah
-
Convert the following numbers to hex:
89 101100011101B
-
What is -14 in 8 bit 2's complement notation?
-
What is the 8 bit 2's complement number 11101011B in decimal?
-
Convert the following numbers to binary:
29 = 3CD9h =
-
Convert the following numbers to decimal:
110100B = 5Ah =
-
Convert the following numbers to hex:
101101011101B 176
-
Convert the following numbers to binary:
52 = 7EAFh =
-
Convert the following numbers to decimal:
10111001 B = 19Bh =
-
Convert the following numbers to hex:
1011010111010B = 210 =
-
Do the following arithmetic problems by converting to 8 bit 2-s complement binary numbers, performing the arithmetic in binary, then converting the result back to a signed decimal number. Indicate where overflow occurs. (Hint: 72 = 1001000B, 67 = 1000011B, and 39 =100111B)
72 -67
+ 39 +72
- 72 -67
+67 -39
-
Do the following arithmetic problems by converting to 8 bit 2-s complement binary numbers, performing the arithmetic in binary, then converting the result back to a signed decimal number. Indicate where overflow occurs, and why. (Hint: 83 = 1010011B, 58 =111010B, and 47 =101111B)
58 - 58
+47 + 47
-58 -58
- -83 +83
-
Do the following base conversions...
a) to base 10: 1011010B 0a6eh
b) to hex: 101101110010101B
c) to binary: 0a6eh
-
Do the following arithmetic problems by converting to 8-bit 2's complement, performing the arithmetic, and then converting back to the decimal answer. Indicate any overflow that occurs.
28 -28 82 -82
+75 +75 +75 +75
-
Convert to binary: 482
-
Convert to hex: 10110101001011B
-
Convert to decimal: 0ABH
-
Given that 35 = 00100011B, 87 = 01010001B, and 51 = 00110011B, do the
following arithmetic problems by translating to 8-bit 2's complement
form, doing the arithmetic in that form, and translating the result
back to decimal. Indicate where overflow occurs, and why.
35 -35
-87 -87
-51 -51
87 -87
-
What are the contents of ax after executing the following sequence of
instructions?
mov ax, 9876h ;
mov al, Od5h ; ax = ________________________________
-
Fill in the contents of ax in hex where requested in the comments below.
Stuff DW 89ABh
MoreOfIt DB 10h
Nonsense DB 32h
mov ax, Stuff ;ax = _____________
mov ax, 7654h
mov ah, MoreOfIt ;ax = _____________
mov al, Nonsense ;ax = _____________
mov ax, 7654h
mov al, ah ;ax = _____________
mov ax, 7654h
mov ah, 'a' ;ax = _____________
(HINT: 'a' = 97 = 61h)
mov ax, 7654h
mov ax, 'a' ;ax = _____________
mov ah, MoreOfIt
mov al, MoreOfIt + 1 ;ax = ___________
mov ah, 'a'
mov al, 'a' + 1 ;ax = _____________
mov ah, 5
mov al, 8 ;ax = _____________
-
Name the three major segments of a PC assembly language program,
and give a brief description of the function of each. (Hint: Each
is started by a pseudo-instruction beginning with a '.' .
a)
b)
c)
-
Write a complete assembly language program which displays the line
You owe me $nnnn
where nnnn is the decimal value of the word Dols declared in the
.DATA segment. (Use PutDec to display the value of Dols.)
-
Write data declarations and PCMAC.INC macro calls to display the
following line on the CRT screen and leave the cursor at the beginning of the next line:
Pay the $2.00
-
In order to use the macro _PutStr, what pseudo-instruction must
precede it in the program?
-
In order to use the instruction
call PutDec
(PutDec in UTIL.LIB) what pseudo-instruction must precede it in the
program?
-
Give assembly code necessary to display the two lines
One thing
Leads to another
Use only one DB statement.
-
Write assembly data and code to display the message
'Enter amount: ', read in a decimal number and then display
'The amount was $', followed by that number. A typical run might be
Enter amount: 1234
The amount was $1234
(Hint: remember that PutStr destroys ah and dx.)
-
Translate the following C statements into MASM code. All variables are assumed to be signed words.
a) X=A/ (5+B);
b) if (A+4<B) then X=X/2;
c) if (A <= B) then B = 2 else A = A -1;
d) if ((A < B) || (C == 0)) then X = 12;
-
Fill in the contents of the specified registers after the following
combinations of instructions have been executed?
A db 12h
C dw 4321h
mov ax, 1234h ; ax = _____________
mov al, A ; ax = _____________
mov ax, 1234h
mov ax, C ; ax = _____________
mov ax, 3FFFh
inc ax ; ax = _____________
mov ax, 3FFFh
inc AL ; ax = _____________
mov ax, -1
mov bx, -1
imul bx ; ax = _____________
; dx = _____________
-
Write assembly language code to perform the following C assignment statements. Assume that all variables are signed words.
(a) X = - (A + B) ;
(b) Y = 14 * (A - B);
(c) Z = Z - 1;
(d) W = (A + 20) / (X - 14);
-
Write assembly language code to effect the following C code
(assume signed WORD variables):
x = (a + 3) / 27;
-
Write assembly language code fragments to accomplish the same
purpose as the following C code. Assume that all variables are
signed words.
a) Counter = Counter - 1;
b) LastDigit = Numb % 10;
c) Average = (A + B + C) / 3;
d) Y = A - 24 * (X - 1);
-
Write assembly language code to effect the following C code (assume signed WORD variables):
x = a / (b - 1);
-
Fill in the blanks with the specified contents, in hex or binary:
mov ax, 1234h
mov al, -1 ; ax = _____________
inc ax
mov ax, 1234h
inc al ; ax = _____________
mov al, 80h
cbw ; ax = _____________
mov al, 77h
cbw ; ax = _____________
mov ax, -1
mov bx, 3
mul bx ; ax = _____________
; dx = _____________
mov ax, -1 ; bx still contains 3
imul bx ; ax = _____________
; dx = _____________
-
Fill in the blanks with the specified contents, in hex or binary:
mov ax, 1200h
dec ax ; ax = _____________
mov ax, 1200h
dec al ; ax = _____________
mov al, FEh
cbw ; ax = _____________
mov al, 5Eh
cbw ; ax = _____________
mov ax, -1
mov bx, 5
imul bx ; ax = _____________
; dx = _____________
mov ax, 3 ; bx is still 5
mul bx ; ax = _____________
; dx = _____________
mov ax. 3
imul bx ; ax = _____________
; dx = _____________
mov ax, 27
cwd
mov ax, 5
idiv bx ; ax = _____________
; dx = _____________
mov ax, -2
cwd
mov bx, 2
idiv bx ; ax = _____________
; dx = _____________
mov ax, -2
cwd
mov ax, 2
div bx ; ax = _____________
; dx = _____________
-
Write a complete MASM program which does the following: Read a
single character from the keyboard; compare the character read
to the to the character 'y'; if they are equal, display 'YES',
otherwise display 'MAYBE'.
-
Write assembly language code to perform the same function as the
following C code. Assume that all variables are signed words.
a) if (A > 14)
A = 0;
b) if (X <= Y)
{
A = X;
}
else
{
A = Y;
}
c) if ( (A >= B + 3) || (X = 100) )
M = 2 * M;
d) while (A < B)
{
A = A + 1;
B = B / 2;
}
-
Let N be a word variable and aChar a byte variable. Write code to
display N copies of aChar. Be sure that you display no characters
if N is 0.
-
Write assembly language code to effect the following C code
(assume signed WORD variables):
if ( (a > 4) || (rate = 15) )
{
b = a + 10;
}
else
{
b = a;
}
-
Suppose that A, B, C, X, Y, and Z are signed word variables.
Write assembly language code to accomplish the function of the
following C fragments:
a) while ( X > 0 )
{
X = X - 12;
A = A + 1;
}
b) if ( C <= 5 )
{
X = X + 1;
}
else
{
Y = Y - 1;
};
c) if (( A == 4) && (B > X + 7))
{
Y = 0;
}
-
Suppose that A, B, C, X, Y, and Z are signed word variables.
Write assembly language code to accomplish the function of the
following C fragments:
a) if (A > X + 5)
{
Max = A;
else
{
Max = X + 5;
}
b) while (M != N)
{
if (M > N)
{
M = M - N;
}
else
{
N = N - M:
}
c) if ((Day == 1) || (Day == 7))
{
Weekend = 1 ;
}
d) if (X < 0)
{
Sgn = -1;
}
else if (X > 0) |
{
Sgn = 1;
}
else
{
Sgn = 0;
}
-
Write assembly language code to effect the following C code (
assume signed WORD variables):
a) if ((a > 4) || (rate = 15) )
{
b = a + 10;
{
else
{
b = a;
}
b) Count = 0;
ReadKey = getchar( ); /*ASCII value goes to al */
while (al == '*')
{
Count = Count + 1;
ReadKey = getchar( );
} /* Note: only one getchar( ) required! */
c) for( I = 1; I <= 80; I++)
{
printf("*");\
}
d) Sum = 0;
for (I = 1; I <= 100; I++)
{
Sum = Sum + I;
}
printf("The sum is %d\n", Sum);
-
Write code which jumps to the label Beyond defined elsewhere
if OFFSET A occurs in memory after OFFSET B, where A and B are
labels defined in the .DATA segment.
-
Write a complete, separately translated assembly language function
Unmax which takes as input two unsigned numbers in ax and bx and
returns as its value (in ax) the larger of the two.
-
Write a test program TestProg which tests UnMax by calling it with
three appropriate sets of values and displaying the results.
-
Give the appropriate commands to assemble, link, and execute
TestProg.
-
The instruction
push 153
is illegal. (That is, pushing a literal is illegal.). Write code
to show how this could be done legally:
-
Describe exactly what happens when the following instruction is
executed
call Whatsit
-
Describe exactly what happens when the following instruction
is executed
ret
-
Write a complete separately compiled assembly language procedure
PutSmall which takes as input a number in the range 0..99 in AL
and displays the number with leading zeroes. That is, it is always
displayed as precisely two digits. Since I told you that you
weren't going to have to divide, I will give you an alternate
method: The instruction AAM (ASCII Adjust for Multiplication) does
AH := AL div 10, AL := AL mod 10 (the original AL on the right
side in both cases.)
-
The macro @GetTime returns the time of day, CH = hours,
CL = minutes, and DH = seconds. Write an assembly fragment
which uses @GetTime and PutSmall to display the current time in
the form hh:mm:ss.
-
Suppose that Digit is a byte variable containing a digit
character (e.g., '3'). Write assembly code to convert Digit to
its numeric value (0..9) and store it in the word variable Value.
-
Suppose that ah and al are the left and right bytes, respectively,
of the ASCII representation of a two digit number. Write assembly
code to convert this number to its numeric equivalent and leave
the result in ax. For instance, if at the start ah = '3' and
al = '5', when you are done you should have ax = 35 (= 0023h).
Use any registers you wish.
-
-
Write a macro message such that the call Message
<This is a message> causes the parameter
'This is a message' to be displayed followed by a carriage return
and line feed.
-
Write a macro NonNeg A which changes the value of A to 0 if A
is less than 0.
-
Write a macro HexIt D which takes a number in a byte D,
0 <= D <= 15, and displays it as a single hex digit on the CRT. (0 is displayed as '0',10 as 'a', etc.)
-
Using HexIt, write a complete separately compiled procedure
PutoctB which displays the byte in the AL register as three
octal (base 8) digits. (These three digits are, left to right,
bits 6-7, bits 3-5, and bits 0-2. It is probably better to do
this as three separate cases than to try to write a loop to do
it. Use the back of this page to complete the procedure if
necessary.)
-
Suppose the following macro has been defined:
AMac MACRO a, b, c
cmp a, b
jz c
ENDM
What code will be generated by the following invocations of the macro? (Note that some of the code is invalid!)
a) AMac X, 14, ALabel
b) AMac X+3, 14, ALabel
-
a) Write a macro Thrice which displays its argument three times, each
time followed by an exclamation point. Thus Thrice Help would
display Help! Help! Help! (You may assume that the macro _PutStr
is available.)
b) How would you use Thrice to display the message Help Me! Help Me! Help Me!
-
Suppose the following macro has been defined:
AMac MACRO a, b, c
cmp a, b
jz c
ENDM
What code will be generated by AMac X, 14, ALabel
-
Suppose the following macro has been defined:
BMac MACRO a, b, z, c
cmp a, b
jz c
ENDM
What code will be generated by BMac X, 14 , ge, Alabel
-
Suppose the following macro has been defined:
CMac MACRO a, b, z, c
cmp a, b
j&z& c
ENDM
What code will be generated by CMac X , 14 , ge , ALabel
-
The following probably won't work. Explain why, and fix it:
LongJZ MACRO aLabel
jnz around
jmp aLabel
around:
END
-
What will the contents of the register ax be after executing each
of the following instruction sequences?
mov ax, 5
shl ax, 1 ; ax =_____________________
mov ax,10011100101b ;binary
and ax,11001001110b ; ax =_____________________
-
PWORD is a word containing a 9 bit quantity in bits 3-11
(numbered from right to left, 0 to 15). Write MASM code to
extract this quantity and store it in the word N.
-
The word X contains a field in bits 6-11 (numbering from the
right starting at 0). Write assembly code to extract this field
and store it as a number from 0 to 63 in the word N.
-
Write assembly language code which sets bits 5-9 of the word X
to 11001B. (Bits are numbered from right to left, starting at 0.)
-
Write assembly language code which extracts the contents of
bits 5-9 of word X, shifts them all the way to the right, and
stores them in the word Field.
-
Fill in the contents of BL at the indicated places in the
comments in the following code:
mov bl, 11110000B
and bl, 11001100B ; bl =_____________________
mov bl, 11110000B
or bl, 11001100B ; bl =_____________________
mov bl, 11110000B
xor bl, 11001100B ; bl =_____________________
mov bl, 11110000B
not bl ; bl =_____________________
mov bl, 11110000B
shl bl, 1 ; bl =_____________________
mov bl, 11110000B
rol bl, 1 ; bl =_____________________
mov bl, 11110000B
shr bl, 1 ; bl =_____________________
mov bl, 11110000B
sar bl, 1 ; bl =_____________________
-
N is a word variable.
a) Write assembly code to extract the number in bits 4-11 of
N and place it, right justified, in the AX register. Remember
that bits are counted from the right end of the number, starting
at 0.
b) Write assembly code to store the contents of AL in bits 4-11
of the word N. (AH may contain any sort of garbage).
-
Suppose that X is a word variable with bits numbered as usual
from 0-15, right to left. Write assembly language fragments to
accomplish the following:
a) Set bit 5 of X to 1
b) Set bits 4-6 of X to 0
c) Toggle bit 8 (i.e., set it to 1 if it was 0, to 0 if it was 1)
d) Set bits 4-9 of X to 101011B. Note: Previous contents of these bits might be anything, so they have to be cleared first.
-
Write an assembly code fragment which sets the word variable N
equal to the number of 1 bits in the word X. That is, if X =14
(=1110B), then N = 3, and if X = -1, N =16.
-
Fill in the blanks with the specified contents, in hex or binary:
MASK EQU 00111100B
mov al, 11100101B
and al, MASK ; al =_____________________
mov al, 11100101B
or al, MASK ; al =_____________________
mov al, 11100101B
xor al, MASK ; al =_____________________
mov al, 11100101B
not al ; al =_____________________
mov al, 11100101B
neg al ; al =_____________________
mov al, 11100101B
shr al, 1 ; al =_____________________
mov al, 11100101B
sar al, 1 ; al =_____________________
mov al, 11100101B
ror al, 1 ; al =_____________________
-
In file directories, times are stored in the form: Second/2 in
bits 0-4, minute in bits 5-10, and hour (0..23) in bits 11-15.
(Bits are counted from the right. Only seconds/2 can be stored
because there are only 5 bits left.) Suppose that Timel and
Time2 are words containing such times and that Minute is also a
word.
a) Write assembly code to extract the minute from Time1 and store
it as a number between 0 and 59 in Minute.
b) Write assembly code to store a number in Minute between 0 and
59 into the minute position of Time 2.
c) Write code which jumps to the label Later defined elsewhere
if Time2 represents a later time than Time 1. (Careful!)
-
As you may recall, each of the (2000) characters on the normal
IBM PC color display screen has color characteristics controlled
by an attribute byte whose format is: bits 0-2, foreground
color; bit 3, intensity bit for foreground color; bits 4-6,
background color; bit 7, the blink bit. Bits are numbered right
to left and colors are in the form red-green-blue from left to
right. Attr1 and Attr2 are such attribute bytes and Color is a
word containing such a color as a number in the range 0..7
a) Write an assembly instruction to turn on (set to 1) the blink
bit in Attr1.
b) Write an assembly instruction to turn off (set to 0) the
intensity bit in Attr1.
c) Write an assembly instruction to complement the bits of the
foreground color in Attrl.
d) Write assembly code to test the intensity bit in Attr1 and
jump to label High if it is on.
e) Write assembly code to extract the background color from Attr1
and store it as a number between 0 and 7 in Color.
f) Write assembly code to store a number in Color between 0 and 7
into the background color position of Attr2.
-
The following code sets cx equal to the number of trailing
zeroes in ax. For instance, if ax started at 48 =110000B this
code sets cx to 4.
mov cx, 0
CountLoop:
shr ax, 1
jc Done ; Jump if carry bit set
inc cx
jmp CountLoop
a) Turn this code into a separately assembled procedure called
TrailZ which takes as input a number in ax and returns as
output also in ax the number of trailing zeroes that were in
the input number. Preserve all registers except ax.
b) Show what code would be necessary to use this procedure to
set the word variable Pow equal to the number of trailing
zeroes in the word variable X
c) The original code doesn't work correctly if ax was originally
zero. How does it fail?
d) Fix the original code so that it works correctly for ax
initially zero.
-
Suppose we have declared
SomeWds DW 73,14, -22, 25, 8, 3, 27
what is in ax at the specified points in the code below?
mov bx, OFFSET SomeWds+4
mov ax, [4 + bx] ; ax =_____________________
mov ax, [-4 + bx] ; ax =_____________________
mov bx, 8
mov ax, [SomeWds + bx] ; ax =_____________________
mov ax, [SomeWds+4 + bx] ; ax =_____________________
mov ax, [SomeWds-2 + [bx] ; ax =_____________________
mov ax, [SomeWds+1+bxl ; ax =_____________________
(NOTE: the last one is a trick question, but it does have an answer!)
-
Suppose we have declared
SomeWds DW 010Ah, 020Bh, 030Ch, 040Dh, 050Eh, 060Fh, 0700h
what is in ax at the specified points in the code below?
mov bx, OFFSET SomeWds+4
mov ax, [4+bx] ; ax =_____________________
mov ax, [-4+bx] ; ax =_____________________
mov bx, 8
mov ax, [SomeWds+bx] ; ax =_____________________
mov ax, [SomeWds+4+bx] ;ax =_____________________
mov ax, [SomeWds-2+bx] ; ax =_____________________
mov ax. BYTE PTR SomeWds ; ax =_____________________
mov ax, SomeWds+1 ; ax =_____________________
-
Alpha is an array of 26 characters. Write a MASM code fragment
to set Alpha[0] = 'a', Alpha[1] ='b', ..., Alpha[25] ='z'.
-
Suppose that the following data-defining pseudo-instructions are given:
A DB 98h
B DB 76h
C DW 5432h
What will the contents of the following bytes of memory be?
A: ________________
B: ________________
C: ________________
________________
-
What are the contents of the specified registers at the specified points?
A DB OAh, lAh, 2Ah, 3Ah, 4Ah, 5Ah
B DW OBh, 1Bh, 2Bh, 3Bh, 4Bh
mov al, [A] ; al = ________________
mov al, [A+3] ; al = ________________
mov ax, [B+2] ; ax = ________________
mov ax, [B+6] ; ax = ________________
mov ax, [B-2] ; ax = ________________
mov al, 11001010B
shr al, 1 ; al = ________________
mov al, 11001010B
sar al, 1 ; al = ________________
mov al, 11001010B
ror al, 1 ; al = ________________
mov al, 11001010B
shl al, 1 ; al = ________________
mov al, 11001010B
sal al, -1 ; al = ________________
mov al, 11001010B
rol al, 1 ; al = ________________
mov cl, 5
mov al, 11001010B
rol al, cl ; al = ________________
mov al, Ofh
shl al, 1 ; al = ________________
mov al, 11001010B
and al, 011110008 ; al = ________________
mov al, 11001010B
or al, 01111000B ; al = ________________
mov al, 11001010B
xor al, 01111000B ; al = ________________
-
Suppose that the following data-defining pseudo-instructions are
given:
A DB 98h
B DB 76h
C DW 5432h
What will the contents of ax be after the following combinations
of mov instructions have been executed?
mov ax, 1234h ; ax = ______________
mov al, A ; ax = ______________
mov ax, 1234h ;
mov ax, C ; ax = ______________
mov ax, 1234h
mov ax, WORD PTR A ; ax = ______________
mov ax, 1234h
mov ax, WORD PTR B ; ax = ______________
mov ax, 1234h
mov ah, BYTE PTR C ; ax = ______________
-
Suppose we have defined
P DW 5, 18, 4, 23, -7, 432, 277, 1
What is AX after executing the following instructions?
mov bx, OFFSET P
mov ax, [4 + bx] ; ax = ______________
mov bx, OFFSET P+6
mov ax, [4 + bx] ; ax = ______________
mov ax, [-4 + bx] ; ax = ______________
mov bx, 6
mov ax, [P + bx] ; ax = ______________
mov ax, [P - 2 + bx] ; ax = ______________
mov ax, [P + 6 + bx] ; ax = ______________
-
Suppose that A is an array of 20 words. What does the following
code do (generally)?
sub ax, ax
mov bx, OFFSET A
mov cx, 20
mov dx, 1
Aloop:
mov [bx], ax
add bx, 2
add dx, 2
loop Aloop
9. GLARG is an array of 25 words. Write assembly code to set
the word variable BIGGEST to the largest number in the
GLARG array.
-
The array
int flub[ 6 ]
is to be represented in assembly code as
flub dw 6 DUP (?)
I and N are defined as integer (signed word) variables.
Write assembly code to perform N = flub[I], i.e., to have the
same effect as the C code N = flub[ I ];
-
Let the FIB array be defined by
FIB DW 15 DUP (?)
Write Assembly language code which sets FIB to the first 15
Fibonacci numbers; i.e.,
FIB(0) = 0,
FIB(1) = 1, and
FIB(N) = FIB(N -1) + FIB(N - 2)]
-
Given the data definition
X DB 0Ah, 0Fh
Fill in the contents of ax after the instruction
mov ax, WORD PTR X ; ax = ______________
-
Suppose we have defined
A DW 0A00h, 0A0lh, 0A02h, 0A03h
B DW 0B00h, 0B0lh, 0B02h
C DW 0C00h, 0C0lh, 0C02h, 0C03h, 0C04h
N DW 3
What are the contents of the specified registers after
executing the following instructions?
mov ax, [B] ; ax = ______________
mov ax, [B+4] ; ax = ______________
mov ax, [B-4] ; ax = ______________
mov al, BYTE PTR [B+1] ; ax = ______________
mov ax, [A+16] ; ax = ______________
mov bx, 4
mov ax, [A + bx] ; ax = ______________
mov ax, [A + 2 + bx] ; ax = ______________
mov bx, OFFSET B
mov ax, [bx] ; ax = ______________
mov ax, [2 + bx] ; ax = ______________
mov ax, [C-B+bx] ; ax = ______________
mov si, 2
mov ax, [bx + si] ; ax = ______________
mov ax, [2+bx+si] ; ax = ______________
mov bx, N
shl bx, 1
mov ax, [A + bx] ; ax = ______________
mov ax, [A-2+bx] ; ax = ______________
-
Suppose that A is an array of 100 words, subscripted 0..99, and
that I is a word variable.
a) Write an assembly language instruction to set A[3] := 44.
b) Write assembly language code to set A[I] := 44.
c) Write assembly language code to set A[I+3] := 44.
-
A and B are arrays of 50 words.
a) Write assembly code to copy the contents of the B array into
the A array.
b) Write assembly code to set the word variable BIG equal to the
largest (signed) element in the A array.
-
Suppose we have declared:
C DB ?
HexDig DB '0123456789ABCDEF'
D DW ?
Suppose that D is a number between 0 and 15. Use it as a subscript into the HexDig array to set C equal to the ASCII hex digit corresponding to the value in D.
-
Suppose we have defined
C DW 0C00h, 0C01h, 0C02h, 0C03h, 0C04h, 0C05h, 0C06h
N DW 4
What are the contents of the specified registers after executing the following instructions?
mov ax, [C+4] ; ax = ________________________
mov si, 6
mov ax, [C + si] ; ax = ________________________
mov ax, [C - 2 + si] ; ax = ________________________
mov bx, OFFSET C
mov ax, [bx + si] ; ax = ________________________
mov bx, N
shl bx, 1
mov ax,.[C + bx] ; ax = ________________________
;
mov ax, [C - 2 + bx] ; ax = ________________________
-
Suppose that A is an array of 100 words and that I is a word
variable.
a) Write assembly language code to set A[I] = 53.
b) Write assembly language code to set the word variable LITTLE equal to the smallest (signed) element in the A array.
-
Suppose that C is an array of 100 characters and that we have
included the array UpIt in our program by making the declaration
EXTRN UpIt : BYTE
in the .DATA segment. Recall that Upit has the property that
for any character X, if X is a lower-case letter, then UpIt[X]
is the upper case version of X and otherwise, UpIt is just X.
Write the code fragment which uses UpIt to convert all the
lower case into upper case.
- In the game of Scrabble, each letter of the alphabet has an
associated value. (More common letters, such as 'E', have
the value 1 while rare letters, such as 'X' have the high
values, such as 10.) Suppose that SCRABVAL is an array of
256 bytes such that for any letter L, SCRABVAL[I] is the
scrabble value of the letter L. suppose that C is an array
of bytes constituting a word, terminated by the '$' character.
Write code to set dx to the sum of the values of the letters
in the word at C.