Question

In: Electrical Engineering

Write an assembly language program for 8051 microcontroller to find the sum of the following series,...

Write an assembly language program for 8051 microcontroller to find the sum of the following

series,

1, -2, +3, -4, +5, -6,..., up to 100 terms.

Store lower byte in R0 and higher byte in R1.

Solutions

Expert Solution

                  // In the sereis all even numbers are negive and odd numbers are positive
                
                  ORG 000h
                  MOV R1,#64H       //Enter the final number of Series
                  MOV A,#00H        //Initilize the Accumulator with zero
         AGAIN:   MOV R0,R1         // Copy the contenets of R1 to R0
                  RRC R0            //Rotate R0 once to right if carry is zero then it is even number else odd number
                  JNC EVEN_Number   //if carry is not set then even nuber and jump to EVEN_Number location
                  JC ODD_Number     //if carry is set then odd nuber and jump to ODD_Number location
   EVEN_Number:   CPL R0            //ones complement R0
                  ADD R0, #01H      //Add one to complemented number
   ODD_Number:    ADD A,R0          //Add Ro to Acummulator
                  DJNZ R1, AGAIN    //Decrement R1 if not zero jumber AGAIN location else continue
                  MOV R2,A          //Move the final ansuer from Acummulator to R2
                  END               // End the program


Related Solutions

write a assembly language program to convert GRAY to BCD code in 8051
write a assembly language program to convert GRAY to BCD code in 8051
Write an 8051-assembly language program for the interfacing of ADC0804 and LM35 to display the room...
Write an 8051-assembly language program for the interfacing of ADC0804 and LM35 to display the room temperature on 16x2 LCD (10marks) please note that the program should be interfacing with ADC0804.
Describe the types and differences in the assembly instructions of 8051 microcontroller
Describe the types and differences in the assembly instructions of 8051 microcontroller
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code...
write a program for the microcontroller-msp430fr6989 using code composer studio not assembly language. write a code that transmits a single character and lights the red LED upon receiving that character. The board will "talk" to itself. The green LED should turn on whenever a message is sent and the LCD will display the message being received.
Write a MIPS assembly language program to find the addition of two arrays
Write a MIPS assembly language program to find the addition of two arrays
Write an X86-series assembly language program that checks whether input string is palindrome or not. A...
Write an X86-series assembly language program that checks whether input string is palindrome or not. A palindrome is a word, number, phrase or any other sequence which reads the same backward as forward e.g. madam, racecar. Sample Execution: Please enter a String: redivider The string is a palindrome Another Sample Execution: Please enter a String: abracadabra The string is not a palindrome
Write a code of digital alarm clock 8051 microcontroller using pin AT89S52
Write a code of digital alarm clock 8051 microcontroller using pin AT89S52
Write a MIPS assembly program that calculates the sum of all the elements in the following...
Write a MIPS assembly program that calculates the sum of all the elements in the following array: int array[10]={12,21,3,40,15,6,17,8,29,10}
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE...
Q1: A. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO EXCHANGE 16-BIT NUMBERS B. WRITE AN ASSEMBLY LANGUAGE PROGRAM TO SOLVE THE EQUATION Z=A+B-(C/D)+E please write the answer separately part A its own code and part B its own code this is microprocessor the ASSEMBLY LANGUAGE emu8086 should be written like this EX: mov ax,100h mov bx,200h etc
1. Write a program that does the following. Write in Assembly Language program Loads your student...
1. Write a program that does the following. Write in Assembly Language program Loads your student ID number into memory starting at location 0x2000 0100 a. DO NOT do any conversion on your ID number. If my ID number is 123456789, I should be able to read your ID in memory as 123456789 2. Loads the first six characters of your name, in ASSIC, in to memory right after your student ID. Total of 6 bytes. a. This means that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT