SlideShare a Scribd company logo
Discussion: Assembly Language Paper
Discussion: Assembly Language PaperORDER HERE FOR ORIGINAL, PLAGIARISM-FREE
PAPERS ON Discussion: Assembly Language PaperAssembly language Please refer to slides
and primer board lessons 1. A system is designed to monitor the temperature of a furnace.
Temperature readings are recorded in 16 bits and stored in memory locations starting at
XX60H. The highorder byte is stored first and the low-order byte is stored in the next
consecutive memory location. However, the high-order Byte of all the temperature readings
is constant. Write a program to transfer the low-order readings to consecutive memory
locations starting at XX80H and discard the high-order bytes. Temperature Readings (H)
0581, 0595, 0578, 057A, 0598. 2. The temperatures of two furnaces are being monitored by
a microcomputer. A set of five readings of the first furnace, recorded by five thermal
sensors, is stored at the memory location starting at XX50H. A corresponding set of five
readings from the second furnace is stored at the memory location starting at XX60H. Each
reading from the first set is expected to be higher than the corresponding reading from the
second set. For example, the temperature reading at the location 54H (T54) is expected to
be higher than the temperature reading at the location 64H (T64).Discussion: Assembly
Language PaperWrite a program to check whether each reading from the first set is higher
than the corresponding reading from the second set. If all readings from the first set are
higher than the corresponding readings from the second set, turn on the bit D0 of the output
PORT1. If any one of the readings from the first set is lower than the corresponding reading
of the second set, stop the process and output FF as an emergency signal to the output
PORT1. 3. Specify the contents of the accumulator and the status of the Cy flag when the
following instructions are executed a. MVI A,B7H ORA A RLC b. MVI A,B7H ORA A RAL 4.
Calculate the decimal value of the number in the accumulator before and after the Rotate
instructions are executed, and explain the mathematical functions performed by the
instructions a. MVI A,18H RLC b. MVI A,78H RRC RRC 5. Explain the mathematical function
that is performed by the following instructions MVI A,07H RLC MOV B,A RLC RLC ADD B 6.
A set of eight readings is stored in memory starting at location XX50H. Write a program to
check whether a byte of 40H exists in the set.Discussion: Assembly Language PaperIf it
does, stop checking and display its memory location; otherwise output FFH. DATA(H) 48,
32, F2, 38, 37, 40, 82, 8A 7. The following program adds the number of bytes stored in
memory locations starting from XX00H and saves the result in memory. Read the program
and answer the questions given below LXI H,XX00H ;Set up HL as a data pointer LXI
D,0000H ;set up D as a byte counter and E as a Carry register NEXT: ADD M ;Add byte JNC
SKIP ;If the result has no carry, do not increment Carry register INR E SKIP: DCR D ;Update
byte counter JNZ NEXT ;Go to the next byte LXI H,XX90H MOV M,A ;Save the result INX H
MOV M,E HLT a. Assuming the byte counter is set up appropriately, specify the number of
bytes that are added by the program. b. Specify the memory locations where the result is
stored. c. Identify the two errors in this program.Discussion: Assembly Language
PaperMicroprocessors and Assembly Language Microprocessors • Programmable devices,
instructed to perform given tasks within its capability. • Designed to understand and
execute many binary instructions • The engineers designing microprocessors determine a
set of tasks the microprocessor should perform and design necessary logic circuits • They
also provide user with a list of instructions the processor will understand. Von Neuman
Architecture • Digital computers: • They are traditionally represented by five components:
CPU, ALU plus control unit, memory, input and output • Organization of a Microprocessor
based system: • CPU: the central processing unit. The group of circuits that processes data
and provides control signals and timing. It includes the arithmetic/logic unit, registers,
instruction decoder, and the control unit. • ALU: the group of circuits that perform
arithmetic and logic operations. It is part of CPU. • Control unit: the group of circuits that
provides timing and signals to all operations in the computer and controls data flow. •
Register array: • used to store data temporarily during the execution of a program and are
accessible to the user through instructions. • They are identified by letters such as B, C, D, E,
H and L. • Input: a device that transfers information from the outside to the computer. •
Output: a device that transfers information from the computer to the outside world.
•Organization of a Microprocessor based system: • Memory: • stores binary information as
instructions and data and provides them to the microprocessor whenever necessary. • To
execute programs, the microprocessor reads instructions and data from memory and
performs the computing operations in its ALU. Results are either transferred to the output
section for display or stored in memory for later use. • ROM (read only memory) • is used to
store programs that do not need alterations. E.g. the program that interprets info entered
through keyboard and provides equivalent binary digits to microprocessor. • RAM (random
access memory) • stores user programs and data • System Bus: • is a communication path
between the microprocessor and peripherals. • it is nothing but a group of wires to carry
bits. • Moore’s Law • Scale of Integration: • SSI (small scale integration)- the process of
designing a few circuits on a single chip. e.g. discrete logic gates on a chip. • MSI ( medium
scale integration) the process of designing more than a hundred gates on a single chip • LSI
( large scale integration) the process of designing more than a thousand gates on a single
chip • Similarly VLSI (very large scale integration) and SLSI (super large scale integration)
•Discussion: Assembly Language PaperHow does a microprocessor work? • • • • Fetch: an
instruction from memory. Decode: interpret the instruction Execute: perform action repeat
until comes across an instruction to stop. Microprocessor Instruction set • Machine
language: • an 8-bit microprocessor can have 256 different words. • The designer selects
combinations of bit patterns and gives a specific meaning to each combination by using
electronic logic circuits.—-This is called an instruction • The 8085 machine language: • The
8085 has 74 different instructions. This is called the instruction set. • The binary language
of the instruction set is called the machine language. • e.g. • 0011 1100 is an instruction to
increment a register called the accumulator by 1 • 1000 0000 is an instruction that adds the
number in register B to the number in the accumulator. and keeps the sum in the
accumulator. • 8085 Assembly language: • Each manufacturer of a microprocessor has
devised a symbolic code for each instruction, called a mnemonic • The mnemonic of the
instruction set is called assembly language. • Examples: • binary code 0011 1100 (3CH) is
represented by the mnemonic INR A •binary code 1000 0000 (80H) is represented by the
mnemonic ADD B • Machine language and assembly language are microprocessor specific
and are both considered low level languages. • Writing and Executing an Assembly language
Program: • To manually write and execute an assembly language program on a single board
computer, with a HEX keyboard for input and LEDs (light emitting diodes) for output : •
Write the instructions in mnemonics obtained from instruction set of manufacturer. • Find
the hexadecimal machine code for each instruction • Enter the program in user memory in
sequential order by using the HEX keyboard • Execute the program by pressing the Execute
key. • This is hand assembly. • An assembler is a program that translates an assembly
language program to binary machine code. The 8085 Programming model • Registers:
•8085 has six general-purpose registers to store 8-bit data. • These are identified as B, C, D,
E, H, and L • They can be combined as register pairs – BC, DE and HL to perform 16-bit
operations. • Accumulator: • 8-bit register that is used to store 8-bit data and perform arith.
and logical operations. The result of the operation is stored in the accumulator. It is
identified as A. • Flags: • ALU includes five flip flops, which are set or reset after an
operation according to data conditions of the result • They are: • Z (zero flag): is set to 1
when the result is zero. • CY (carry): is set if an arithmetic operation results in a carry, o.w.
reset. • S (sign): is set if most significant bit (D7) of the result is 1 • P (parity): is set if result
has an even number of 1s, reset for odd number of 1s • AC (auxiliary carry): is set in an
arithmetic operation if a carry is generated by digit D3 and passed to digit D4. It is used
internally for BCD operations • Program Counter (PC): • 16-bit register to hold memory
addresses. • It is used to sequence the execution of the instructions • It points to the
memory address from which the next byte is fetched. • After the fetch, it is incremented by
one • Stack pointer (SP): • 16-bit register used as memory pointer to a location the RAM
called the stack. • The beginning of the stack is defined by loading a 16-bit address in SP. •
Introduce the Primer board or Simulaoror Simulator• Each instruction has two parts: • The
operation code (opcode): which is the task to be performed • The operand: which is the
data to be operated on • Instructions can be: • 1-byte instructions: (opcode and operand in
the same byte) • 2-byte instructions: (first byte is opcode, second byte is operand) • 3-byte
instructions: ( first byte is opcode, the following two bytes specify the 16-bit address. The
second byte is the low order address and the third byte is the high order address) • One-
byte instructions • Two-byte instructions • Three-byte instructions • Some examples for
primer • see handouts • use the Primer board or Simulaor in class to run these examples. •
Lesson 2 Overview of the 8085 instruction set: • Data Transfer (Copy) instructions Data
Transfer (copy) instructions • The data transfer instructions: • copy data from a source into
a destination without modifying the contents of the source. • They do not affect flags •
Examples: • MOV Rd,Rs copies data from source register Rs to destination register Rd • MVI
R, 8-bit loads 8 bits of second byte into register • OUT 8-bit port address sends the contents
of the accumulator A to the output port specified by the second byte • IN 8-bit port address
accepts (reads) data from the input port specified by the second byte and loads into the
accumulator A other instructions • HLT • The processor stops executing and enters wait
state. •The address bus and data bus are placed in high impedance state. No registers are
affected. • NOP • No operation • used to increase processing time or substitute in place of an
instruction. • When an error occurs in a program and an instruction needs to be eliminated,
it is more convenient to substitute NOP than to reassemble the whole program. Examples •
Load accumulator A with 82H and save in register B • MVI A, 82H • MOV B, A • Read eight
ON/OFF switches connected to input port with address 00H, and turn on devices connected
to output port with address 01H • IN 00H • OUT • HLT 01H • If the switch positions has a
pattern of 4FH, this will be placed on the data bus and transferred to Acc. The out
instruction places this pattern on ON/OFF devices of output port. This will turn on devices
connected to output port data lines D6, D3, D2, D1 and D0 Examples Addressing Modes •
Immediate addressing • e.g. MVI R, data • Register addressing • e.g. MOV Rd, Rs • Direct
addressing • e.g. IN/OUT port # • indirect addressing • will be discussed in ch7 Another
example • Problem: load 37H in B and display the number at the output port labeled PORT1
MVI B, 37H MOV A, B OUT PORT1 HLT • from assembly language to machine language MVI
B, 37H 06 37 MOV A, B 78 OUT PORT1 D3 01 HLT 76 • Lesson 3 Primer Arithmetic
Operations • Examples: ADD, ADI, SUB, SUI .Discussion: Assembly Language PaperAssume
implicitly that the accumulator is one of the operands • modify all flags according to data
conditions of the result • place the result in the accumulator • do not affect the contents of
the operand register • e.g ADD C add the contents of register C to contents of accumulator,
set the flags accordingly. • Others: INR R , DCR R • affect the contents of the specified
register • affect all flags except the CY flag • Lesson 4, 5 ( try INR R instead of ADD, see how
it affects flags) Hex code for INR A = 3CH Addition • assume that A=93H, C=B7H • after ADD
C instruction: • A=4AH, C =B7H, • flag status: S=0 (D7 is not 1), Z=0 (A is not 0), CY=1 • after
ADI 35H • A= 7FH, • Flags: S=0, Z=0 , CY =0 • Now assume A=FFH • if ADI 01H will leave
A=0, flags: S=0, Z=1, CY=1 • if INR A, A=00H, S=0, Z=1, CY=NA Subtraction • Subtraction is
performed in 2’s complement. • The following steps are done internally: • convert
subtrahend (# to be subtracted) into 2’s complement. • add it to contents of accumulator. •
complement the carry flag. • Example: B= 65H, A=97H • SUB B • will result in A= 32H, S=0,
Z=0, CY=0 Illustrative problem • Write a problem to: 1. load 30H in B, 39H in C 2. subtract
39H from 30H 3. display the answer at port1 – Program: MVI B, 30H MVI C, 39H MOV A, B
SUB C OUT port1 HLT – result: A= F7, S=1, Z=0, CY=1 Logic Operations • Examples: • ANA R,
logically ANDs the contents of R with A, CY reset, AC set • ANI 8-bit logically ANDs the
second byte with the contents of accumulator, CY reset, AC set • ORA R, logically ORs the
contents of R with A • ORI 8-bit, logically ORs the second byte with the contents of
accumulator • XRA R, XORs the contents of R with A, AC, CY are reset • XRI 8-bit XORs the
second byte with the contents of accumulator, AC, CY are reset • CMA complement
accumulator, no flags affected Illustrative Program: data masking with logic AND • Problem
statement: •to control appliances around the house • turn on air conditioner if switch S7 of
the input port 00H is on. • ignore all other switches of the input port even if someone
attempts to turn on other appliances. • Program: IN 00H ANI 80H; mask all bits except D7
OUT 01H HLT OR, XOR, NOT • assume B= 93H, A= 15H • ORA B , will result in A=97H
(verify), S=1, Z=0, CY=0 • XRA B, will result in A=86H (verify), S=1, Z=0, CY=0 • CMA, will
result in A=EAH (verify), no flags modified Setting and resetting specific bits • Examples: •
Keep the radio on (D4) continuously without affecting the functions of other appliances,
even if someone turns off the switch S4. IN 00H ORI 10H, always set bit D4 • Turn off air
conditioner (D7) without affecting other appliances. IN 00H ANI 7FH, always reset S7 •
Lesson 12 Branch Operations • They allow the microprocessor to change the sequence of a
program, either unconditionally or conditionally. • They are classified into three categories:
• Jump instructions .Discussion: Assembly Language PaperCall and return instructions ( in
subroutines ch 9) • restart instructions ( interrupt techniques ch 12) • JMP 16-bit,
unconditional jump, the second and third bytes specify 16-bit memory address. The second
byte specifies the low order and the third byte specifies the high order memory address •
e.g. JMP 2000H, jump to memory location 2000H • machine code C3 00 20 Illustrative
program: unconditional jump to set up a continuous loop • Problem statement: • read the
switch positions continuously and turn on the appliances accordingly • Program: • mem.
add. m/c code label mnemonics 2000 2001 2002 2003 2004 2005 2006 DB 00 D3 01 C3 00
20 START: IN 00H OUT 01H JMP START conditional jumps • They allow microprocessor to
make decisions based on certain conditions indicated by the carry, zero, sign and parity
flags • Two jump instructions are associated with each flag. • e.g. while adding the numbers
you can change the program sequence either because the carry is present (JC= Jump on
carry) or because the carry is absent (JNC= jump on no carry) conditional jump instructions
• • • • • • • • JC JNC JZ JNZ JP JM JPE JPO 16-bit, jump on carry ( if CY=1) 16-bit, jump on no
carry ( if CY=0) 16-bit, jump on zero ( if Z=1) 16-bit, jump on no zero ( if Z=0) 16-bit, jump
on plus ( if D7=0 and S=0) 16-bit, jump on minus ( if D7=1 and S=1) 16-bit, jump on parity
even ( if P=1) 16-bit, jump on parity odd ( if P=0) • Lesson 13 Illustrative Program: testing
of the carry flag • problem statement: load the hexadecimal numbers 9BH and A7H in
registers D and E, and add the numbers. If the sum is greater than FFH, display 01H at
output port0; o.w. display the sum Illustrative Program: testing of the carry flag (cont.) •
machine code with memory addresses: • Note we can use JC instruction instead of JNC, just
change the order of the other instructions accordingly • Try this program as well. Writing
assembly language programs • Read the problem carefully • Break it down into small steps.
• Represent these small steps with a flow chart • Translate each block of the flow chart into
appropriate mnemonic instructions • Translate mnemonic into machine code. •Discussion:
Assembly Language Paper.Discussion: Assembly Language PaperEnter the machine code
into memory and execute • Debug your program if necessary Counters • Add ten data bytes
of data stored in memory locations starting at a given location and display the sum. • a
counter to count 10 data bytes • an index or a memory pointer to locate where data bytes
are stored • to transfer data from a memory location to ALU • to perform addition •
registers for temporary storage of partial sum • a flag to indicate the completion of a task •
to store or output the result. Additional data transfers and 16-bit arithmetic instructions •
LXI Rp, 16 bit • 3 byte instruction • Rp is a register pair, it can be B, D and H to represent BC,
DE, and HL registers respectively. • The second byte is loaded in the low order register of
the register pair (e.g. register C, E, L) • the third byte is loaded in the high-order register
pair. (e.g. register B, D and H) • LXI SP, 16 bit • loads stack pointer. Additional data transfers
and 16-bit arithmetic instructions • Write instructions to load 16-bit number 2050 H in
register pair HL using LXI and MVI opcodes. Data transfer from memory to microprocessor
• MOV R, M • • • • 1 byte instruction copies data byte from memory location into a register
the memory location is specified by the contents of the register pair HL This is indirect
addressing mode; specification of memory location is indirect • LDAX B/D i.e. LDAX B, LDAX
D • • • • • load accumulator indirect 1 byte instruction copies data byte from memory
location into accumulator the memory location is specified by the contents of the register
pair BC or DE This is indirect addressing mode • LDA 16-bit • load accumulator direct
.Discussion: Assembly Language Paper3-byte instruction • copies data from memory
location specified by 16-bit address in second and third byte • second byte is low order
memory address • third byte is high order memory address • addressing mode is direct
Example • the memory location 2050H holds the data byte F7H. Write instructions to
transfer the data byte to the accumulator using three different opcodes: MOV, LDAX, and
LDA • Indirect addressing mode takes four bytes and direct addressing mode takes three
bytes. • The question is: Why not just use the direct addressing mode? • If only one byte is
transferred LDA is more effici …

More Related Content

Similar to Assembly Language Paper.docx (20)

PPT
8085_Microprocessor(simar).ppt
KanikaJindal9
 
PPT
Programming with 8085-Microprocessor and interfacing
Amitabh Shukla
 
PPT
Unit 3 assembler and processor
Abha Damani
 
PPTX
Lec03
siddu kadiwal
 
PDF
Assembler Programming
Omar Sanchez
 
PPTX
MECHATRONICS-UNIT 2-8085 MICROPROCESSOR AND 8051 MICROCONTROLLER .pptx
CHANDRA KUMAR S
 
PDF
8085 micro processor
Arun Umrao
 
PDF
Notes of 8085 micro processor Programming for BCA, MCA, MSC (CS), MSC (IT) &...
ssuserd6b1fd
 
PPTX
MicroProcessors
Muhammad Uzair Rasheed
 
PDF
UNIT 2-8085 MICROPROCESSOR AND 8051 MICROCONTROLLER.pdf
Chandra Kumar S
 
PPTX
EC8691-MPMC-PPT.pptx
Manikandan813397
 
PPTX
ALP intro assembly language programing.pptx
ansariparveen06
 
PPT
Chapter3 presentation2
surendar88
 
PPT
8051assembly language
Hisham Mat Hussin
 
PDF
Microprocessor and microcontroller (MPMC).pdf
XyzjakhaAbhuvs
 
PDF
lecture1423813120.pdf
Akhilesh Mishra
 
PDF
12109 microprocessor & programming
Gaurang Thakar
 
PDF
microprocessor & programming
Gaurang Thakar
 
PPTX
Basic programming of 8085
vijaydeepakg
 
PPTX
Computer Organization
Radhika Talaviya
 
8085_Microprocessor(simar).ppt
KanikaJindal9
 
Programming with 8085-Microprocessor and interfacing
Amitabh Shukla
 
Unit 3 assembler and processor
Abha Damani
 
Assembler Programming
Omar Sanchez
 
MECHATRONICS-UNIT 2-8085 MICROPROCESSOR AND 8051 MICROCONTROLLER .pptx
CHANDRA KUMAR S
 
8085 micro processor
Arun Umrao
 
Notes of 8085 micro processor Programming for BCA, MCA, MSC (CS), MSC (IT) &...
ssuserd6b1fd
 
MicroProcessors
Muhammad Uzair Rasheed
 
UNIT 2-8085 MICROPROCESSOR AND 8051 MICROCONTROLLER.pdf
Chandra Kumar S
 
EC8691-MPMC-PPT.pptx
Manikandan813397
 
ALP intro assembly language programing.pptx
ansariparveen06
 
Chapter3 presentation2
surendar88
 
8051assembly language
Hisham Mat Hussin
 
Microprocessor and microcontroller (MPMC).pdf
XyzjakhaAbhuvs
 
lecture1423813120.pdf
Akhilesh Mishra
 
12109 microprocessor & programming
Gaurang Thakar
 
microprocessor & programming
Gaurang Thakar
 
Basic programming of 8085
vijaydeepakg
 
Computer Organization
Radhika Talaviya
 

More from write22 (20)

DOCX
Utilizing research software can be daunting for a What.docx
write22
 
DOCX
To Prepare Reflect on your own community and consider the.docx
write22
 
DOCX
Watch this video about Joseph concept of Creative.docx
write22
 
DOCX
write a 700 word psychoanalytic criticism research about the.docx
write22
 
DOCX
You have had the opportunity to review thermoregulation as is.docx
write22
 
DOCX
Write 300 words in MLA Nietzsche claims God.docx
write22
 
DOCX
Write 300 words in MLA choose one topic.docx
write22
 
DOCX
Week 9 Assignment 2 Case Total Quality.docx
write22
 
DOCX
What were American and British strategies for winning the.docx
write22
 
DOCX
What is the process involving movement of mantle rock that.docx
write22
 
DOCX
Unit Learning Outcomes ULO Explain job and.docx
write22
 
DOCX
Timeline of events what was happening that was important.docx
write22
 
DOCX
To what degree did the emergence of a large union.docx
write22
 
DOCX
This you will begin to synthesize the information you.docx
write22
 
DOCX
This is for Understanding the behavior of infection.docx
write22
 
DOCX
The use of devices within information technology has increased exponentially....
write22
 
DOCX
Steven Smith was employed by the Avon School District as.docx
write22
 
DOCX
Students will assume the situation of an individual with.docx
write22
 
DOCX
The company that all students will use for their final.docx
write22
 
DOCX
the following critical elements must be Lens.docx
write22
 
Utilizing research software can be daunting for a What.docx
write22
 
To Prepare Reflect on your own community and consider the.docx
write22
 
Watch this video about Joseph concept of Creative.docx
write22
 
write a 700 word psychoanalytic criticism research about the.docx
write22
 
You have had the opportunity to review thermoregulation as is.docx
write22
 
Write 300 words in MLA Nietzsche claims God.docx
write22
 
Write 300 words in MLA choose one topic.docx
write22
 
Week 9 Assignment 2 Case Total Quality.docx
write22
 
What were American and British strategies for winning the.docx
write22
 
What is the process involving movement of mantle rock that.docx
write22
 
Unit Learning Outcomes ULO Explain job and.docx
write22
 
Timeline of events what was happening that was important.docx
write22
 
To what degree did the emergence of a large union.docx
write22
 
This you will begin to synthesize the information you.docx
write22
 
This is for Understanding the behavior of infection.docx
write22
 
The use of devices within information technology has increased exponentially....
write22
 
Steven Smith was employed by the Avon School District as.docx
write22
 
Students will assume the situation of an individual with.docx
write22
 
The company that all students will use for their final.docx
write22
 
the following critical elements must be Lens.docx
write22
 
Ad

Recently uploaded (20)

PDF
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
PDF
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
PDF
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
PPTX
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
PDF
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
PDF
community health nursing question paper 2.pdf
Prince kumar
 
PDF
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
PPTX
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
PDF
The Different Types of Non-Experimental Research
Thelma Villaflores
 
PPTX
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
PDF
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
PDF
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
PDF
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
PDF
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
PPTX
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
PDF
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
PDF
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
PDF
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
PPTX
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
PDF
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
People & Earth's Ecosystem -Lesson 2: People & Population
marvinnbustamante1
 
Lesson 2 - WATER,pH, BUFFERS, AND ACID-BASE.pdf
marvinnbustamante1
 
Generative AI: it's STILL not a robot (CIJ Summer 2025)
Paul Bradshaw
 
Universal immunization Programme (UIP).pptx
Vishal Chanalia
 
ARAL-Orientation_Morning-Session_Day-11.pdf
JoelVilloso1
 
community health nursing question paper 2.pdf
Prince kumar
 
The History of Phone Numbers in Stoke Newington by Billy Thomas
History of Stoke Newington
 
2025 Winter SWAYAM NPTEL & A Student.pptx
Utsav Yagnik
 
The Different Types of Non-Experimental Research
Thelma Villaflores
 
Soil and agriculture microbiology .pptx
Keerthana Ramesh
 
Biological Bilingual Glossary Hindi and English Medium
World of Wisdom
 
BÀI TẬP BỔ TRỢ TIẾNG ANH 8 - GLOBAL SUCCESS - CẢ NĂM - NĂM 2024 (VOCABULARY, ...
Nguyen Thanh Tu Collection
 
The-Ever-Evolving-World-of-Science (1).pdf/7TH CLASS CURIOSITY /1ST CHAPTER/B...
Sandeep Swamy
 
LAW OF CONTRACT (5 YEAR LLB & UNITARY LLB )- MODULE - 1.& 2 - LEARN THROUGH P...
APARNA T SHAIL KUMAR
 
How to Manage Large Scrollbar in Odoo 18 POS
Celine George
 
Reconstruct, Restore, Reimagine: New Perspectives on Stoke Newington’s Histor...
History of Stoke Newington
 
SSHS-2025-PKLP_Quarter-1-Dr.-Kerby-Alvarez.pdf
AishahSangcopan1
 
CONCURSO DE POESIA “POETUFAS – PASSOS SUAVES PELO VERSO.pdf
Colégio Santa Teresinha
 
I AM MALALA The Girl Who Stood Up for Education and was Shot by the Taliban...
Beena E S
 
ARAL_Orientation_Day-2-Sessions_ARAL-Readung ARAL-Mathematics ARAL-Sciencev2.pdf
JoelVilloso1
 
Ad

Assembly Language Paper.docx

  • 1. Discussion: Assembly Language Paper Discussion: Assembly Language PaperORDER HERE FOR ORIGINAL, PLAGIARISM-FREE PAPERS ON Discussion: Assembly Language PaperAssembly language Please refer to slides and primer board lessons 1. A system is designed to monitor the temperature of a furnace. Temperature readings are recorded in 16 bits and stored in memory locations starting at XX60H. The highorder byte is stored first and the low-order byte is stored in the next consecutive memory location. However, the high-order Byte of all the temperature readings is constant. Write a program to transfer the low-order readings to consecutive memory locations starting at XX80H and discard the high-order bytes. Temperature Readings (H) 0581, 0595, 0578, 057A, 0598. 2. The temperatures of two furnaces are being monitored by a microcomputer. A set of five readings of the first furnace, recorded by five thermal sensors, is stored at the memory location starting at XX50H. A corresponding set of five readings from the second furnace is stored at the memory location starting at XX60H. Each reading from the first set is expected to be higher than the corresponding reading from the second set. For example, the temperature reading at the location 54H (T54) is expected to be higher than the temperature reading at the location 64H (T64).Discussion: Assembly Language PaperWrite a program to check whether each reading from the first set is higher than the corresponding reading from the second set. If all readings from the first set are higher than the corresponding readings from the second set, turn on the bit D0 of the output PORT1. If any one of the readings from the first set is lower than the corresponding reading of the second set, stop the process and output FF as an emergency signal to the output PORT1. 3. Specify the contents of the accumulator and the status of the Cy flag when the following instructions are executed a. MVI A,B7H ORA A RLC b. MVI A,B7H ORA A RAL 4. Calculate the decimal value of the number in the accumulator before and after the Rotate instructions are executed, and explain the mathematical functions performed by the instructions a. MVI A,18H RLC b. MVI A,78H RRC RRC 5. Explain the mathematical function that is performed by the following instructions MVI A,07H RLC MOV B,A RLC RLC ADD B 6. A set of eight readings is stored in memory starting at location XX50H. Write a program to check whether a byte of 40H exists in the set.Discussion: Assembly Language PaperIf it does, stop checking and display its memory location; otherwise output FFH. DATA(H) 48, 32, F2, 38, 37, 40, 82, 8A 7. The following program adds the number of bytes stored in memory locations starting from XX00H and saves the result in memory. Read the program and answer the questions given below LXI H,XX00H ;Set up HL as a data pointer LXI D,0000H ;set up D as a byte counter and E as a Carry register NEXT: ADD M ;Add byte JNC
  • 2. SKIP ;If the result has no carry, do not increment Carry register INR E SKIP: DCR D ;Update byte counter JNZ NEXT ;Go to the next byte LXI H,XX90H MOV M,A ;Save the result INX H MOV M,E HLT a. Assuming the byte counter is set up appropriately, specify the number of bytes that are added by the program. b. Specify the memory locations where the result is stored. c. Identify the two errors in this program.Discussion: Assembly Language PaperMicroprocessors and Assembly Language Microprocessors • Programmable devices, instructed to perform given tasks within its capability. • Designed to understand and execute many binary instructions • The engineers designing microprocessors determine a set of tasks the microprocessor should perform and design necessary logic circuits • They also provide user with a list of instructions the processor will understand. Von Neuman Architecture • Digital computers: • They are traditionally represented by five components: CPU, ALU plus control unit, memory, input and output • Organization of a Microprocessor based system: • CPU: the central processing unit. The group of circuits that processes data and provides control signals and timing. It includes the arithmetic/logic unit, registers, instruction decoder, and the control unit. • ALU: the group of circuits that perform arithmetic and logic operations. It is part of CPU. • Control unit: the group of circuits that provides timing and signals to all operations in the computer and controls data flow. • Register array: • used to store data temporarily during the execution of a program and are accessible to the user through instructions. • They are identified by letters such as B, C, D, E, H and L. • Input: a device that transfers information from the outside to the computer. • Output: a device that transfers information from the computer to the outside world. •Organization of a Microprocessor based system: • Memory: • stores binary information as instructions and data and provides them to the microprocessor whenever necessary. • To execute programs, the microprocessor reads instructions and data from memory and performs the computing operations in its ALU. Results are either transferred to the output section for display or stored in memory for later use. • ROM (read only memory) • is used to store programs that do not need alterations. E.g. the program that interprets info entered through keyboard and provides equivalent binary digits to microprocessor. • RAM (random access memory) • stores user programs and data • System Bus: • is a communication path between the microprocessor and peripherals. • it is nothing but a group of wires to carry bits. • Moore’s Law • Scale of Integration: • SSI (small scale integration)- the process of designing a few circuits on a single chip. e.g. discrete logic gates on a chip. • MSI ( medium scale integration) the process of designing more than a hundred gates on a single chip • LSI ( large scale integration) the process of designing more than a thousand gates on a single chip • Similarly VLSI (very large scale integration) and SLSI (super large scale integration) •Discussion: Assembly Language PaperHow does a microprocessor work? • • • • Fetch: an instruction from memory. Decode: interpret the instruction Execute: perform action repeat until comes across an instruction to stop. Microprocessor Instruction set • Machine language: • an 8-bit microprocessor can have 256 different words. • The designer selects combinations of bit patterns and gives a specific meaning to each combination by using electronic logic circuits.—-This is called an instruction • The 8085 machine language: • The 8085 has 74 different instructions. This is called the instruction set. • The binary language of the instruction set is called the machine language. • e.g. • 0011 1100 is an instruction to
  • 3. increment a register called the accumulator by 1 • 1000 0000 is an instruction that adds the number in register B to the number in the accumulator. and keeps the sum in the accumulator. • 8085 Assembly language: • Each manufacturer of a microprocessor has devised a symbolic code for each instruction, called a mnemonic • The mnemonic of the instruction set is called assembly language. • Examples: • binary code 0011 1100 (3CH) is represented by the mnemonic INR A •binary code 1000 0000 (80H) is represented by the mnemonic ADD B • Machine language and assembly language are microprocessor specific and are both considered low level languages. • Writing and Executing an Assembly language Program: • To manually write and execute an assembly language program on a single board computer, with a HEX keyboard for input and LEDs (light emitting diodes) for output : • Write the instructions in mnemonics obtained from instruction set of manufacturer. • Find the hexadecimal machine code for each instruction • Enter the program in user memory in sequential order by using the HEX keyboard • Execute the program by pressing the Execute key. • This is hand assembly. • An assembler is a program that translates an assembly language program to binary machine code. The 8085 Programming model • Registers: •8085 has six general-purpose registers to store 8-bit data. • These are identified as B, C, D, E, H, and L • They can be combined as register pairs – BC, DE and HL to perform 16-bit operations. • Accumulator: • 8-bit register that is used to store 8-bit data and perform arith. and logical operations. The result of the operation is stored in the accumulator. It is identified as A. • Flags: • ALU includes five flip flops, which are set or reset after an operation according to data conditions of the result • They are: • Z (zero flag): is set to 1 when the result is zero. • CY (carry): is set if an arithmetic operation results in a carry, o.w. reset. • S (sign): is set if most significant bit (D7) of the result is 1 • P (parity): is set if result has an even number of 1s, reset for odd number of 1s • AC (auxiliary carry): is set in an arithmetic operation if a carry is generated by digit D3 and passed to digit D4. It is used internally for BCD operations • Program Counter (PC): • 16-bit register to hold memory addresses. • It is used to sequence the execution of the instructions • It points to the memory address from which the next byte is fetched. • After the fetch, it is incremented by one • Stack pointer (SP): • 16-bit register used as memory pointer to a location the RAM called the stack. • The beginning of the stack is defined by loading a 16-bit address in SP. • Introduce the Primer board or Simulaoror Simulator• Each instruction has two parts: • The operation code (opcode): which is the task to be performed • The operand: which is the data to be operated on • Instructions can be: • 1-byte instructions: (opcode and operand in the same byte) • 2-byte instructions: (first byte is opcode, second byte is operand) • 3-byte instructions: ( first byte is opcode, the following two bytes specify the 16-bit address. The second byte is the low order address and the third byte is the high order address) • One- byte instructions • Two-byte instructions • Three-byte instructions • Some examples for primer • see handouts • use the Primer board or Simulaor in class to run these examples. • Lesson 2 Overview of the 8085 instruction set: • Data Transfer (Copy) instructions Data Transfer (copy) instructions • The data transfer instructions: • copy data from a source into a destination without modifying the contents of the source. • They do not affect flags • Examples: • MOV Rd,Rs copies data from source register Rs to destination register Rd • MVI R, 8-bit loads 8 bits of second byte into register • OUT 8-bit port address sends the contents
  • 4. of the accumulator A to the output port specified by the second byte • IN 8-bit port address accepts (reads) data from the input port specified by the second byte and loads into the accumulator A other instructions • HLT • The processor stops executing and enters wait state. •The address bus and data bus are placed in high impedance state. No registers are affected. • NOP • No operation • used to increase processing time or substitute in place of an instruction. • When an error occurs in a program and an instruction needs to be eliminated, it is more convenient to substitute NOP than to reassemble the whole program. Examples • Load accumulator A with 82H and save in register B • MVI A, 82H • MOV B, A • Read eight ON/OFF switches connected to input port with address 00H, and turn on devices connected to output port with address 01H • IN 00H • OUT • HLT 01H • If the switch positions has a pattern of 4FH, this will be placed on the data bus and transferred to Acc. The out instruction places this pattern on ON/OFF devices of output port. This will turn on devices connected to output port data lines D6, D3, D2, D1 and D0 Examples Addressing Modes • Immediate addressing • e.g. MVI R, data • Register addressing • e.g. MOV Rd, Rs • Direct addressing • e.g. IN/OUT port # • indirect addressing • will be discussed in ch7 Another example • Problem: load 37H in B and display the number at the output port labeled PORT1 MVI B, 37H MOV A, B OUT PORT1 HLT • from assembly language to machine language MVI B, 37H 06 37 MOV A, B 78 OUT PORT1 D3 01 HLT 76 • Lesson 3 Primer Arithmetic Operations • Examples: ADD, ADI, SUB, SUI .Discussion: Assembly Language PaperAssume implicitly that the accumulator is one of the operands • modify all flags according to data conditions of the result • place the result in the accumulator • do not affect the contents of the operand register • e.g ADD C add the contents of register C to contents of accumulator, set the flags accordingly. • Others: INR R , DCR R • affect the contents of the specified register • affect all flags except the CY flag • Lesson 4, 5 ( try INR R instead of ADD, see how it affects flags) Hex code for INR A = 3CH Addition • assume that A=93H, C=B7H • after ADD C instruction: • A=4AH, C =B7H, • flag status: S=0 (D7 is not 1), Z=0 (A is not 0), CY=1 • after ADI 35H • A= 7FH, • Flags: S=0, Z=0 , CY =0 • Now assume A=FFH • if ADI 01H will leave A=0, flags: S=0, Z=1, CY=1 • if INR A, A=00H, S=0, Z=1, CY=NA Subtraction • Subtraction is performed in 2’s complement. • The following steps are done internally: • convert subtrahend (# to be subtracted) into 2’s complement. • add it to contents of accumulator. • complement the carry flag. • Example: B= 65H, A=97H • SUB B • will result in A= 32H, S=0, Z=0, CY=0 Illustrative problem • Write a problem to: 1. load 30H in B, 39H in C 2. subtract 39H from 30H 3. display the answer at port1 – Program: MVI B, 30H MVI C, 39H MOV A, B SUB C OUT port1 HLT – result: A= F7, S=1, Z=0, CY=1 Logic Operations • Examples: • ANA R, logically ANDs the contents of R with A, CY reset, AC set • ANI 8-bit logically ANDs the second byte with the contents of accumulator, CY reset, AC set • ORA R, logically ORs the contents of R with A • ORI 8-bit, logically ORs the second byte with the contents of accumulator • XRA R, XORs the contents of R with A, AC, CY are reset • XRI 8-bit XORs the second byte with the contents of accumulator, AC, CY are reset • CMA complement accumulator, no flags affected Illustrative Program: data masking with logic AND • Problem statement: •to control appliances around the house • turn on air conditioner if switch S7 of the input port 00H is on. • ignore all other switches of the input port even if someone attempts to turn on other appliances. • Program: IN 00H ANI 80H; mask all bits except D7
  • 5. OUT 01H HLT OR, XOR, NOT • assume B= 93H, A= 15H • ORA B , will result in A=97H (verify), S=1, Z=0, CY=0 • XRA B, will result in A=86H (verify), S=1, Z=0, CY=0 • CMA, will result in A=EAH (verify), no flags modified Setting and resetting specific bits • Examples: • Keep the radio on (D4) continuously without affecting the functions of other appliances, even if someone turns off the switch S4. IN 00H ORI 10H, always set bit D4 • Turn off air conditioner (D7) without affecting other appliances. IN 00H ANI 7FH, always reset S7 • Lesson 12 Branch Operations • They allow the microprocessor to change the sequence of a program, either unconditionally or conditionally. • They are classified into three categories: • Jump instructions .Discussion: Assembly Language PaperCall and return instructions ( in subroutines ch 9) • restart instructions ( interrupt techniques ch 12) • JMP 16-bit, unconditional jump, the second and third bytes specify 16-bit memory address. The second byte specifies the low order and the third byte specifies the high order memory address • e.g. JMP 2000H, jump to memory location 2000H • machine code C3 00 20 Illustrative program: unconditional jump to set up a continuous loop • Problem statement: • read the switch positions continuously and turn on the appliances accordingly • Program: • mem. add. m/c code label mnemonics 2000 2001 2002 2003 2004 2005 2006 DB 00 D3 01 C3 00 20 START: IN 00H OUT 01H JMP START conditional jumps • They allow microprocessor to make decisions based on certain conditions indicated by the carry, zero, sign and parity flags • Two jump instructions are associated with each flag. • e.g. while adding the numbers you can change the program sequence either because the carry is present (JC= Jump on carry) or because the carry is absent (JNC= jump on no carry) conditional jump instructions • • • • • • • • JC JNC JZ JNZ JP JM JPE JPO 16-bit, jump on carry ( if CY=1) 16-bit, jump on no carry ( if CY=0) 16-bit, jump on zero ( if Z=1) 16-bit, jump on no zero ( if Z=0) 16-bit, jump on plus ( if D7=0 and S=0) 16-bit, jump on minus ( if D7=1 and S=1) 16-bit, jump on parity even ( if P=1) 16-bit, jump on parity odd ( if P=0) • Lesson 13 Illustrative Program: testing of the carry flag • problem statement: load the hexadecimal numbers 9BH and A7H in registers D and E, and add the numbers. If the sum is greater than FFH, display 01H at output port0; o.w. display the sum Illustrative Program: testing of the carry flag (cont.) • machine code with memory addresses: • Note we can use JC instruction instead of JNC, just change the order of the other instructions accordingly • Try this program as well. Writing assembly language programs • Read the problem carefully • Break it down into small steps. • Represent these small steps with a flow chart • Translate each block of the flow chart into appropriate mnemonic instructions • Translate mnemonic into machine code. •Discussion: Assembly Language Paper.Discussion: Assembly Language PaperEnter the machine code into memory and execute • Debug your program if necessary Counters • Add ten data bytes of data stored in memory locations starting at a given location and display the sum. • a counter to count 10 data bytes • an index or a memory pointer to locate where data bytes are stored • to transfer data from a memory location to ALU • to perform addition • registers for temporary storage of partial sum • a flag to indicate the completion of a task • to store or output the result. Additional data transfers and 16-bit arithmetic instructions • LXI Rp, 16 bit • 3 byte instruction • Rp is a register pair, it can be B, D and H to represent BC, DE, and HL registers respectively. • The second byte is loaded in the low order register of the register pair (e.g. register C, E, L) • the third byte is loaded in the high-order register
  • 6. pair. (e.g. register B, D and H) • LXI SP, 16 bit • loads stack pointer. Additional data transfers and 16-bit arithmetic instructions • Write instructions to load 16-bit number 2050 H in register pair HL using LXI and MVI opcodes. Data transfer from memory to microprocessor • MOV R, M • • • • 1 byte instruction copies data byte from memory location into a register the memory location is specified by the contents of the register pair HL This is indirect addressing mode; specification of memory location is indirect • LDAX B/D i.e. LDAX B, LDAX D • • • • • load accumulator indirect 1 byte instruction copies data byte from memory location into accumulator the memory location is specified by the contents of the register pair BC or DE This is indirect addressing mode • LDA 16-bit • load accumulator direct .Discussion: Assembly Language Paper3-byte instruction • copies data from memory location specified by 16-bit address in second and third byte • second byte is low order memory address • third byte is high order memory address • addressing mode is direct Example • the memory location 2050H holds the data byte F7H. Write instructions to transfer the data byte to the accumulator using three different opcodes: MOV, LDAX, and LDA • Indirect addressing mode takes four bytes and direct addressing mode takes three bytes. • The question is: Why not just use the direct addressing mode? • If only one byte is transferred LDA is more effici …