This document provides an overview of assembly language concepts including:
- Conditional loops like LOOPZ/LOOPE that check the zero flag
- New directives like .IF/.ELSEIF/.ELSE/.ENDIF for conditional execution
- Examples of finding the min/max of an array, grading student scores, and counting scores in different grades
- The .REPEAT/.UNTIL and .WHILE/.ENDW loops for repetitive execution
- Examples of reversing a string, finding the first non-zero value in an array, and understanding MOVSX/MOVZX
- An assignment is given to print a triangle of asterisks based on user input size
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...warda aziz
this pdf covers solution to chapter 8 and 9 of assembly language and organization of the IBM PC. if you find any mistakes in my writing , please disccuss with me.
Chapter 5The proessor status and the FLAGS registerswarda aziz
solution manual to COMPUTER ORGANIZATION AND ASSEMBLY LANGUAGE CHAPTER 5.
If you find any mistake in the manual please share with me ... it will be appreciated
chapter 7 Logic, shift and rotate instructionswarda aziz
this is a solution to exercise of chapter 7 from Assembly language programming and organization of the IBM PC.
If you find any mistakes in my solution , please discuss with me. as i am also a human and can do mistakes.
Chap 8 The stack and introduction to procedures & Chapter 9 multiplication an...warda aziz
this pdf covers solution to chapter 8 and 9 of assembly language and organization of the IBM PC. if you find any mistakes in my writing , please disccuss with me.
Chapter 5The proessor status and the FLAGS registerswarda aziz
solution manual to COMPUTER ORGANIZATION AND ASSEMBLY LANGUAGE CHAPTER 5.
If you find any mistake in the manual please share with me ... it will be appreciated
chapter 7 Logic, shift and rotate instructionswarda aziz
this is a solution to exercise of chapter 7 from Assembly language programming and organization of the IBM PC.
If you find any mistakes in my solution , please discuss with me. as i am also a human and can do mistakes.
Automata theory - describes to derives string from Context free grammar - derivation and parse tree
normal forms - Chomsky normal form and Griebah normal form
This presentation contains:
1. Language, Regular Language
2. DFA vs. NFA
3. Components of DFA
4. Acceptability checking
5. Group-wise designing different types of DFA machines
Automata theory - describes to derives string from Context free grammar - derivation and parse tree
normal forms - Chomsky normal form and Griebah normal form
This presentation contains:
1. Language, Regular Language
2. DFA vs. NFA
3. Components of DFA
4. Acceptability checking
5. Group-wise designing different types of DFA machines
An assembly (or assembler) language, often abbreviated asm, is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture's machine code instructions.
In this lecture we discuss more about programming in MATLAB. One main section in programming is flow control. There are many flow control commands in MATLAB. In this lecture we discuss the conditional flow control commands. Conditional statements are commands that allows MATLAB to decide whether or not to execute some code that follows the statement
Conditional statements use relational operators like ==,~=,>,< (Note that are all scalar tests)
Write an MASM program that meets the following requirements- Please us.pdfasarts99
Write an MASM program that meets the following requirements. Please use the starter code
posted below from another question. Currently the count array does not work.
; Description: Sorting and Counting Random Integers
INCLUDE Irvine32.inc
;global constants
ARRAYSIZE = 200
LO = 10
HI = 29
.data
intro BYTE "Sorting and Counting Random integers!",0
intro2 BYTE "Programmed by Pat Stumbaugh",0
intro3 BYTE "This program generates 200 random numbers in the range "
BYTE "[10 ... 29], displays the original list, sorts the list, "
BYTE "displays the median value, displays the list sorted in "
BYTE "ascending order, then displays the number of instances"
BYTE "of each generated value.",0
unsort BYTE "Your unsorted random numbers: ",0
sort BYTE "Your sorted random numbers:",0
medianIntro BYTE "List Median: ",0
instances BYTE "Your list of instances of each generated number, "
BYTE "starting with the number of 10s:",0
spaces BYTE " ",0
cList BYTE "Your list of instances of each generated number, "
BYTE "starting with the number of 10s:",0
goodbye BYTE "Goodbye, and thanks for using my program!",0
array DWORD 200 DUP(?)
countArray DWORD 200 DUP(?)
cArraySize DWORD 0
.code
main PROC
;introduce the program
push OFFSET intro
push OFFSET intro2
push OFFSET intro3
call introduction
;fill the array
push OFFSET array
push ARRAYSIZE
push HI
push LO
call fillArray
call CrLf
;display title of unsorted array
push OFFSET unsort
call displayTitle
call CrLf
;display the unsorted list
push OFFSET array
push ARRAYSIZE
push OFFSET spaces
call displayArray ;display array call #1
call CrLf
call CrLf
;sort our array
push OFFSET array
push ARRAYSIZE
call sortList
;display title of median
push OFFSET medianIntro
call displayTitle
;display median
push OFFSET array
push ARRAYSIZE
call displayMedian
call CrLf
call CrLf
;display title of sorted array
push OFFSET sort
call displayTitle
call CrLf
;display sorted list
push OFFSET array
push ARRAYSIZE
push OFFSET spaces
call displayArray ;display array call #2
call CrLf
;display title for count list
push OFFSET cList
call displayTitle
call CrLf
;count the items in list and store them in countArray
push OFFSET array
push OFFSET countArray
push ARRAYSIZE
push OFFSET cArraySize
call countList
;display the counted array
push OFFSET countArray
push cArraySize
push OFFSET spaces
call displayArray ;display array call #3
call CrLf
call CrLf
;display goodbye message
push OFFSET goodbye
call displayTitle
call CrLf
exit ; exit to operating system
main ENDP
;FUNCTIONS BELOW
;***************************************************************************
;introduces the program
;receives: addresses of intro, intro2 and intro3
;registers changed: ebp, edx
introduction PROC
push ebp
mov ebp, esp
mov edx, [ebp+16]
call WriteString
call CrLf
mov edx, [ebp+12]
call writeString
call CrLf
call CrLf
mov edx, [ebp+8]
call writeString
call CrLf
pop ebp
ret 12
introduction ENDP
;fills the array with random numbers, within a specified range
;receives: address of a.
This slide includes: Control Flow and Functions.
That is Boolean values and operators.
It include Iteration,Fruitful functions,Scope of Variable and Modules.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Macroeconomics- Movie Location
This will be used as part of your Personal Professional Portfolio once graded.
Objective:
Prepare a presentation or a paper using research, basic comparative analysis, data organization and application of economic information. You will make an informed assessment of an economic climate outside of the United States to accomplish an entertainment industry objective.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
8. LOOPZ / LOOPE Instructions
Loop if Zero / Loop if Equal.
They are like LOOP instruction except that they have one
additional condition:
The Zero flag must be set in order for control to transfer
to the destination label.
Loopz/Loope destination
9. They perform the following tasks:
Otherwise, no jump occurs, and control passes to the
next instruction
ECX = ECX - 1
if ECX > 0 and ZF = 1, jump to
destination
10. LOOPNZ / LOOPNE Instructions
Loop if Not Zero / Loop if Not Equal.
The Counterpart of LOOPZ and LOOPE.
The Zero flag must be Clear in order for control to
transfer to the destination label.
Loopnz/Loopne destination
11. They perform the following tasks:
Otherwise, no jump occurs, and control passes to the
next instruction
ECX = ECX - 1
if ECX > 0 and ZF = 0, jump to
destination
13. Min and Max in Array
Write an assembly program that finds the min and max
of an entered integer array.
14. arr_size equ 5
.data
arr DWORD arr_size DUP(0)
min DWORD 9fffffffh
max DWORD 0
strPrompt BYTE 'Enter array items:', 0
strMinMsg BYTE 'The min value = ', 0;a message
to be displayed to user
strMaxMsg BYTE 'The Max value = ', 0;a message
to be displayed to user
15. .code
main PROC
mov edx, offset strPrompt ;put the address of
strPrompt in edx
call WriteString;as a parameter to WriteString
MOV ESI, OFFSET arr
MOV ECX, arr_size
L1:
CALL ReadDec
MOV [ESI], EAX ;what saved frm ReadDec
ADD ESI, TYPE arr ;update esi
CMP EAX, min ;compare with min
JB updateMin ;update min if there is a new min
CMP EAX, max ;compare with max
JA updateMax ;update max if there is a new max
LOOP L1 ;this line will be hit ... when??
JMP next
16. updateMin:
MOV min, EAX ;update the min
Loop L1 ;continue loop if ECX > 0
JMP next ;GOTO the end if loop is done
updateMax:
MOV max, EAX ;update the max
Loop L1 ;continue loop if ECX > 0
JMP next ;GOTO the end if loop is done
17. next:
MOV EDX, OFFSET strMinMsg ;print the min msg
CALL WriteString
MOV EAX, min ;print the min
Call WriteDec
CALL CRLF
MOV EDX, OFFSET strMaxMsg ;print the max msg
CALL WriteString
MOV EAX, max
CALL WriteDec ;display the max
Call CRLF
exit
main ENDP
18. Student Grade
Write an assembly program that inputs a student’s score
and prints her/his grade. The student will be “Excellent”
if her/his score is between 90‐100, “Very Good” if the
score is between 80‐89, “Good” if the score is between
70‐79, “Fair” if the score is between 60‐69, and “Fail” if
the score is lower than 60. (Assume scores are integers.)
19. New Directives
This problem can be done using CMP && JMP, but here
we will introduce new directives to do the same
functionality
22. Student Grade
Write an assembly program that inputs a student’s score
and prints her/his grade. The student will be “Excellent”
if her/his score is between 90‐100, “Very Good” if the
score is between 80‐89, “Good” if the score is between
70‐79, “Fair” if the score is between 60‐69, and “Fail” if
the score is lower than 60. (Assume scores are integers.)
26. Grades Counter
Write an assembly program that accepts multiple
students’ scores, and then prints number of students in
each grade. Grades and their score ranges are defined in
the previous exercise. The program should also print an
error message if the entered score is less than 0 or
greater than 100.
27. scores_cnt equ 5
.data
prompt byte "Enter 5 scores: ",0
promptA byte "Studens Have Excellent ",0
CntA DWORD 0
promptB byte "Students Have Very Good ",0
CntB DWORD 0
promptC byte "Students Have Good ",0
CntC DWORD 0
promptD byte "Students Have Fair ",0
CntD DWORD 0
promptF byte "Students Have Fail ",0
CntF DWORD 0
promptE byte "Error!!",0
32. What If the Problem …
takes a student score, prints its grade then asks user if
s/he wants to enter another score
Repeat OR While
33. .REPEAT & .WHILE
The .REPEAT directive executes the loop body before
testing the runtime condition following the .UNTIL
directive. However, the .WHILE directive tests the
condition before executing the body loop
.REPEAT
Statements
.UNTIL cond
.WHILE cond
Statements
.ENDW
Do then
check
Check
then
DO
34. .data
prompt byte "Enter a student score: ",0
;print the output msg
promptA byte "Excellent",0
promptB byte "Very Good",0
promptC byte "Good",0
promptD byte "Fair",0
promptF byte "Fail",0
promptE byte "Error!!",0
stragain byte "Do you want to enter another
score (Y/N)? ",0
38. .code
main PROC
mov ecx, SIZEOF original
mov esi, 0 ;index for original string
mov edi, ecx ;index for reversed string
dec edi ;because array is zero indexed
dec edi ;skip the null termination char
L:
mov al, original[edi]
mov reversed[esi], al
inc esi ;slide to next character
dec edi
loop L
mov reversed[esi], 0 ;null-terminate the
reversed string
mov edx, offset reversed
call writestring
call crlf
39. Find the Non Zero …
Write an Assembly program that looks for the first
nonzero value in an array of 16-bit integers.
If it finds one, it displays the value; otherwise, it displays
a message stating that a nonzero value was not found.
0, 0, 0, 0, -1, 20, 35, -12, 66, 4, 0
Test
Case
40. intArray SWORD 0, 0, 0, 0, -1, 20, 35, -12, 66,
4, 0
noneMsg BYTE "A non-zero value was not found", 0
41. mov ebx, OFFSET intArray ;point to the array
mov ecx, LENGTHOF intArray ;loop counter
L1:
cmp WORD PTR [ebx], 0 ;compare value to zero
jnz found ;found a value
add ebx, TYPE intArray ;point to next
loop L1 ;continue the loop
jmp notFound ;none found
found: ;display the value
movsx eax, WORD PTR[ebx] ;sign-extend into EAX
call WriteInt
jmp quit
notFound: ;display "not found" message
mov edx, OFFSET noneMsg
call WriteString
quit:
call Crlf
exit
42. mov ebx, OFFSET intArray ;point to the array
mov ecx, LENGTHOF intArray ;loop counter
L1:
cmp WORD PTR [ebx], 0 ;compare value to zero
jnz found ;found a value
add ebx, TYPE intArray ;point to next
loop L1 ;continue the loop
jmp notFound ;none found
found: ;display the value
movsx eax, WORD PTR[ebx] ;sign-extend into EAX
call WriteInt
jmp quit
notFound: ;display "not found" message
mov edx, OFFSET noneMsg
call WriteString
quit:
call Crlf
exit
43. MOVSX VS.MOVZX Real Example
The output will be -1
movsx eax, WORD PTR[ebx] ;sign-extend into EAX
call WriteInt
movzx eax, WORD PTR[ebx] ;zero-extend into EAX
call WriteInt
The output will be +65535 EAX = 0000FFFF
EAX = FFFFFFFF
44. MOVSX VS.MOVZX Real Example
The output will be 65535
movsx eax, WORD PTR[ebx] ;sign-extend into EAX
call WriteDec
movzx eax, WORD PTR[ebx] ;zero-extend into EAX
call WriteDec
The output will be 4294967295
EAX = 0000FFFF
EAX = FFFFFFFF
46. Triangle of *
Write an assembly program that reads the size of a right
triangle and then prints it by asterisks. For example, if
your program reads a size of 5, it should print:
*
**
***
****
*****
Hint: WriteChar is an Irvine function that prints a single
character. This character must be stored in AL register.
47. Two Largest…
Write an assembly program that takes 10 integers and
finds the two largest values among input integers
PTR is an operator that overrides the size of an operand. It is always preceded by a Type (BYTE, WORD, DWORD…etc). In the instruction add eax, DWORD PTR [esi], you can remove DWORD PTR as the assembler will assume a default size equals to the size of the second operand which in this case DWORD. If ax is used instead of eax, WORD size will be assumed and so on.
Writeint function is a function defined in Irvine library. It prints a signed integer stored in EAX on the screen.
LENGTHOF operator retrieves the length of an array. For example, the instruction mov ECX, LENGTHOF Arr1 gets the length of Arr1 array and stores it in ECX.
TYPE operator retrieves the number of bytes allocated for each item in the given array. For example, the instruction add esi, TYPE Arr1 adds 4 to esi if Arr1 is DWORD array, adds 2 if Arr1 is WORD array and adds 1 if Arr1 is BYTE array
ReadInt function is a function defined in Irvine library. It reads a 32‐bit signed decimal integer from the user and stores it in EAX Register, stopping when the Enter key is pressed, leading spaces are ignored, and an optional leading + or ‐ sign is permitted. ReadInt will display an error message, set the Overflow flag, and reset EAX to zero if the value entered cannot be represented as a 32‐bit signed integer. If you need to store the entered value in a variable, you need to move it from EAX to this variable.
ReadDec is the same for Unsigned
.IF eax > -1 statement is translated into JBE instruction assuming unsigned
numbers. However, .IF eax > int1 is translated into JLE instruction
assuming signed numbers because int1 is defined as SDWORD.
The idea is in parsing the value stored in EAX based on what you call either WriteInt or WriteDec
In case of WriteInt – It parse the value that it’s a signed value or in other words the output must have + or – sign leading
1.It know the SIGN from the last (MSB) bit
2.it reads the remaining value and prints it as it understood
In case of WriteDec – It assume that the value is an UNSIGNED value
1.No signs appears here
2.It parsed the whole value as it is