SlideShare a Scribd company logo
6
Most read
7
Most read
10
Most read
A solution manual to
Assembly language
Programming
and the organization of
the IBM PC
Chapter 8
The Stack and introduction to Procedures
Chapter 9
Multiplication and Division instructions
BY:- Ytha Yu & Charles Marut
prepared by :
Warda Aziz
Wardaaziz555@gmail.com
Chapter 8
The stack and
introduction to
procedures
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication and division intrsuctions
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication and division intrsuctions
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication and division intrsuctions
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication and division intrsuctions
Question 5:
Suppose SP= 0200h, TOP of stack= 012Ah. What are the contents
of IP , SP
A) after RET is executed, when RET appears in a NEAR
procedure?
B) After RET 4 is executed, where RET appears in a NEAR
procedure?
Answer:
Question 6:
Write some code to
A) place the TOP of the stack into AX, without changing the
stack contents
B) Place the word that is below the stack TOP into CX, without
changing the stack contents.
C) Exchange the TOP two words on the stack. You may use AX,
BX
Question 7:
Procedures are supposed to return the stack to the calling
program in the same condition that they received it. However it
may be useful to have procedures that alter the stack. For
example suppose we would like to write a NEAR procedure
SAVE_REGS that saves BX, CX, DX, SI, DI, BP, DS and ES on
the stack. Now unfortunately , SAVE_REGS can’t return to the
calling program because the return address is not at the TOP of
the stack.
A) devise a way to implement a procedure SAVE_REGS that
gets around this problem(you may use AX to do this)
B) Write a procedure RESTORE_REGS that restores the
registers that SAVE_REGS has saved.
Answer:
Chapter 9
Multiplication and division
instructions
Question 1:
If it is a legal instruction, give the value of DX , AX, and CF/OF
after each of the following instruction is executed.
A) MUL BX, if AX contains 0008h and BX contains 0003h.
B) MUL BX, if AX contains 00FFh and BX contains 1000h.
C) IMUL CX, if AX contains 0005h and CX contains FFFF h.
D) IMUL WORD1, if AX contains 8000h and WORD1 contains
FFFF h.
E) MUL 10h, if AX contains FFE0h.
Solution:
DX AX CF/OF
A 0000 0018 0
B 000F F000 1
C FFFF FFFB 0
D 0000 8000 1
E Illegal statement!!!
Question 2:
Give the new values of AX and CF/OF for each of the following
instructions.
A) MUL BL, if AL contains ABh, and BL contains 10h
B) IMUL BL, if AL contains ABh and BL contains 10h
C) MUL AH, if AX contains 01ABh
D) IMUL BYTE1, if AL contains 02h and byte 1 contains FBh
AX CF/OF
A 0AB0 1
B FAB0 1
C 00AB 0
D FFF6 0
Question 3:
Give the new values of AX and DX for each of the following
instructions. Or tell if overflow occurs.
A)DIV BX, if DX contains 0000h, AX contains 0007h and Bx contains
0002h
B)DIV BX, if DX contains 0000h AX contains FFFEh and BX
contains 0010h
C)IDIV BX , if DX contains FFFFh AX contains FFFCh and BX
contains 0003h
D)DIV BX, if DX contains FFFFh AX contains FFFCh and BX
contains 0003h
AX DX OVERFLOW
A 0003 0001 0
B 0FFF 000E 0
C FFFF FFFF 0
D Divide overflow occur!!!
Question 4:
Give the new values of AL and AH for each of the following
instructions. Or tell if overflow occurs.
A) DIV BL, if AX contains 000Dh, BL contains 03h
B) IDIV BL, if AX contains FFFBh, BL contains FEh
C) DIV BL, if AX contains 00FEh, BL contains 10h
D) DIV BL, if AX contains FFE0h, BL contains 02h
AH AL OF
A 01 04 0
B FF 02 0
C 0B FE 0
D Divide overflow occour!!!
Question 5:
Give the values of DX after executing CWD if AX contains
A) 7E02h
B) 8ABCh
C) 1ABCh
Input Output
7E02 0000
8ABC FFFF
1ABC 0000
Question 6:
Give the values of AX after executing CBW if AL contains
a) F0h
b) 5Fh
c) 80h
Input Output
F0h FFF0
5Fh 005F
80h FF80
Question 7:
Write assembly code for each of the following high level language
assignment statements. Suppose that A,B and C are word variables
and all products will fit in 16 bits. Use IMUL for multiplication. Its
not necessary to preserve the contents of variables A,B and C.
A. A=5*A-7
B. B=(A-B)*(B+10)
C. A=6-9*A
D. IF A2
+ B2
=C2
THEN
Set CF
ELSE
Clear CF
END_IF
Solution:
d

More Related Content

What's hot (20)

PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Bilal Amjad
 
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 7 (Logic, Shift,...
Bilal Amjad
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 8 (The Stack and...
Bilal Amjad
 
PPTX
Multiplication & division instructions microprocessor 8086
University of Gujrat, Pakistan
 
PDF
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Bilal Amjad
 
PDF
Solution manual of assembly language programming and organization of the ibm ...
Tayeen Ahmed
 
PPTX
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
Bilal Amjad
 
PPTX
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
PPTX
Flag Registers (Assembly Language)
Anwar Hasan Shuvo
 
PDF
Assembly language (coal)
Hareem Aslam
 
PPTX
Microprocessor 8086 instruction description
Dheeraj Suri
 
PDF
8086 instructions
Ravi Anand
 
PPTX
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
PPTX
8086 Interrupts & With DOS and BIOS by vijay
Vijay Kumar
 
PPTX
Assembly 8086
Mustafa Salah
 
PPT
Assembly language programming_fundamentals 8086
Shehrevar Davierwala
 
PPTX
Minimum Modes and Maximum Modes of 8086 Microprocessor
Nikhil Kumar
 
PPTX
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 6 (Flow Control ...
Bilal Amjad
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 5 (The Processor...
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 8 (The Stack and...
Bilal Amjad
 
Multiplication & division instructions microprocessor 8086
University of Gujrat, Pakistan
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 10 ( Arrays and ...
Bilal Amjad
 
Solution manual of assembly language programming and organization of the ibm ...
Tayeen Ahmed
 
assembly language programming organization of IBM PC chapter 9 part-1(MULTIPL...
Bilal Amjad
 
Binary and hex input/output (in 8086 assembuly langyage)
Bilal Amjad
 
Flag Registers (Assembly Language)
Anwar Hasan Shuvo
 
Assembly language (coal)
Hareem Aslam
 
Microprocessor 8086 instruction description
Dheeraj Suri
 
8086 instructions
Ravi Anand
 
Assembly Language Programming By Ytha Yu, Charles Marut Chap 4 (Introduction ...
Bilal Amjad
 
8086 Interrupts & With DOS and BIOS by vijay
Vijay Kumar
 
Assembly 8086
Mustafa Salah
 
Assembly language programming_fundamentals 8086
Shehrevar Davierwala
 
Minimum Modes and Maximum Modes of 8086 Microprocessor
Nikhil Kumar
 
assembly language programming organization of IBM PC chapter 9 part-2(decimal...
Bilal Amjad
 

Similar to Chap 8 The stack and introduction to procedures & Chapter 9 multiplication and division intrsuctions (20)

PPTX
8086 Instruction set
karthiga selvaraju
 
PDF
Topic 6 - Programming in Assembly Language_230517_115118.pdf
ezaldeen2013
 
PDF
Assembly language 8086 intermediate
John Cutajar
 
PPT
8086 instruction set
mengistu ketema
 
PPT
8086-instruction-set-ppt
jemimajerome
 
PDF
Assembly language 8086
John Cutajar
 
PPT
instruction-set-of-8086-mr-binu-joy3.ppt
ssuser2b759d
 
PPTX
[ASM]Lab7
Nora Youssef
 
DOCX
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
COMSATS Abbottabad
 
PPT
8085 instruction set and Programming
pooja saini
 
PPT
Unit 2 8086 Instruction set.ppt notes good
SahilSingh866567
 
PDF
Assembly Complete 8086 Instruction Set
Darian Pruitt
 
PPTX
Computer Science 33 - Week 02 - Discussion 2.pptx
yp6458
 
PPT
INTRUCTION SET OF 8086 FOR MICROPROCESSOR
MikkiliSuresh
 
PPTX
Arithmetic instructions
Robert Almazan
 
PPT
How Assembly works, and Logics made in Assembly language
akkhanyar
 
PPT
Microprocssor
riyadh8
 
PPT
Stack and subroutine
Ashim Saha
 
8086 Instruction set
karthiga selvaraju
 
Topic 6 - Programming in Assembly Language_230517_115118.pdf
ezaldeen2013
 
Assembly language 8086 intermediate
John Cutajar
 
8086 instruction set
mengistu ketema
 
8086-instruction-set-ppt
jemimajerome
 
Assembly language 8086
John Cutajar
 
instruction-set-of-8086-mr-binu-joy3.ppt
ssuser2b759d
 
[ASM]Lab7
Nora Youssef
 
IMPLEMENTING ARITHMETIC INSTRUCTIONS IN EMU 8086
COMSATS Abbottabad
 
8085 instruction set and Programming
pooja saini
 
Unit 2 8086 Instruction set.ppt notes good
SahilSingh866567
 
Assembly Complete 8086 Instruction Set
Darian Pruitt
 
Computer Science 33 - Week 02 - Discussion 2.pptx
yp6458
 
INTRUCTION SET OF 8086 FOR MICROPROCESSOR
MikkiliSuresh
 
Arithmetic instructions
Robert Almazan
 
How Assembly works, and Logics made in Assembly language
akkhanyar
 
Microprocssor
riyadh8
 
Stack and subroutine
Ashim Saha
 
Ad

Recently uploaded (20)

PDF
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego López-de-Ipiña González-de-Artaza
 
PPTX
CST413 KTU S7 CSE Machine Learning Introduction Parameter Estimation MLE MAP ...
resming1
 
PPTX
Functions in Python Programming Language
BeulahS2
 
PPTX
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
 
PDF
01-introduction to the ProcessDesign.pdf
StiveBrack
 
PPSX
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
PDF
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
PPTX
Computer network Computer network Computer network Computer network
Shrikant317689
 
PPTX
CST413 KTU S7 CSE Machine Learning Clustering K Means Hierarchical Agglomerat...
resming1
 
PDF
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 
PPTX
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
moonsony54
 
PPT
SF 9_Unit 1.ppt software engineering ppt
AmarrKannthh
 
PDF
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
 
PPTX
Introduction to File Transfer Protocol with commands in FTP
BeulahS2
 
PDF
June 2025 Top 10 Sites -Electrical and Electronics Engineering: An Internatio...
elelijjournal653
 
PDF
Rapid Prototyping for XR: Lecture 2 - Low Fidelity Prototyping.
Mark Billinghurst
 
PPTX
Mobile database systems 20254545645.pptx
herosh1968
 
PDF
تقرير عن التحليل الديناميكي لتدفق الهواء حول جناح.pdf
محمد قصص فتوتة
 
PDF
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
PDF
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
Validating a Citizen Observatories enabling Platform by completing a Citizen ...
Diego López-de-Ipiña González-de-Artaza
 
CST413 KTU S7 CSE Machine Learning Introduction Parameter Estimation MLE MAP ...
resming1
 
Functions in Python Programming Language
BeulahS2
 
CST413 KTU S7 CSE Machine Learning Neural Networks and Support Vector Machine...
resming1
 
01-introduction to the ProcessDesign.pdf
StiveBrack
 
OOPS Concepts in Python and Exception Handling
Dr. A. B. Shinde
 
lesson4-occupationalsafetyandhealthohsstandards-240812020130-1a7246d0.pdf
arvingallosa3
 
Computer network Computer network Computer network Computer network
Shrikant317689
 
CST413 KTU S7 CSE Machine Learning Clustering K Means Hierarchical Agglomerat...
resming1
 
Python Mini Project: Command-Line Quiz Game for School/College Students
MPREETHI7
 
Tesla-Stock-Analysis-and-Forecast.pptx (1).pptx
moonsony54
 
SF 9_Unit 1.ppt software engineering ppt
AmarrKannthh
 
Rapid Prototyping for XR: Lecture 5 - Cross Platform Development
Mark Billinghurst
 
Introduction to File Transfer Protocol with commands in FTP
BeulahS2
 
June 2025 Top 10 Sites -Electrical and Electronics Engineering: An Internatio...
elelijjournal653
 
Rapid Prototyping for XR: Lecture 2 - Low Fidelity Prototyping.
Mark Billinghurst
 
Mobile database systems 20254545645.pptx
herosh1968
 
تقرير عن التحليل الديناميكي لتدفق الهواء حول جناح.pdf
محمد قصص فتوتة
 
Rapid Prototyping for XR: Lecture 6 - AI for Prototyping and Research Directi...
Mark Billinghurst
 
輪読会資料_Miipher and Miipher2 .
NABLAS株式会社
 
Ad

Chap 8 The stack and introduction to procedures & Chapter 9 multiplication and division intrsuctions

  • 1. A solution manual to Assembly language Programming and the organization of the IBM PC Chapter 8 The Stack and introduction to Procedures Chapter 9 Multiplication and Division instructions BY:- Ytha Yu & Charles Marut prepared by : Warda Aziz [email protected]
  • 2. Chapter 8 The stack and introduction to procedures
  • 7. Question 5: Suppose SP= 0200h, TOP of stack= 012Ah. What are the contents of IP , SP A) after RET is executed, when RET appears in a NEAR procedure? B) After RET 4 is executed, where RET appears in a NEAR procedure? Answer: Question 6: Write some code to A) place the TOP of the stack into AX, without changing the stack contents B) Place the word that is below the stack TOP into CX, without changing the stack contents. C) Exchange the TOP two words on the stack. You may use AX, BX
  • 8. Question 7: Procedures are supposed to return the stack to the calling program in the same condition that they received it. However it may be useful to have procedures that alter the stack. For example suppose we would like to write a NEAR procedure SAVE_REGS that saves BX, CX, DX, SI, DI, BP, DS and ES on the stack. Now unfortunately , SAVE_REGS can’t return to the calling program because the return address is not at the TOP of the stack. A) devise a way to implement a procedure SAVE_REGS that gets around this problem(you may use AX to do this) B) Write a procedure RESTORE_REGS that restores the registers that SAVE_REGS has saved. Answer:
  • 9. Chapter 9 Multiplication and division instructions
  • 10. Question 1: If it is a legal instruction, give the value of DX , AX, and CF/OF after each of the following instruction is executed. A) MUL BX, if AX contains 0008h and BX contains 0003h. B) MUL BX, if AX contains 00FFh and BX contains 1000h. C) IMUL CX, if AX contains 0005h and CX contains FFFF h. D) IMUL WORD1, if AX contains 8000h and WORD1 contains FFFF h. E) MUL 10h, if AX contains FFE0h. Solution: DX AX CF/OF A 0000 0018 0 B 000F F000 1 C FFFF FFFB 0 D 0000 8000 1 E Illegal statement!!! Question 2: Give the new values of AX and CF/OF for each of the following instructions. A) MUL BL, if AL contains ABh, and BL contains 10h B) IMUL BL, if AL contains ABh and BL contains 10h C) MUL AH, if AX contains 01ABh D) IMUL BYTE1, if AL contains 02h and byte 1 contains FBh AX CF/OF A 0AB0 1 B FAB0 1 C 00AB 0 D FFF6 0 Question 3: Give the new values of AX and DX for each of the following instructions. Or tell if overflow occurs. A)DIV BX, if DX contains 0000h, AX contains 0007h and Bx contains 0002h B)DIV BX, if DX contains 0000h AX contains FFFEh and BX contains 0010h C)IDIV BX , if DX contains FFFFh AX contains FFFCh and BX contains 0003h
  • 11. D)DIV BX, if DX contains FFFFh AX contains FFFCh and BX contains 0003h AX DX OVERFLOW A 0003 0001 0 B 0FFF 000E 0 C FFFF FFFF 0 D Divide overflow occur!!! Question 4: Give the new values of AL and AH for each of the following instructions. Or tell if overflow occurs. A) DIV BL, if AX contains 000Dh, BL contains 03h B) IDIV BL, if AX contains FFFBh, BL contains FEh C) DIV BL, if AX contains 00FEh, BL contains 10h D) DIV BL, if AX contains FFE0h, BL contains 02h AH AL OF A 01 04 0 B FF 02 0 C 0B FE 0 D Divide overflow occour!!! Question 5: Give the values of DX after executing CWD if AX contains A) 7E02h B) 8ABCh C) 1ABCh Input Output 7E02 0000 8ABC FFFF 1ABC 0000 Question 6: Give the values of AX after executing CBW if AL contains a) F0h b) 5Fh c) 80h Input Output F0h FFF0 5Fh 005F 80h FF80 Question 7:
  • 12. Write assembly code for each of the following high level language assignment statements. Suppose that A,B and C are word variables and all products will fit in 16 bits. Use IMUL for multiplication. Its not necessary to preserve the contents of variables A,B and C. A. A=5*A-7 B. B=(A-B)*(B+10) C. A=6-9*A D. IF A2 + B2 =C2 THEN Set CF ELSE Clear CF END_IF Solution:
  • 13. d