Question

Assembly using "Atmel" : 1- Write a program that counts from 0 to 255 and show...

Assembly using "Atmel" :

1- Write a program that counts from 0 to 255 and show the result on PORTD (shown on 8 LEDs).

2- Write a program that adds two numbers and show their sum on PORTD.

Homework Answers

Answer #1

1.

int LPins[] = {2,3,4,5,6,7,8,9};

void setup()
{
for(int i = 0; i < 8; i++)
{   
pinMode(LPins[i],OUTPUT);
}   
}
void loop()   
{
for (int i=0; i<256; i++)
{
showBinNumber(i);
delay(256-i);
}
}

void showBinNumber(int num) {
for (int i=0; i<8; i++) {
if (num%2)
digitalWrite(LPins[i], HIGH);
else
digitalWrite(LPins[i], LOW);
num/=2;
}
}

2.

# Number 1
LDI R16 0x…
LDI R17 0x…
LDI R18 0x…
LDI R19 0x…
# Number 2
LDI R20 0x…
LDI R21 0x…
LDI R22 0x…
LDI R23 0x…
# Add LSB of 1 and 2, result will be in R20
ADD R20,R16
# Add remaining bytes using the add-with-carry operation
ADC R21,R17
ADC R22,R18
ADC R23,R19 # MSB


Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write a program to count number between 0 and 255 in binary using 8 LEDs connected...
Write a program to count number between 0 and 255 in binary using 8 LEDs connected to the Arduino. This code should start at 0 and loop back to 0 once it counts to 255. Delay 0.25s between counts.
1. Open “Atmel Studio” and write an assembly program to count up from 0 to 9...
1. Open “Atmel Studio” and write an assembly program to count up from 0 to 9 and show the result on a CC seven segment.
Using for loops: - write a Java program that adds numbers between 1 to 100 and...
Using for loops: - write a Java program that adds numbers between 1 to 100 and prints the result. - write a Java program that adds odd numbers between 1 to 100 and prints the result - write a Java program that averages even numbers between 5 to 30 and prints the result
Write an assembly code for a M68CH12 microcontroller that counts from 0000-9999 using even numbers on...
Write an assembly code for a M68CH12 microcontroller that counts from 0000-9999 using even numbers on the seven segment display.
Write an 8088/8086 assembly program that counts the length of a null terminated string that starts...
Write an 8088/8086 assembly program that counts the length of a null terminated string that starts at location STR. Print the result on the screen.
Using Windows 32 framework , write an assembly language program; Write a recursive procedure to find...
Using Windows 32 framework , write an assembly language program; Write a recursive procedure to find the greatest common divisor of two non negative numbers. You should use Euclidean algorithm and this is typically discussed in CSC 230. Your procedure: ❼ Needs to follow cdecl protocol. ❼ Needs to take two parameters. ❼ Should return -1, if the parameters are negative. ❼ Should return gcd, if the parameters are non negative. Your main procedure should do the followings. ❼ Read...
Write an ARM assembly language program that counts the number of 1’s for any value in...
Write an ARM assembly language program that counts the number of 1’s for any value in R0. The program must assemble/compile in KEIL and must be able to run in the KEIL simulator. Generally, R0 may contain any value, but for purpose of this exercise, you may move 0x2345ABCD into R0. The number in R0 does not need be preserved. You may use any other registers as you need. The result, total count of 1’s in R0, should be in...
3) Write a program to print out a random number from 1..100. USING ASSEMBLY LANGUAGE
3) Write a program to print out a random number from 1..100. USING ASSEMBLY LANGUAGE
Write a Hack Assembly Language program to calculate the quotient from a division operation. The values...
Write a Hack Assembly Language program to calculate the quotient from a division operation. The values of dividend a and divisor b are stored in RAM[0] (R0) and RAM[1] (R1), respectively. The dividend a is a non-negative integer, and the divisor b is a positive integer. Store the quotient in RAM[2] (R2). Ignore the remainder. Example: if you are given two numbers 15 and 4 as dividend a (R0) and divisor b (R1), respectively, the answer will be 3 stored...
Write a NASM program that does the following: 1) Asks the user to enter three numbers...
Write a NASM program that does the following: 1) Asks the user to enter three numbers (each is a byte) A,B, and C 2) Adds up the numbers and stores the sum in variable D 3) Outputs the sum