SlideShare a Scribd company logo
2
Most read
4
Most read
5
Most read
A solution manual to
Assembly language
Programming
and the organization of
the IBM PC
Chapter 4
Introduction to IBM PC Assembly language
BY:- Ytha Yu & Charles Marut
prepared by :
Warda Aziz
Wardaaziz555@gmail.com
Question 1:
Which of the following names are legal in IBM PC assembly language?
Names Status
TWO_WORDS Legal
?1 Legal
Two words illegal
.@? illegal
$145 legal
Let’s_go illegal
T= illegal
Question 2:
Which of the following names are legal numbers? If they are legal , tell whether they
are binary , decimal or hex?
Numbers Status
246 decimal
246h hex
1001 decimal
1,101 illegal
2A3h hex
FFFEh illegal
0Ah hex
Bh illegal
1110B binary
Question 3:
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 WORD1 uninitialized.
c) A byte variable B initialized to 25h
d) A byte variable C1, uninitialized
e) A word variable WORD1, initialized to 65536
f) A word array ARRAY1, initialized to the first five positive integers
g) A constant BELL equal to 07h
h) a constant message equal to ‘THIS IS A MESSAGE$’
Solution:
A word variable A initialized to 52
A DW 52
A word variable WORD1 uninitialized.
WORD1 DW ?
A byte variable B initialized to 25h
B DB25h
A byte variable C1, uninitialized
C1 DB ?
A word variable WORD1, initialized to 65536
WORD1 DW 65536
A word array ARRAY1, initialized to the first five positive integers
ARRAY1 DW 1,2,3,4,5
A constant BELL equal to 07h
BELL EQU 07h
A constant message equal to ‘THIS IS A MESSAGE$’
MSG EQU ‘THIS IS A MESSAGE$’
Question 4:
Suppose that the following data are loaded starting at offset 0000h
A DB 7
B DW 1ABCh
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
c. Give the contents of the byte at offset 0004h in hex
d. Give the offset address of the character “O” in “HELLO”
variable content Address
A 7 0000
B BC 0001
1A 0002
C H 0003
E 0004
L 0005
L 0006
0 007
A) A: 0000
B: 0001
C: 0003
B) 1A
C) E
D)0007
Question 4:
Tell whether each of the instructions is legal or illegal
instruction status
MOV DS,AX Legal
MOV DS, 1000h Illegal ;can’t use seg register with an
immediate value
MOV CS,ES Illegal; seg registers cannot go together
MOV W1, DS Legal
XCHG W1,W2 Illegal
SUB 5, B1 Illegal
ADD B1,B2 illegal
ADD AL, 256 illegal
MOV W1,B1 Illegal
Question 6:
Using only MOV , ADD, SUB, INC, DEC and NEG , translate the following high
level language assignment statements into assembly language A,B and C are word
variables.
A) A=B-A
B) A=-(A+1)
C) C=A+B
D) B=3*B+7
E) A=B-A-1
A=B-A
MOV AX, a
MOV BX, b
SUB BX,AX
MOV AX,BX
A=-(A+1)
MOV AX,A
ADD AX,1
NEG AX
MOV A,AX
C=A+B
MOV AX,A
ADD AX,B
MOV C,AX
B=3*B+7
MOV AX,B
ADD AX,B
ADD AX,B
ADD AX,7
MOV B,AX
A=B-A-1
MOV BX,B
SUB BX,A
SUB BX,1
MOV A, BX
Question 7:
Write instructions to do the following.
A. Read a character and display it at the next position on the same line
B. Read an uppercase letter and display it at the next position on the same line in lower
case
Read a character and display it at the next position on the same line
mov ah,1
int 21h
mov ah,2
mov dl,al
int 21h
Read an uppercase letter and display it at the next position on the same line in lower
case
mov ah,1
int 21h
add al,20h
mov ah,2
mov dl,al
int 21h
Question 8:
Write a program to
a) display a “?”
b) read two decimal digits whose sum is less than 10
c)display them and their sum in the next line with an appropriate message.
Code:
.MODEL SMALL
.STACK 100H
.DATA
MSG DB 0AH, 0DH, "The sum of "
VAR DB ?, ' and '
var2 DB ? , ' is ';
sum DB ?,"$"
.CODE
MAIN PROC
;DATA INITIALIZATION
MOV AX, @DATA
MOV DS, AX
; DISPLAY ? TO PROMPT THE USER FOR INPUT
MOV AH, 2
MOV DL, '?'
INT 21H
;READ DECIMAL DIGITS
MOV AH, 1
INT 21H
MOV VAR, AL ; storing var in another reg
;INPUT 2ND VARIABLE
INT 21H ; storing VAR2 in AL
MOV var2, AL
;ADDING VARIABLES
ADD AL, VAR
SUB AL, 30H ;there is ASCII coding in background so subtracting code 30h
MOV SUM , AL
;DISPLAY MSG
LEA DX, MSG
MOV AH, 9
INT 21H
;DOS EXIT
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Output:
Question 9:
write a program to
A) prompt the user
B) Read first middle and last initials of a person’s name
C) And display them down the left margin
Ans:
.MODEL SMALL
.STACK 100H
.DATA
MSG DB 0AH, 0DH,, "Enter three initials:$"
A DB ?
b DB ?
c DB ?
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
;DISPLAYING LINES
LEA DX, MSG
MOV AH, 9
INT 21H
;TAKING INPUT
MOV AH, 1 ;First input
INT 21H
MOV A, AL
INT 21H ;Second input
MOV B, AL
INT 21H ;3rd input
MOV C, AL
;LINE FEED
MOV AH,2
MOV DL, 0AH
INT 21H
MOV DL, 0DH
INT 21H
;display function
MOV AH, 2
MOV DL, A
INT 21H
;LINE FEED
MOV AH,2
MOV DL, 0AH
INT 21H
MOV DL, 0DH
INT 21H
;DISPLAY 2ND NUM
MOV AH, 2
MOV DL, B
INT 21H
;LINE FEED
MOV AH,2
MOV DL, 0AH
INT 21H
MOV DL, 0DH
INT 21H
;DISPLAY
MOV AH, 2
MOV DL, C
INT 21H
; DOS EXIT
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Output:
Q 10:
Write a program to read one of the hex digits A-F;and display it on the next line in
decimal.
Ans:
.MODEL small
.STACK 100h
.DATA
MSG DB 'enter a hex digit'
C db ?, '$'
MSG2 DB 0AH,0DH,"In decimal it is: 1"
C2 db ?,'$'
MAIN PROC
MOV AX, @DATA
MOV DS,AX
;Displaying first message
MOV AH, 9
LEA DX, MSG
INT 21H
;input
MOV AH,1
INT 21H
MOV C, AL
;CALCULATION
SUB AL, 11H
MOV C2,AL
;DISPLAY
MOV AH,9
LEA DX, MSG2
INT 21H
;DOS EXIT
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Output:
Question 11:
write a program to display a 10*10 solid box of asterisk.
Hint: declare a string in the data segment that specifies the box and display it with INT
21h function 9h.
Ans:
.MODEL SMALL
.STACK 100H
.DATA
MSG DW 0AH,0DH,'**********$'
.CODE
MAIN PROC
MOV AX, @DATA
MOV DS, AX
;FUNCTION 9 FOR DISPLAYING OUTPUT STRING
MOV AH,9
LEA DX ,MSG
INT 21H ;OUTPUT FOR first line
INT 21H ;output for second line
INT 21H ; .
INT 21H ; .
INT 21H ; .
INT 21H ; .
INT 21H ; .
INT 21H ; .
INT 21H ; .
INT 21H ; output for the 10th line
;DOS EXIT
MOV AH, 4CH
INT 21H
MAIN ENDP
END MAIN
Output:
Write a program to display
a) ?
b) Read three initials
c) Display them in the middle of an 11*11 box of asterisk
d) Beep the computer
Ans:
.STACK 100h
.MODEL small
.DATA
msg DB "?$"
msg1 DB 0Ah, 0Dh,"**********$"
msg2 DB 0Ah, 0Dh,"***"
ch1 DB ?
ch2 DB ?
ch3 DB ?,"****$"
.CODE
main PROC
MOV AX, @DATA
MOV DS, AX
;prompt the user for ?
MOV AH,2
MOV DL, msg
INT 21h
;enter initials
MOV AH,1
int 21h
MOV ch1, AL
INT 21h
MOV ch2, AL
INT 21h
MOV ch3, AL
; output
MOV AH,9
lea DX, msg1
INT 21h
INT 21h
INT 21h
INT 21h
INT 21h
INT 21h
LEA DX, msg2
INT 21h
LEA DX, msg1
INT 21h
INT 21h
INT 21h
INT 21h
INT 21h
;BEEP THE COUNTER
MOV AH, 2
MOV DL, 7H
INT 21H
;dos exit
MOV AH, 4Ch
INT 21h
main ENDP
END main
Output

More Related Content

What's hot (20)

PPTX
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Bilal Amjad
 
PDF
Assembly language (coal)
Hareem Aslam
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Bilal Amjad
 
PPTX
Assembly 8086
Mustafa Salah
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Bilal Amjad
 
PPT
Assignment on alp
Jahurul Islam
 
PDF
Solution manual of assembly language programming and organization of the ibm ...
Tayeen Ahmed
 
PPTX
Multiplication & division instructions microprocessor 8086
University of Gujrat, Pakistan
 
PDF
8086 instructions
Ravi Anand
 
PPT
Jumps in Assembly Language.
NA000000
 
PDF
Assembly language 8086
John Cutajar
 
PPT
Lecture 3,4
shah zeb
 
PDF
Unit 3 – assembly language programming
Kartik Sharma
 
PPTX
Logical, Shift, and Rotate Instruction
Badrul Alam
 
PPTX
Addressing modes of 8086
saurav kumar
 
PDF
Instruction formats-in-8086
MNM Jain Engineering College
 
PPTX
Addressing modes
karthiga selvaraju
 
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Bilal Amjad
 
Assembly language (coal)
Hareem Aslam
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Bilal Amjad
 
Assembly 8086
Mustafa Salah
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Bilal Amjad
 
Assignment on alp
Jahurul Islam
 
Solution manual of assembly language programming and organization of the ibm ...
Tayeen Ahmed
 
Multiplication & division instructions microprocessor 8086
University of Gujrat, Pakistan
 
8086 instructions
Ravi Anand
 
Jumps in Assembly Language.
NA000000
 
Assembly language 8086
John Cutajar
 
Lecture 3,4
shah zeb
 
Unit 3 – assembly language programming
Kartik Sharma
 
Logical, Shift, and Rotate Instruction
Badrul Alam
 
Addressing modes of 8086
saurav kumar
 
Instruction formats-in-8086
MNM Jain Engineering College
 
Addressing modes
karthiga selvaraju
 

Similar to Introduction to ibm pc assembly language (20)

PPTX
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
PPTX
Introduction to Assembly Language & various basic things
ishitasabrincse
 
PPT
Assembly Language Basics
Education Front
 
PPT
8051assembly language
Hisham Mat Hussin
 
PDF
computer architecture Lecture 8 for computer science
kareem mohamed
 
PPT
12 mt06ped008
vijaydeepakg
 
PDF
Lab report assembly
Syed Ahmed Zaki
 
PPTX
6 assembly language computer organization
wewiv47743
 
PPTX
Lec06
siddu kadiwal
 
PDF
Lecture6
misgina Mengesha
 
PPTX
outline : basicc elements of assembly language
rivadiab30663
 
PPTX
Assembly Language Tutorials for Windows - 03 Assembly Language Programming
Sangram Kesari Ray
 
PPTX
Micro task1
ChetanShahukari
 
DOCX
HW2.pdfCSEEEE 230 Computer Organization and Assembly La.docx
adampcarr67227
 
PPT
Assembly language programming_fundamentals 8086
Shehrevar Davierwala
 
DOCX
64-bit Assembly language program to Accept and display numbers.docx
VidyaAshokNemade
 
PDF
8086 microprocessor lab manual
University of Technology - Iraq
 
PDF
8086 labmanual
Murali Krishna
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
Introduction to Assembly Language & various basic things
ishitasabrincse
 
Assembly Language Basics
Education Front
 
8051assembly language
Hisham Mat Hussin
 
computer architecture Lecture 8 for computer science
kareem mohamed
 
12 mt06ped008
vijaydeepakg
 
Lab report assembly
Syed Ahmed Zaki
 
6 assembly language computer organization
wewiv47743
 
outline : basicc elements of assembly language
rivadiab30663
 
Assembly Language Tutorials for Windows - 03 Assembly Language Programming
Sangram Kesari Ray
 
Micro task1
ChetanShahukari
 
HW2.pdfCSEEEE 230 Computer Organization and Assembly La.docx
adampcarr67227
 
Assembly language programming_fundamentals 8086
Shehrevar Davierwala
 
64-bit Assembly language program to Accept and display numbers.docx
VidyaAshokNemade
 
8086 microprocessor lab manual
University of Technology - Iraq
 
8086 labmanual
Murali Krishna
 
Ad

Recently uploaded (20)

PPTX
Folding Off Hours in Gantt View in Odoo 18.2
Celine George
 
PPTX
How to Consolidate Subscription Billing in Odoo 18 Sales
Celine George
 
PDF
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
PPTX
Presentation: Climate Citizenship Digital Education
Karl Donert
 
PPTX
ANORECTAL MALFORMATIONS: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PPTX
ARAL Program of Adia Elementary School--
FatimaAdessaPanaliga
 
PPTX
GENERAL METHODS OF ISOLATION AND PURIFICATION OF MARINE__MPHARM.pptx
SHAHEEN SHABBIR
 
PDF
Right to Information.pdf by Sapna Maurya XI D
Directorate of Education Delhi
 
PPTX
Room booking management - Meeting Room In Odoo 17
Celine George
 
PPTX
10CLA Term 3 Week 4 Study Techniques.pptx
mansk2
 
PPTX
Accounting Skills Paper-I, Preparation of Vouchers
Dr. Sushil Bansode
 
PPTX
HIRSCHSPRUNG'S DISEASE(MEGACOLON): NURSING MANAGMENT.pptx
PRADEEP ABOTHU
 
PPTX
IDEAS AND EARLY STATES Social science pptx
NIRANJANASSURESH
 
PPTX
LEGAL ASPECTS OF PSYCHIATRUC NURSING.pptx
PoojaSen20
 
PPTX
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
PPTX
Top 10 AI Tools, Like ChatGPT. You Must Learn In 2025
Digilearnings
 
PDF
A guide to responding to Section C essay tasks for the VCE English Language E...
jpinnuck
 
PPTX
Various Psychological tests: challenges and contemporary trends in psychologi...
santoshmohalik1
 
PPTX
Maternal and Child Tracking system & RCH portal
Ms Usha Vadhel
 
PDF
Ziehl-Neelsen Stain: Principle, Procedu.
PRASHANT YADAV
 
Folding Off Hours in Gantt View in Odoo 18.2
Celine George
 
How to Consolidate Subscription Billing in Odoo 18 Sales
Celine George
 
Tips for Writing the Research Title with Examples
Thelma Villaflores
 
Presentation: Climate Citizenship Digital Education
Karl Donert
 
ANORECTAL MALFORMATIONS: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
ARAL Program of Adia Elementary School--
FatimaAdessaPanaliga
 
GENERAL METHODS OF ISOLATION AND PURIFICATION OF MARINE__MPHARM.pptx
SHAHEEN SHABBIR
 
Right to Information.pdf by Sapna Maurya XI D
Directorate of Education Delhi
 
Room booking management - Meeting Room In Odoo 17
Celine George
 
10CLA Term 3 Week 4 Study Techniques.pptx
mansk2
 
Accounting Skills Paper-I, Preparation of Vouchers
Dr. Sushil Bansode
 
HIRSCHSPRUNG'S DISEASE(MEGACOLON): NURSING MANAGMENT.pptx
PRADEEP ABOTHU
 
IDEAS AND EARLY STATES Social science pptx
NIRANJANASSURESH
 
LEGAL ASPECTS OF PSYCHIATRUC NURSING.pptx
PoojaSen20
 
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
Top 10 AI Tools, Like ChatGPT. You Must Learn In 2025
Digilearnings
 
A guide to responding to Section C essay tasks for the VCE English Language E...
jpinnuck
 
Various Psychological tests: challenges and contemporary trends in psychologi...
santoshmohalik1
 
Maternal and Child Tracking system & RCH portal
Ms Usha Vadhel
 
Ziehl-Neelsen Stain: Principle, Procedu.
PRASHANT YADAV
 
Ad

Introduction to ibm pc assembly language

  • 1. A solution manual to Assembly language Programming and the organization of the IBM PC Chapter 4 Introduction to IBM PC Assembly language BY:- Ytha Yu & Charles Marut prepared by : Warda Aziz [email protected]
  • 2. Question 1: Which of the following names are legal in IBM PC assembly language? Names Status TWO_WORDS Legal ?1 Legal Two words illegal .@? illegal $145 legal Let’s_go illegal T= illegal Question 2: Which of the following names are legal numbers? If they are legal , tell whether they are binary , decimal or hex? Numbers Status 246 decimal 246h hex 1001 decimal 1,101 illegal 2A3h hex FFFEh illegal 0Ah hex Bh illegal 1110B binary Question 3: 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 WORD1 uninitialized. c) A byte variable B initialized to 25h d) A byte variable C1, uninitialized e) A word variable WORD1, initialized to 65536 f) A word array ARRAY1, initialized to the first five positive integers g) A constant BELL equal to 07h h) a constant message equal to ‘THIS IS A MESSAGE$’ Solution: A word variable A initialized to 52 A DW 52 A word variable WORD1 uninitialized. WORD1 DW ? A byte variable B initialized to 25h B DB25h A byte variable C1, uninitialized C1 DB ? A word variable WORD1, initialized to 65536
  • 3. WORD1 DW 65536 A word array ARRAY1, initialized to the first five positive integers ARRAY1 DW 1,2,3,4,5 A constant BELL equal to 07h BELL EQU 07h A constant message equal to ‘THIS IS A MESSAGE$’ MSG EQU ‘THIS IS A MESSAGE$’ Question 4: Suppose that the following data are loaded starting at offset 0000h A DB 7 B DW 1ABCh 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 c. Give the contents of the byte at offset 0004h in hex d. Give the offset address of the character “O” in “HELLO” variable content Address A 7 0000 B BC 0001 1A 0002 C H 0003 E 0004 L 0005 L 0006 0 007 A) A: 0000 B: 0001 C: 0003 B) 1A C) E D)0007 Question 4: Tell whether each of the instructions is legal or illegal instruction status MOV DS,AX Legal MOV DS, 1000h Illegal ;can’t use seg register with an immediate value MOV CS,ES Illegal; seg registers cannot go together MOV W1, DS Legal XCHG W1,W2 Illegal SUB 5, B1 Illegal ADD B1,B2 illegal ADD AL, 256 illegal MOV W1,B1 Illegal Question 6: Using only MOV , ADD, SUB, INC, DEC and NEG , translate the following high level language assignment statements into assembly language A,B and C are word variables.
  • 4. A) A=B-A B) A=-(A+1) C) C=A+B D) B=3*B+7 E) A=B-A-1 A=B-A MOV AX, a MOV BX, b SUB BX,AX MOV AX,BX A=-(A+1) MOV AX,A ADD AX,1 NEG AX MOV A,AX C=A+B MOV AX,A ADD AX,B MOV C,AX B=3*B+7 MOV AX,B ADD AX,B ADD AX,B ADD AX,7 MOV B,AX A=B-A-1 MOV BX,B SUB BX,A SUB BX,1 MOV A, BX Question 7: Write instructions to do the following. A. Read a character and display it at the next position on the same line B. Read an uppercase letter and display it at the next position on the same line in lower case Read a character and display it at the next position on the same line mov ah,1 int 21h mov ah,2 mov dl,al int 21h Read an uppercase letter and display it at the next position on the same line in lower case mov ah,1 int 21h add al,20h mov ah,2 mov dl,al int 21h
  • 5. Question 8: Write a program to a) display a “?” b) read two decimal digits whose sum is less than 10 c)display them and their sum in the next line with an appropriate message. Code: .MODEL SMALL .STACK 100H .DATA MSG DB 0AH, 0DH, "The sum of " VAR DB ?, ' and ' var2 DB ? , ' is '; sum DB ?,"$" .CODE MAIN PROC ;DATA INITIALIZATION MOV AX, @DATA MOV DS, AX ; DISPLAY ? TO PROMPT THE USER FOR INPUT MOV AH, 2 MOV DL, '?' INT 21H ;READ DECIMAL DIGITS MOV AH, 1 INT 21H MOV VAR, AL ; storing var in another reg ;INPUT 2ND VARIABLE INT 21H ; storing VAR2 in AL MOV var2, AL ;ADDING VARIABLES ADD AL, VAR SUB AL, 30H ;there is ASCII coding in background so subtracting code 30h MOV SUM , AL ;DISPLAY MSG LEA DX, MSG MOV AH, 9 INT 21H ;DOS EXIT MOV AH, 4CH INT 21H MAIN ENDP END MAIN Output: Question 9: write a program to A) prompt the user B) Read first middle and last initials of a person’s name C) And display them down the left margin
  • 6. Ans: .MODEL SMALL .STACK 100H .DATA MSG DB 0AH, 0DH,, "Enter three initials:$" A DB ? b DB ? c DB ? .CODE MAIN PROC MOV AX, @DATA MOV DS, AX ;DISPLAYING LINES LEA DX, MSG MOV AH, 9 INT 21H ;TAKING INPUT MOV AH, 1 ;First input INT 21H MOV A, AL INT 21H ;Second input MOV B, AL INT 21H ;3rd input MOV C, AL ;LINE FEED MOV AH,2 MOV DL, 0AH INT 21H MOV DL, 0DH INT 21H ;display function MOV AH, 2 MOV DL, A INT 21H ;LINE FEED MOV AH,2 MOV DL, 0AH INT 21H MOV DL, 0DH INT 21H ;DISPLAY 2ND NUM MOV AH, 2 MOV DL, B INT 21H ;LINE FEED MOV AH,2 MOV DL, 0AH
  • 7. INT 21H MOV DL, 0DH INT 21H ;DISPLAY MOV AH, 2 MOV DL, C INT 21H ; DOS EXIT MOV AH, 4CH INT 21H MAIN ENDP END MAIN Output: Q 10: Write a program to read one of the hex digits A-F;and display it on the next line in decimal. Ans: .MODEL small .STACK 100h .DATA MSG DB 'enter a hex digit' C db ?, '$' MSG2 DB 0AH,0DH,"In decimal it is: 1" C2 db ?,'$' MAIN PROC MOV AX, @DATA MOV DS,AX ;Displaying first message MOV AH, 9 LEA DX, MSG INT 21H ;input MOV AH,1 INT 21H
  • 8. MOV C, AL ;CALCULATION SUB AL, 11H MOV C2,AL ;DISPLAY MOV AH,9 LEA DX, MSG2 INT 21H ;DOS EXIT MOV AH, 4CH INT 21H MAIN ENDP END MAIN Output: Question 11: write a program to display a 10*10 solid box of asterisk. Hint: declare a string in the data segment that specifies the box and display it with INT 21h function 9h. Ans: .MODEL SMALL .STACK 100H .DATA MSG DW 0AH,0DH,'**********$' .CODE MAIN PROC MOV AX, @DATA MOV DS, AX ;FUNCTION 9 FOR DISPLAYING OUTPUT STRING MOV AH,9 LEA DX ,MSG INT 21H ;OUTPUT FOR first line INT 21H ;output for second line INT 21H ; . INT 21H ; . INT 21H ; . INT 21H ; . INT 21H ; . INT 21H ; . INT 21H ; . INT 21H ; output for the 10th line ;DOS EXIT MOV AH, 4CH INT 21H MAIN ENDP END MAIN
  • 9. Output: Write a program to display a) ? b) Read three initials c) Display them in the middle of an 11*11 box of asterisk d) Beep the computer Ans: .STACK 100h .MODEL small .DATA msg DB "?$" msg1 DB 0Ah, 0Dh,"**********$" msg2 DB 0Ah, 0Dh,"***" ch1 DB ? ch2 DB ? ch3 DB ?,"****$" .CODE main PROC MOV AX, @DATA MOV DS, AX ;prompt the user for ? MOV AH,2 MOV DL, msg INT 21h ;enter initials MOV AH,1 int 21h MOV ch1, AL INT 21h MOV ch2, AL INT 21h MOV ch3, AL ; output MOV AH,9 lea DX, msg1 INT 21h INT 21h INT 21h INT 21h
  • 10. INT 21h INT 21h LEA DX, msg2 INT 21h LEA DX, msg1 INT 21h INT 21h INT 21h INT 21h INT 21h ;BEEP THE COUNTER MOV AH, 2 MOV DL, 7H INT 21H ;dos exit MOV AH, 4Ch INT 21h main ENDP END main Output