Advance procedures in assembly are fully explained by me and my group mates.
Main topics are:
*Stack frames
-Recursion
-ADDR, INVOKE , LOCAL, PROC , PROTO directives and variables
-MultiModule Programs in assembly
A different approach to learn assembly language programming for microprocessors. Please download the presentation as it contains lots of animations which are not supported by the slideshare slide show.
This presentation covers very basics of assembly language with some computer organization concept. I took this session as part of on going series on assembly at NULL Hyderabad meets. PART II will cover instruction sets and more in detail.
Advance procedures in assembly are fully explained by me and my group mates.
Main topics are:
*Stack frames
-Recursion
-ADDR, INVOKE , LOCAL, PROC , PROTO directives and variables
-MultiModule Programs in assembly
A different approach to learn assembly language programming for microprocessors. Please download the presentation as it contains lots of animations which are not supported by the slideshare slide show.
This presentation covers very basics of assembly language with some computer organization concept. I took this session as part of on going series on assembly at NULL Hyderabad meets. PART II will cover instruction sets and more in detail.
A microprocessor is an electronic component that is used by a computer to do its work. It is a central processing unit on a single integrated circuit chip containing millions of very small components including transistors, resistors, and diodes that work together.
A microprocessor is an electronic component that is used by a computer to do its work. It is a central processing unit on a single integrated circuit chip containing millions of very small components including transistors, resistors, and diodes that work together.
Describe the three main addressing modes of the PIC16 architecture di.pdfSALES97
Describe the three main addressing modes of the PIC16 architecture discussed in class. For each
of the modes include two examples. Write a PIC16 assembly program which will accomplish the
following instruction. I just want the section of assembly code which accomplishes this. Make
VAR1 =0x22. VAR1 = 0x42 + (0xF0 AND 0xAA) - (0x12 OR 0x34) Perform the above
calculation by hand, showing all your work in binary.
Solution
2 ans
)
The term addressing modes refers to the way in which the operand of an instruction is specified.
Information contained in the instruction code is the value of the operand or the address of the
result/operand. Following are the main addressing modes that are used on various platforms and
architectures.
1) Immediate Mode
The operand is an immediate value is stored explicitly in the instruction:
Example: SPIM ( opcode dest, source)
li $11, 3 // loads the immediate value of 3 into register $11
li $9, 8 // loads the immediate value of 8 into register $9
Example : (textbook uses instructions type like, opcode source, dest)
move #200, R0; // move immediate value 200 in register R0
2) Index Mode
The address of the operand is obtained by adding to the contents of the general register (called
index register) a constant value. The number of the index register and the constant value are
included in the instruction code. Index Mode is used to access an array whose elements are in
successive memory locations. The content of the instruction code, represents the starting address
of the array and the value of the index register, and the index value of the current element. By
incrementing or decrementing index register different element of the array can be accessed.
Example: SPIM/SAL - Accessing Arrays
3) Indirect Mode
The effective address of the operand is the contents of a register or main memory location,
location whose address appears in the instruction. Indirection is noted by placing the name of the
register or the memory address given in the instruction in parentheses. The register or memory
location that contains the address of the operand is a pointer. When an execution takes place in
such mode, instruction may be told to go to a specific address. Once it\'s there, instead of finding
an operand, it finds an address where the operand is located.
NOTE:
Two memory accesses are required in order to obtain the value of the operand (fetch operand
address and fetch operand value).
Example: (textbook) ADD (A), R0
(address A is embedded in the instruction code and (A) is the operand address = pointer variable)
Example: SPIM - simulating pointers and indirect register addressing
The following \"C\" code:
could be translated into the following assembly code:
Example: SPIM/SAL - - array pointers and indirect register addressing
4) Absolute (Direct) Mode
The address of the operand is embedded in the instruction code.
Example: (SPIM)
5) Register Mode
The name (the number) of the CPU register is embedded in the instruction. The register contai.
Mastering Assembly Language: Programming with 8086sravanithonta79
Unlock the secrets of 8086 assembly language programming with this comprehensive document. Delve into the intricacies of low-level coding, understand the architecture, and harness the full potential of the 8086 processor. From foundational concepts to advanced techniques, this guide empowers you to craft efficient and powerful programs for the 8086 platform.
Machine Language Instruction Formats – Instruction Set of 8086-Data transfer
instructions,Arithmetic and Logic instructions,Branch instructions,Loop instructions,Processor
Control instructions,Flag Manipulation instructions,Shift and Rotate instructions,String
instructions, Assembler Directives and operators,Example Programs,Introduction to Stack,
STACK Structure of 8086, Interrupts and Interrupt Service Routines, Interrupt Cycle of 8086,
Non-Maskable and Maskable Interrupts, Interrupt Programming, MACROS.
A microprocessor is an electronic component that is used by a computer to do its work. It is a central processing unit on a single integrated circuit chip containing millions of very small components including transistors, resistors, and diodes that work together. Some microprocessors in the 20th century required several chips. Microprocessors help to do everything from controlling elevators to searching the Web. Everything a computer does is described by instructions of computer programs, and microprocessors carry out these instructions many millions of times a second. [1]
Microprocessors were invented in the 1970s for use in embedded systems. The majority are still used that way, in such things as mobile phones, cars, military weapons, and home appliances. Some microprocessors are microcontrollers, so small and inexpensive that they are used to control very simple products like flashlights and greeting cards that play music when you open them. A few especially powerful microprocessors are used in personal computers.
The 8086 instruction set consists of the following instructions: Data Transfer Instructions move, copy, load, exchange, input, and output. Arithmetic Instructions add, subtract, increment, decrement, convert byte/word and compare. Logical Instructions AND, OR, exclusive OR, shift/rotate and test
A microprocessor is an electronic component that is used by a computer to do its work. It is a central processing unit on a single integrated circuit chip containing millions of very small components including transistors, resistors, and diodes that work together.
This ppt covers the following topics
Software quality
A framework for product metrics
A product metrics taxonomy
Metrics for the analysis model
Metrics for the design model
Metrics for maintenance
This ppt covers the following
A strategic approach to testing
Test strategies for conventional software
Test strategies for object-oriented software
Validation testing
System testing
The art of debugging
This topic covers the following topics
Introduction
Golden rules of user interface design
Reconciling four different models
User interface analysis
User interface design
User interface evaluation
Example user interfaces
This ppt covers the following topics
Introduction
The software component
Designing class-based components
Designing conventional components
Thus it covers Component level design
This ppt covers the following topics :-
Introduction
Design quality
Design concepts
The design model
Thus it covers design engineering in software engineering
This ppt explains about the FAQ's in software engineering and software engineer profession and ethics of software engineer.
Difference between the system engineer and software engineer.
This ppt covers the following topics:
Introduction
Data design
Software architectural styles
Architectural design process
Assessing alternative architectural designs
Thus it covers Architectural Design
This ppt explains in brief what actually is arm processor and it covers the first 3 chapters of book "ARM SYSTEM DEVELOPERS GUIDE". The 3 chapters include the history,architecture,instruction set etc.
TECHNICAL TRAINING MANUAL GENERAL FAMILIARIZATION COURSEDuvanRamosGarzon1
AIRCRAFT GENERAL
The Single Aisle is the most advanced family aircraft in service today, with fly-by-wire flight controls.
The A318, A319, A320 and A321 are twin-engine subsonic medium range aircraft.
The family offers a choice of engines
Automobile Management System Project Report.pdfKamal Acharya
The proposed project is developed to manage the automobile in the automobile dealer company. The main module in this project is login, automobile management, customer management, sales, complaints and reports. The first module is the login. The automobile showroom owner should login to the project for usage. The username and password are verified and if it is correct, next form opens. If the username and password are not correct, it shows the error message.
When a customer search for a automobile, if the automobile is available, they will be taken to a page that shows the details of the automobile including automobile name, automobile ID, quantity, price etc. “Automobile Management System” is useful for maintaining automobiles, customers effectively and hence helps for establishing good relation between customer and automobile organization. It contains various customized modules for effectively maintaining automobiles and stock information accurately and safely.
When the automobile is sold to the customer, stock will be reduced automatically. When a new purchase is made, stock will be increased automatically. While selecting automobiles for sale, the proposed software will automatically check for total number of available stock of that particular item, if the total stock of that particular item is less than 5, software will notify the user to purchase the particular item.
Also when the user tries to sale items which are not in stock, the system will prompt the user that the stock is not enough. Customers of this system can search for a automobile; can purchase a automobile easily by selecting fast. On the other hand the stock of automobiles can be maintained perfectly by the automobile shop manager overcoming the drawbacks of existing system.
NO1 Uk best vashikaran specialist in delhi vashikaran baba near me online vas...Amil Baba Dawood bangali
Contact with Dawood Bhai Just call on +92322-6382012 and we'll help you. We'll solve all your problems within 12 to 24 hours and with 101% guarantee and with astrology systematic. If you want to take any personal or professional advice then also you can call us on +92322-6382012 , ONLINE LOVE PROBLEM & Other all types of Daily Life Problem's.Then CALL or WHATSAPP us on +92322-6382012 and Get all these problems solutions here by Amil Baba DAWOOD BANGALI
#vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore#blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #blackmagicforlove #blackmagicformarriage #aamilbaba #kalajadu #kalailam #taweez #wazifaexpert #jadumantar #vashikaranspecialist #astrologer #palmistry #amliyaat #taweez #manpasandshadi #horoscope #spiritual #lovelife #lovespell #marriagespell#aamilbabainpakistan #amilbabainkarachi #powerfullblackmagicspell #kalajadumantarspecialist #realamilbaba #AmilbabainPakistan #astrologerincanada #astrologerindubai #lovespellsmaster #kalajaduspecialist #lovespellsthatwork #aamilbabainlahore #Amilbabainuk #amilbabainspain #amilbabaindubai #Amilbabainnorway #amilbabainkrachi #amilbabainlahore #amilbabaingujranwalan #amilbabainislamabad
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
COLLEGE BUS MANAGEMENT SYSTEM PROJECT REPORT.pdfKamal Acharya
The College Bus Management system is completely developed by Visual Basic .NET Version. The application is connect with most secured database language MS SQL Server. The application is develop by using best combination of front-end and back-end languages. The application is totally design like flat user interface. This flat user interface is more attractive user interface in 2017. The application is gives more important to the system functionality. The application is to manage the student’s details, driver’s details, bus details, bus route details, bus fees details and more. The application has only one unit for admin. The admin can manage the entire application. The admin can login into the application by using username and password of the admin. The application is develop for big and small colleges. It is more user friendly for non-computer person. Even they can easily learn how to manage the application within hours. The application is more secure by the admin. The system will give an effective output for the VB.Net and SQL Server given as input to the system. The compiled java program given as input to the system, after scanning the program will generate different reports. The application generates the report for users. The admin can view and download the report of the data. The application deliver the excel format reports. Because, excel formatted reports is very easy to understand the income and expense of the college bus. This application is mainly develop for windows operating system users. In 2017, 73% of people enterprises are using windows operating system. So the application will easily install for all the windows operating system users. The application-developed size is very low. The application consumes very low space in disk. Therefore, the user can allocate very minimum local disk space for this application.
Cosmetic shop management system project report.pdfKamal Acharya
Buying new cosmetic products is difficult. It can even be scary for those who have sensitive skin and are prone to skin trouble. The information needed to alleviate this problem is on the back of each product, but it's thought to interpret those ingredient lists unless you have a background in chemistry.
Instead of buying and hoping for the best, we can use data science to help us predict which products may be good fits for us. It includes various function programs to do the above mentioned tasks.
Data file handling has been effectively used in the program.
The automated cosmetic shop management system should deal with the automation of general workflow and administration process of the shop. The main processes of the system focus on customer's request where the system is able to search the most appropriate products and deliver it to the customers. It should help the employees to quickly identify the list of cosmetic product that have reached the minimum quantity and also keep a track of expired date for each cosmetic product. It should help the employees to find the rack number in which the product is placed.It is also Faster and more efficient way.
Industrial Training at Shahjalal Fertilizer Company Limited (SFCL)MdTanvirMahtab2
This presentation is about the working procedure of Shahjalal Fertilizer Company Limited (SFCL). A Govt. owned Company of Bangladesh Chemical Industries Corporation under Ministry of Industries.
Welcome to WIPAC Monthly the magazine brought to you by the LinkedIn Group Water Industry Process Automation & Control.
In this month's edition, along with this month's industry news to celebrate the 13 years since the group was created we have articles including
A case study of the used of Advanced Process Control at the Wastewater Treatment works at Lleida in Spain
A look back on an article on smart wastewater networks in order to see how the industry has measured up in the interim around the adoption of Digital Transformation in the Water Industry.
Courier management system project report.pdfKamal Acharya
It is now-a-days very important for the people to send or receive articles like imported furniture, electronic items, gifts, business goods and the like. People depend vastly on different transport systems which mostly use the manual way of receiving and delivering the articles. There is no way to track the articles till they are received and there is no way to let the customer know what happened in transit, once he booked some articles. In such a situation, we need a system which completely computerizes the cargo activities including time to time tracking of the articles sent. This need is fulfilled by Courier Management System software which is online software for the cargo management people that enables them to receive the goods from a source and send them to a required destination and track their status from time to time.
Immunizing Image Classifiers Against Localized Adversary Attacksgerogepatton
This paper addresses the vulnerability of deep learning models, particularly convolutional neural networks
(CNN)s, to adversarial attacks and presents a proactive training technique designed to counter them. We
introduce a novel volumization algorithm, which transforms 2D images into 3D volumetric representations.
When combined with 3D convolution and deep curriculum learning optimization (CLO), itsignificantly improves
the immunity of models against localized universal attacks by up to 40%. We evaluate our proposed approach
using contemporary CNN architectures and the modified Canadian Institute for Advanced Research (CIFAR-10
and CIFAR-100) and ImageNet Large Scale Visual Recognition Challenge (ILSVRC12) datasets, showcasing
accuracy improvements over previous techniques. The results indicate that the combination of the volumetric
input and curriculum learning holds significant promise for mitigating adversarial attacks without necessitating
adversary training.
Event Management System Vb Net Project Report.pdfKamal Acharya
In present era, the scopes of information technology growing with a very fast .We do not see any are untouched from this industry. The scope of information technology has become wider includes: Business and industry. Household Business, Communication, Education, Entertainment, Science, Medicine, Engineering, Distance Learning, Weather Forecasting. Carrier Searching and so on.
My project named “Event Management System” is software that store and maintained all events coordinated in college. It also helpful to print related reports. My project will help to record the events coordinated by faculties with their Name, Event subject, date & details in an efficient & effective ways.
In my system we have to make a system by which a user can record all events coordinated by a particular faculty. In our proposed system some more featured are added which differs it from the existing system such as security.
Explore the innovative world of trenchless pipe repair with our comprehensive guide, "The Benefits and Techniques of Trenchless Pipe Repair." This document delves into the modern methods of repairing underground pipes without the need for extensive excavation, highlighting the numerous advantages and the latest techniques used in the industry.
Learn about the cost savings, reduced environmental impact, and minimal disruption associated with trenchless technology. Discover detailed explanations of popular techniques such as pipe bursting, cured-in-place pipe (CIPP) lining, and directional drilling. Understand how these methods can be applied to various types of infrastructure, from residential plumbing to large-scale municipal systems.
Ideal for homeowners, contractors, engineers, and anyone interested in modern plumbing solutions, this guide provides valuable insights into why trenchless pipe repair is becoming the preferred choice for pipe rehabilitation. Stay informed about the latest advancements and best practices in the field.
2. STRING INSTRUCTIONS
The 8086 has a set of instructions for handling
blocks of data in the form of bytes or words.
They are called ‘string’ instructions.
A string is an array of data of the same type – for
example, a character string or a byte string
The usefulness of string instructions can be
seen when in the memory data has to be moved,
searched or compared in blocks.
3. PRE-REQUISITES FOR USING STRING
INSTRUCTIONS
i. DS and ES are to be defined: Initializing & using
these segment makes DS as the source & ES as
the destination segment
ii. SI and DI acts as pointers: SI to point to DS & DI top
point to ES, means SI should contain the address (offset) of
the first location in the DS and DI should contain the
address of the first location in ES
iii. DF should be set/reset: control flag called as direction
flag, used exclusively for string operations. Purpose in
string operation is, if flag is set, the pointers get
automatically decremented, and if reset, the reverse
occurs. So, during string instructions are used, DF should
be set/reset depending on the direction.
iv. CX should act as a counter: counter CX should be
loaded with the count of number of operations required.
6. THE MOVS INSTRUCTION
Can be used as MOVSB or MOVSW
It moves data from the source segment (data
segment) to the destination segment (extra
segment)
CX acts as the count register
DF is to be set/reset
SI and DI have to be intialiased to the source
address in the data segment ,and the destination
address in the extra segment
8. Two segments DAT & EXTR are defined
Two segment registers DS & ES are initialized
SI & DI point to the source data & destination data
CLD is used to clear the DF for auto incrementing the
pointer registers
This causes the value of SI and DI to be incremented after
each move operation
Here, SI & DI are incremented only by one each time
String instruction is used here is MOVSB
This causes the data in location pointed by SI to be moved
to the location pointed by DI
After each such move operation, two actions occur
One is that CX decrements by 1 and the other is that the
pointer registers are incremented
This sequence continues until CX=0
10. THE CMPS INSTRUCTION
This instruction is for string comparison, byte
by byte or word by word as the case may be.
The conditional flags are modified according
to the result of the comparison.
String comparison has to be accompanied by
the use of the conditional REP prefix.
Since string comparison checks only for
equality, the Zero flag is made use of
automatically.
11. Example
Compare two character strings (of length six) which
are saved in the data segment.
One of two messages is to be displayed, depending
on whether the strings are equal or not.
12.
13. THE SCAS INSTRUCTION
The SCAS instruction scans a byte or word string to
ascertain the presence of a specific byte or word. This
specific data is loaded into AL or AX.
The string which is to be scanned has to be in the
extra segment, and is to be pointed by DI. This is
mandatory and cannot be overridden.
14. Write a program to search for a character in an
ASCII string .
Express the result using appropriate messages
16. THE STOS AND LODS
INSTRUCTIONS
i) STOS
The STOS instruction is the mnemonic for ‘storing’ a
string in memory.
As such, we need to define a memory area in which
‘storing’ is to be done. This memory area is defined to
be the extra segment, and it is addressed by DI as it
is the destination segment.
The data to be stored is placed in the AL or AX register.
An area in memory can be filled with the required data,
with this instruction.
17. Write a program to fill an area of memory with a
specific word
19. THE LODS
INSTRUCTION
This is an instruction for ‘loading’.
Here, the source memory is the data
segment and the pointer to it is SI
The data segment is the source segment
and the destination register is the AL or AX
register.
There is no sense in using the REP prefix
for the LODS instruction as data can be
loaded to AL/AX only once.
20. PROCEDURES
When a main program calls a subsidiary
program ,the latter is called a procedure
To avoid writing the sequence of instructions
in the program each time you need them,
you can write the sequence as a separate
subprogram called a procedure
You use the CALL instruction to send the
8086 to the starting address of the
procedure in memory
21. CONTD..
A RET instruction at the end of the procedure
returns execution to the next instruction in the main
line
Procedures can even be nested
22. THE SEQUENCE OF CALLING PROCEDURES
Near procedure –which resides in the same code
segment as the main (calling) program
A procedure is called by a CALL instruction
At the time the CALL instruction is being executed,
the IP (instruction pointer) will be pointing to the
next instruction in the main program
23. THE STEPS TAKEN BY THE PROCESSOR FOR
CALLING PROCEDURES
It saves the current IP content on the stack (this is
the ‘return’ address for coming back to the main
program after executing the procedure).
The CALL destination (specified in the CALL
instruction) will be the address of the procedure.
The IP is now loaded with this address and
execution proceeds from that location
The procedure is executed until a RET (return)
instruction in the procedure is encountered.
Then, the old value of the IP is retrieved from the
stack and control returns to the main program at the
return address.
27. WRITING A PROCEDURE
The procedure should begin with the
procedure name followed by the directive
PROC.
We also use the directives NEAR or FAR
which specify the ‘type’ of the procedure.
The procedure should end with the
procedure name and ENDP.
28. EXAMPLE 4.5
Write a program, which enters 10 single digit
numbers through the keyboard, finds their squares
and stores the squares in memory.
Only byte locations need be allocated in memory
for the squares as the square of the highest single
digit number is 81, which will fi t into a byte space
30. THE CALL INSTRUCTION
Intrasegment or ‘Near’ Call
i) Direct CALL
Usage: CALL label
The direct call is like a direct jump instruction, and is
three bytes long. It is relative and the destination can be
−32,768 bytes to +32,767 bytes from the address of the
instruction following
the call (this will be the current content of the IP).
the off set can be a 16-bit signed number.
When this call is executed, the new value of IP = old IP
+ off set,
31. FIGURE 4.3 | FORMAT OF THE DIRECT NEAR
CALL INSTRUCTION
32. II) INDIRECT CALL
Usage: CALL reg16, CALL [reg16]
In this case, the destination is specified in a 16-bit
register or in a memory location pointed by a
register.
This is not a ‘relative’ call. The content of the
referred register or memory location is loaded into
IP for using the procedure.
Examples
CALL BX ;the procedure’s address is in BX
CALL WORD PTR[BX] ;the address of the
procedure is in memory and is pointed by BX
34. INTERSEGMENT OR FAR CALL
Direct Far Call A far call is an intersegment call,
which means that the destination address is in a
different code segment.
This will be a 5-byte instruction, the first byte being
the opcode, the second and third bytes being the
new value of IP, and the fourth and fi fth, the new
values of CS.
This is not a relative call.
When the procedure is called, the IP and CS values
are replaced by the corresponding values in the call
instruction
36. INDIRECT FAR CALL
• The destination address is not in the instruction –
rather, it is in a register or memory.
For a far call, four bytes are needed to specify a
destination. a register cannot specify it. Hence the
four bytes needed to specify a destination are
stored in
memory and pointed by a register.
37. Example of an indirect far call
CALL DWORD PTR [SI] can be a far call instruction.
[SI] and [SI + 1] gives the new value of IP and [SI + 2]
and [SI + 3] gives the new value of CS.
Far calls and procedures are specified using the ‘far’
directive when defining the procedure.
In Chapter 5, we will see how the EXTRN directive is
used in this context.
38. THE RET INSTRUCTION
i) Usage: RET
The execution of RET causes the return address to
be popped from the stack to IP or IP and CS.
(Whenever a procedure is defined, it is known
whether it is a far or near procedure. From this, it is
determined whether the stack has saved just the
old IP value or both IP and CS.)
39. RET N
Usage: RET n
This is another form of the RET instruction. This
adds the number ‘n’ to the stack pointer (SP) after
the return address has been popped off the stack,
on return from a procedure
40. THE USE OF THE STACK IN PROCEDURE
CALLS
When both the main program and the procedures
need the same registers, the content of the
registers are pushed onto the stack when going to
a procedure ,and popped back on returning.
MASM 6.x has a construct ‘USES’ which
automatically pushes the specified registers onto
the stack.
The popping will be automatic on returning from the
procedure.
43. PASSING PARAMETERS TO AND FROM
PROCEDURES
Can be done using
o Registers
o Memory and memory pointers
o Stack
44. EXAMPLE 4.8
Write a program which calculates and places in
memory the Nth term of an arithmetic progression.
The formula for the Nth term of an A.P. is A + (N −
1) D, where A is the fi rst term and D is the common
difference.
Pass the values of the operands using registers
46. PASSING PARAMETERS THROUGH
MEMORY
Example 4.9 is a program for arranging a set of
numbers (stored in memory) in descending order.
The values are passed to the program through
memory pointers.
The method involves comparing numbers pair-wise
and repeating this N − 1 times, if there are N
numbers to be sorted.
48. PASSING PARAMETERS THROUGH THE
STACK
There may be reasons where the stack, which is an
area in the memory, can be used to store data. The
procedure can take data from the stack for its
computation.
Example 4.10 shows BP being used to access data in
the stack
Here, four words which are in the data segment are
pushed on to the stack by the main program.
The procedure accesses the data using the indexing
features of BP. Remember that BP is a register
associated (by default) with the stack segment, and
that BP cannot be used without an off set.
49. EXAMPLE 4.10
Calculate (A + B) − (E + D) where A, B, E and D are
words stored in data memory. The result is also to
be saved in the data segment.
Use BP for accessing the stack
Note We do not use C as a label because ‘C’ is a
reserved word in MASM
50.
51. FIGURE 4.5 | STACK OPERATION FOR THE
PUSH AND RET 8 INSTRUCTIONS OF EXAMPLE
4.10
52. STACK OVERFLOW AND
UNDERFLOW
SP can have a maximum value of FFFFH. For each
PUSH operation, the SP value decrements by 2,
and in the limiting case, it can go to SP = 0000.
Any PUSH operation beyond this will cause a
‘stack overflow’.
This creates a condition when there is no space in
the stack for new data.
Stack underflow is the other case when POP
operations cause SP to have values beyond the
defined stack.
53. MACROS
What is a macro? It is like an opcode – when used,
it executes.
A macro when called by name, executes the
instructions that are listed under that name.
Thus essentially, a macro is a short hand notation
for a number of instruction lines.
It makes assembly language coding more readable
and helps to avoid repetitive coding.
54. WRITING A MACRO –THE FORMAT
MACRO-NAME MACRO [parameter list]
Instructions (body of the macro)
ENDM
55.
56.
57. Macros Procedures
Accessed during assembly when
name given to macro is written as
an instruction in the assembly
program.
Accessed by CALL and RET
instructions during program
execution.
Machine code is generated for
instructions each time a macro is
called.
Machine code for instructions is put
only once in the memory.
This due to repeated generation of
machine code requires more
memory.
This as all machine code is defined
only once so less memory is
required.
Parameters are passed as a part of
the statement in which macro is
called.
Parameters can be passed in
register memory location or stack.