Sie sind auf Seite 1von 6

8 BIT ARITHMETIC OPERATIONS

Aim: To perform 8 bit arithmetic operations like addition, subtraction, multiplication and division using 8085 micro processor. Apparatus required: 8085 microprocessor kit and power supply 8 BIT ADDITION "nitiali#e $% register pair with a memory pointer. Transfer the addend from the memory location to accumulator. "ncrement memory pointer Add the contents of memory location )augend* to accumulator )addend*. "ncrement memory pointer and store the sum +lear the accumulator and add accumulator with carry. "ncrement the memory pointer and store the carry Ma "i!e ode & ,00,(& ./ &' 84 &' .. '/, 00 87 &' .. .4 La#e$ M!emo!i s %-" $, (&00 012 A, 0 "3- $ A55 0 "3- $ 012 0, A 02" A, 00 A5+ A "3- $ 012 0, A $%T Comme!t "nitiali#e $% register pair with a memory pointer Transfer the memory contents to accumulator "ncrement memory pointer Add the contents of memory pointer to accumulator "ncrement memory pointer Transfer the %S6 of the sum to memory location +lear accumulator Add accumulator with accumulator with carry "ncrement memory pointer Transfer 0S6 of the sum to memory location /nd e8ecution

Step ! Step &! Step '! Step(! Step '! Step (! Step 5! ,rogram! Memory Lo atio! ( 00 ( 0' ( 0( ( 05 ( 04 ( 0. ( 08 ( 0A ( 06 ( 0+ ( 05

Sample input and output! Addend 9(&00: Augend 9(&0 : %S6 of the Sum 9(&0&: 0S6 of the sum 9(&0':

8 BIT S%BTRACTION Step ! Step &! Step '! Step(! Step '! Step (! Step 5! Pro&ram: Memory Lo atio! ( 00 ( 0' ( 0( ( 05 ( 04 ( 0. ( 08 ( 0A ( 06 ( 0+ ( 05 Ma "i!e ode & ,00,(& ./ &' ;4 &' .. '/, 00 87 &' .. .4 La#e$ M!emo!i s %-" $, (&00 012 A, 0 "3- $ S<6 0 "3- $ 012 0, A 02" A, 00 A5+ A "3- $ 012 0, A $%T Comme!t "nitiali#e $% register pair with a memory pointer Transfer the memory contents to accumulator "ncrement memory pointer Subtract the contents of memory pointer from accumulator "ncrement memory pointer Transfer the sum to memory location +lear accumulator Add Accumulator with accumulator with carry "ncrement memory pointer Transfer borrow to memory location /nd "nitiali#e $% register pair with a memory pointer. Transfer the minuend from the memory location to accumulator. "ncrement memory pointer subtract the contents of memory location )subtrahend* from accumulator )minuend*. "ncrement memory pointer and store the difference. +lear the accumulator and add accumulator with carry. "ncrement the memory pointer and store the borrow

Sample input and output 0inuend 9(&00: Subtrahend 9(&0 : 5ifference 9(&0&: 6orrow 9(&0':

8 BIT M%LTIPLICATION Step ! Step &! Step '! Step (! Step 5! Step 4! Step .! Step 8! Memory Lo atio! ( 00 ( 0' ( 05 ( 04 ( 0. ( 08 ( 0; ( 0+ ( 05 ( ( ( ( ( ( ( ( 0 & 5 4 . 8 ; "nitiali#e $% register pair with a memory pointer. +lear the accumulator and register + =et the multiplicand to register 6. "f it is #ero go to step 8. "ncrement the memory pointer Add accumulator with the contents of memory pointer ) i.e., multiplier* "f addition generates a carry increment register +. 5ecrement register 6. "f it does not result #ero go to step 5. Store the contents of accumulator )%S6 of the product* and the contents of + register ) 0S6 of the product* in successive memory locations. Ma "i!e ode & ,00,(& '/, 00 (7 (4 &' 68 +A, 5 , ( 84 5&, 0+ 05 +&, 0+,( &' .. &' . .4 %11, ,( La#e$ M!emo!i s %-" $, (&00 02" A, 00 012 +, A 012 6, 0 Comme!t "nitiali#e $% register pair with a memory pointer

+lear accumulator +lear + register =et the multiplicand to register 6 "3- $ "ncrement memory pointer +0, 6 +ompare the multiplicand with #ero >? %11,' "f multiplicand is #ero @ump to %11,' %11,& A55 0 >3+ "3A + 5+A 6 >3? %11, & %11,' "3- $ 012 0, A "3- $ 012 0, + $%T %11, Add accumulator contents with memory contents "f the addition does not generate a carry @ump to %11, "f carry results increment + register 5ecrement register 6 "f no #ero @ump to %11,& "ncrement memory pointer 0ove the contents of accumulator to memory location "ncrement memory pointer 0ove contents of + register to memory location /nd e8ecution

Sample input and output 0ultiplicand 9(&00: 0ultiplier 9(&0 : ,roduct %S6 9(&0&: 0S6 9(&0':

Step ! Step &! Step '! Step (! Step 5 Step 4! Step .! Step 8! Step ;! Step 0! Memory Lo atio! ( 00 ( 0' ( ( ( ( 05 04 0. 08

8 BIT DI'ISION "nitiali#e $% register pair with a memory pointer. +lear register +. =et the dividend to accumulator and divider to register 6. "f dividend is #ero, set the Buotient and remainder as #ero, store in successive memory locations and end the program. "f divider is #ero, set the Buotient and remainder as //, store in successive memory locations and end the program. /lse move the dividend to accumulator and divider to register 6. Subtract the contents of register 6 from accumulator. "f carry sets, go to step;, else increment + register and go to step . Add the contents of register 6 to accumulator to get the remainder. Store Buotient and remainder in successive memory locations Ma "i!e ode & ,00,(& 0/, 00 ./ &' (4 7/, 00 +A, &. , ( .8 7/, 00 +A, &/, ( & , 00 ,(& ./ &' (4 La#e$ M!emo!i s %-" $, (&00 02" +, 00 012 A, 0 "3- $ 012 6, 0 +,", 00 >? %11, Comme!t "nitiali#e $% register pair with a memory pointer +lear + register )Buotient register* =et dividend to accumulator "ncrement memory pointer =et the divider to 6 register +ompare the dividend with #ero "f dividend is #ero @ump to %11, 0ove divider to accumulator +ompare the divider with #ero "f divider is #ero @ump to %11,& "nitiali#e memory pointer =et dividend to accumulator "ncrement memory pointer =et the divider to 6 register

( 0A ( 05 ( 0/ ( ( ( ( ( 0 ' 4 . 8

012 A, 6 +,", 00 >? %11,&

%-" $, (&00 012 A, 0 "3$ 012 6, 0

;0 5A, & ,( 1+ +', ;, ( 80 &' . &' .. .4 &' '4, 00 &' '4, 00 .4 &' '4, // &' '4, // .4

%11,( S<6

( A ( 5 ( / ( & ( && ( &' ( &( ( &5 ( &4 ( &. ( &8 ( &A ( &6 ( &5 ( &/ ( &7 ( ' ( '& ( &5

>+ %11, ' "3A + >0, %11,( %11,' A55 6 "3- $ 012 0,

"3- $ 012 0 , A %11, $%T "3- $ 02" 0, 00 "3- $ 02" 0, 00 $%T %11,& "3- $ 02" 0, // "3- $ 02" 0, // $%T

Subtract the divider from the dividend "f carry sets @ump to %11,' "ncrement Buotient register Aepeat subtraction Add the contents of 6 to accumulator to get the Buotient "ncrement memory pointer Store Buotient in memory location "ncrement memory pointer Store remainder in memory location /nd e8ecution "ncrement memory pointer Store #ero in memory location "ncrement memory pointer Store #ero in memory location /nd e8ecution "ncrement memory pointer Store // in memory location "ncrement memory pointer Store // in memory location /nd e8ecution

Sample input and output 5ividend 9(&00: 5ivider 9(&0 : Cuotient 9(&0&: Aemainder 9(&0':

Aesult! The assembly language programs to perform 8Dbit addition, subtraction, multiplication and division are written and e8ecuted. (uestio!s a!d A!s)ers . Ehat is the clock freBuency of 8085F

&. '. (. 5.

Ehat is the function of program counterF Ehat are the general purpose registers in 8085F Ehat is the function of A%/ signal in 8085F Ehat is meant by demultiple8ing of address busF

E*er ise . Erite a program to add the following data bytes stored in memory locations starting at --40$ and display the sum in the location --80$ if the sum does not generate a carry. "f a result generates a carry, stop the addition, and display 0 $ in the location --80$. A set of eight data bytes are stored in memory locations starting from --.0$. Erite a program to add two data bytes at a time and store the sum in the same memory locations, low order sum replacing the first byte and a carry replacing the second byte. "f any pair does not generate a carry, the memory location of the second byte should be cleared. A set of eight data bytes are stored in memory locations starting from --.0$. Erite a program to subtract two data bytes at a time and store the result in a seBuential order in memory location starting from --.0$

&.

'.

Das könnte Ihnen auch gefallen