You are on page 1of 3
Exercises Which of the following names are legal in IBM PC assembly language? a. TWO_WORDS bom . © Two words a. er . e. $145 f. LET’s_co gts. . Which of the following are legal numbers? If they are legal, tell whether they are binary, decimal, or hex numbers. a. 246 b. 246h 1001 I. 1101 fe 2A3h {. FFREH Chapter 4 Introduction to IBM PC Assembly Language . 79 8. OAR h. Bh i. '1120b, if It Is legal, give data definition pseudo-ops to define each of the following. a. A word variable A initialized to 52 b. A word variable WORDI, uninitialized c. A byte variable B, initialized to 25h 4. A byte variable C1, uninitidlized e. A word variable WORD2, initialized to 65536 {A word array ARRAY1, initialized to the flrst five positive integers (i.e. 1-5) §. Acconstant BELL equal to 07h h. A constant MSG equal to ‘THIS IS A MESSAGES’ Suppose that the following data are loaded starting at offset 0000h: a DB “4 2 ow “> anscn c DB “HELLO’ a. Give the offset address assigned to variables.A, B, and C. b. Give the contents of the byte at offset 0002h in hex. ¢. “Give the contents of the byte at offset 0004n in hex. 4. Give the offset address of the character “O" in “HELLO.” ‘Tell whether each of the following instructions is legal or illegal. W1 and W2 are word variables, and B1 and 2 are byte variables. a. NOV DS,AX bv, Mov ps,1000n & Mov cs.Es d. Mov w1,0s XCHG Wi,w2 1 sup 5,81 8 AbD B1,P2 hh. ano at,25b i Mov W1BL 6. Using only MOV, ADD, SUB, INC, DEC, and NEG, translate the following high-level language assignment statements Into assem- bly language. A, B, and C are word variables. a. A=B-A b. Az-(A41) co CHAGB a. Be3x B+7 e ASB-A-1 7. Write instructions (not a complete program) to do the following. a, Read a character, and display it at the next position on the same tin . b. Read an uppercase letter (omit error checking), and display it at the next position on the same line in lower case. ling Exercises Programming Exercises 8. Write a progcam to (a) display a *2", (b) read two decimal digits : ‘whose sum is less than 10, (c) display them and their sum on the next line, with an appropriate message. Sample execution: 227 THE SUM OF 2 AND 7 IS 9 9. Write a program to (a) prompt the user, (b) tead first, middie, and last initials of a person's name, and (@) display them down the left margin. Sample execution ENTER THREE INITIALS: OFK J K 10, Write a program to read one of the hex digits AH, and display it on the next line in decimal. Sample execution: ENTER A HEX DiSIT: © IN DECIMAL IT 15 12 11, Write a program to display a 10 x 10 solid box of asterisks. Hint: declare a string in the data segment that specifies the box, and display it with INT 21h, function 9h. 12, Write a program to (a) display “2”, (b) read three initials, (©) dis- play them in the middie of an 11 x 11 box of asterisks, and (d) beep the computer.

You might also like