SlideShare a Scribd company logo
1 of 10
Download to read offline
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

Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Bilal Amjad
 
Assembly language (coal)
Assembly language (coal)Assembly language (coal)
Assembly language (coal)Hareem Aslam
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Bilal Amjad
 
Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Bilal Amjad
 
Flag Registers (Assembly Language)
Flag Registers (Assembly Language)Flag Registers (Assembly Language)
Flag Registers (Assembly Language)Anwar Hasan Shuvo
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Bilal Amjad
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Bilal Amjad
 
Solution manual of assembly language programming and organization of the ibm ...
Solution manual of assembly language programming and organization of the ibm ...Solution manual of assembly language programming and organization of the ibm ...
Solution manual of assembly language programming and organization of the ibm ...Tayeen Ahmed
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086Mahalakshmiv11
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-pptjemimajerome
 
Addressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu JoyAddressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu JoyBinu Joy
 
Pipeline hazard
Pipeline hazardPipeline hazard
Pipeline hazardAJAL A J
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Bilal Amjad
 
Ascii adjust & decimal adjust
Ascii adjust & decimal adjustAscii adjust & decimal adjust
Ascii adjust & decimal adjustTech_MX
 

What's hot (20)

Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
 
Assignment on alp
Assignment on alpAssignment on alp
Assignment on alp
 
Assembly language (coal)
Assembly language (coal)Assembly language (coal)
Assembly language (coal)
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 7 (Logic, Shift,...
 
Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)Binary and hex input/output (in 8086 assembuly langyage)
Binary and hex input/output (in 8086 assembuly langyage)
 
Flag Registers (Assembly Language)
Flag Registers (Assembly Language)Flag Registers (Assembly Language)
Flag Registers (Assembly Language)
 
Assembly 8086
Assembly 8086Assembly 8086
Assembly 8086
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
 
Solution manual of assembly language programming and organization of the ibm ...
Solution manual of assembly language programming and organization of the ibm ...Solution manual of assembly language programming and organization of the ibm ...
Solution manual of assembly language programming and organization of the ibm ...
 
Instruction sets of 8086
Instruction sets of 8086Instruction sets of 8086
Instruction sets of 8086
 
8086-instruction-set-ppt
 8086-instruction-set-ppt 8086-instruction-set-ppt
8086-instruction-set-ppt
 
Instruction set of 8086
Instruction set of 8086Instruction set of 8086
Instruction set of 8086
 
Addressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu JoyAddressing modes of 8086 - Binu Joy
Addressing modes of 8086 - Binu Joy
 
Pipeline hazard
Pipeline hazardPipeline hazard
Pipeline hazard
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
 
Ascii adjust & decimal adjust
Ascii adjust & decimal adjustAscii adjust & decimal adjust
Ascii adjust & decimal adjust
 

Similar to Introduction to ibm pc assembly language

Home works summary.pptx
Home works summary.pptxHome works summary.pptx
Home works summary.pptxHebaEng
 
Assembly language programs 2
Assembly language programs 2Assembly language programs 2
Assembly language programs 2HarshitParkar6677
 
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdfaromanets
 
Code Conversion in 8085 Microprocessor
Code Conversion in 8085 MicroprocessorCode Conversion in 8085 Microprocessor
Code Conversion in 8085 MicroprocessorMOHIT AGARWAL
 
Microprocessor and micro-controller lab (assembly programming)
Microprocessor and micro-controller lab (assembly programming)Microprocessor and micro-controller lab (assembly programming)
Microprocessor and micro-controller lab (assembly programming)shamim hossain
 
Keyboard interrupt
Keyboard interruptKeyboard interrupt
Keyboard interruptTech_MX
 
Genius it ians™ 8085 programming (part 2)
Genius it ians™  8085 programming (part 2)Genius it ians™  8085 programming (part 2)
Genius it ians™ 8085 programming (part 2)Manoj Shahu
 
Assembly language solution
Assembly language  solutionAssembly language  solution
Assembly language solutionAhsan Riaz
 
Microprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannualMicroprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannualyeshwant gadave
 
Taller practico emu8086_galarraga
Taller practico emu8086_galarragaTaller practico emu8086_galarraga
Taller practico emu8086_galarragaFabricio Galárraga
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language BasicsEducation Front
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answersdebarghyamukherjee60
 

Similar to Introduction to ibm pc assembly language (20)

Home works summary.pptx
Home works summary.pptxHome works summary.pptx
Home works summary.pptx
 
Assembly language programs 2
Assembly language programs 2Assembly language programs 2
Assembly language programs 2
 
Lab report assembly
Lab report assemblyLab report assembly
Lab report assembly
 
Assembly language programs
Assembly language programsAssembly language programs
Assembly language programs
 
Mcs 17 solved assignment 2015- 16
Mcs 17 solved assignment 2015- 16Mcs 17 solved assignment 2015- 16
Mcs 17 solved assignment 2015- 16
 
Exp 03
Exp 03Exp 03
Exp 03
 
Emulador emu8086
Emulador emu8086Emulador emu8086
Emulador emu8086
 
جميع اوامر لغة الاسمبلي
جميع اوامر لغة الاسمبلي جميع اوامر لغة الاسمبلي
جميع اوامر لغة الاسمبلي
 
Compiladores emu8086
Compiladores emu8086Compiladores emu8086
Compiladores emu8086
 
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf
1) (a) Write a code fragment which adds the 32-bit contents of $8100.pdf
 
Code Conversion in 8085 Microprocessor
Code Conversion in 8085 MicroprocessorCode Conversion in 8085 Microprocessor
Code Conversion in 8085 Microprocessor
 
Microprocessor and micro-controller lab (assembly programming)
Microprocessor and micro-controller lab (assembly programming)Microprocessor and micro-controller lab (assembly programming)
Microprocessor and micro-controller lab (assembly programming)
 
Keyboard interrupt
Keyboard interruptKeyboard interrupt
Keyboard interrupt
 
Genius it ians™ 8085 programming (part 2)
Genius it ians™  8085 programming (part 2)Genius it ians™  8085 programming (part 2)
Genius it ians™ 8085 programming (part 2)
 
Assembly language solution
Assembly language  solutionAssembly language  solution
Assembly language solution
 
Microprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannualMicroprocessor 8086-lab-mannual
Microprocessor 8086-lab-mannual
 
Taller practico emu8086_galarraga
Taller practico emu8086_galarragaTaller practico emu8086_galarraga
Taller practico emu8086_galarraga
 
Assembly Language Basics
Assembly Language BasicsAssembly Language Basics
Assembly Language Basics
 
Bcsl 022 solved-assignment_2012-13
Bcsl 022 solved-assignment_2012-13Bcsl 022 solved-assignment_2012-13
Bcsl 022 solved-assignment_2012-13
 
Class 12 computer sample paper with answers
Class 12 computer sample paper with answersClass 12 computer sample paper with answers
Class 12 computer sample paper with answers
 

Recently uploaded

How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designMIPLM
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfphamnguyenenglishnb
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatYousafMalik24
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Mark Reed
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for BeginnersSabitha Banu
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 

Recently uploaded (20)

How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Keynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-designKeynote by Prof. Wurzer at Nordex about IP-design
Keynote by Prof. Wurzer at Nordex about IP-design
 
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdfAMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
AMERICAN LANGUAGE HUB_Level2_Student'sBook_Answerkey.pdf
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
Earth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice greatEarth Day Presentation wow hello nice great
Earth Day Presentation wow hello nice great
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)Influencing policy (training slides from Fast Track Impact)
Influencing policy (training slides from Fast Track Impact)
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Full Stack Web Development Course for Beginners
Full Stack Web Development Course  for BeginnersFull Stack Web Development Course  for Beginners
Full Stack Web Development Course for Beginners
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"Rapple "Scholarly Communications and the Sustainable Development Goals"
Rapple "Scholarly Communications and the Sustainable Development Goals"
 

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 Wardaaziz555@gmail.com
  • 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