Assembly Language
Using CodeWarrior to create a new project that uses assembly language. Write an assembly program that turns on the red LED at the beginning. It switches to off 2 seconds later and switches back to on after three more seconds. (That is, it stays on for 2 seconds and off for 3 seconds.) This switching process lasts forever. Use a loop (or nested loops) for each of the 2/3-second delay where the loop body of the inner-most loop should contain only multiple instances of the NOP instruction. Use trial-and-error in adjusting the loop iterations to achieve the delay. Write down instructions in the (nested) loops of your program, identify the number of clock cycles needed for each instruction in the loops, and calculate the total number of cycles to get the amount of delay. Use that information to calculate the clock speed of the CPU in MHz, given that the clock speed is an integer in MHz.
Hint: You may use the DBNE instruction for the loop control. In order to find out the number of clock cycles for a particular HCS12 CPU instruction, you may either get it from the data sheet or use the Full Chip Simulation in CodeWarrior, in case you have trouble determining the proper machine code version from the data sheet.
int ledPin1 = 5; // the number of the LED pin
int ledState1 = LOW; // ledState used to set the LED
unsigned long previousMillis1 = 0; // will store last time LED was
updated
long OnTime1 = 2000; // milliseconds of on-time
long OffTime1 = 2000; // milliseconds of off-time
int ledPin2 = 6; // the number of the LED pin
int ledState2 = LOW; // ledState used to set the LED
unsigned long previousMillis2 = 0; // will store last time LED was
updated
long OnTime2 = 5000; // milliseconds of on-time
long OffTime2 = 1000; // milliseconds of off-time
void setup()
{
// set the digital pin as output:
pinMode(ledPin1, OUTPUT);
pinMode(ledPin2, OUTPUT);
}
void loop()
{
// check to see if it's time to change the state of the LED
unsigned long currentMillis = millis();
if((ledState1 == HIGH) && (currentMillis -
previousMillis1 >= OnTime1))
{
ledState1 = LOW; // Turn it off
previousMillis1 = currentMillis; // Remember the
time
digitalWrite(ledPin1, ledState1); // Update the actual
LED
}
else if ((ledState1 == LOW) && (currentMillis -
previousMillis1 >= OffTime1))
{
ledState1 = HIGH; // turn it on
previousMillis1 = currentMillis; // Remember the
time
digitalWrite(ledPin1, ledState1); //
Update the actual LED
}
if((ledState2 == HIGH) && (currentMillis -
previousMillis2 >= OnTime2))
{
ledState2 = LOW; // Turn it off
previousMillis2 = currentMillis; // Remember the
time
digitalWrite(ledPin2, ledState2); // Update the actual
LED
}
else if ((ledState2 == LOW) && (currentMillis -
previousMillis2 >= OffTime2))
{
ledState2 = HIGH; // turn it on
previousMillis2 = currentMillis; // Remember the
time
digitalWrite(ledPin2, ledState2); //
Update the actual LED
}
}
Assembly Language Using CodeWarrior to create a new project that uses assembly language. Write an assembly...
Use HCS12 assembly language only - not C code Using CodeWarrior to create a new project that uses assembly language. Write an assembly program that turns on the red LED at the beginning. It switches to off 2 seconds later and switches back to on after three more seconds. (That is, it stays on for 2 seconds and off for 3 seconds.) This switching process lasts forever. Use a loop (or nested loops) for each of the 2/3-second delay where...
Assume the memory display of the HCS12 shows 16 bytes starting at S0800 as follows SOBO0 80 53 05 28 36 89 00 FF FE 80 91 3E 77 AB 8F 7F Cavt the results of the following instructions SP S0805 pula A ?, SP SP S08OAL pula pshb A 7, SP -? SP S0805 pula A ? pulb B Idaa $O803 Idab $0804 aba A 7,8- SP $0805 psha pshb SP 7 Idx S0800 idab $0807 leax B.X X...
Design and implement a C Language program that measures the
performance of given processors.
There are several metrics that measure the performance of a
processor. We will be using the following 3 measures:
1.CPI (clock cycles per instruction) = #clock cycles
/#instructions
2.CPU execution time = #instructions x CPI x clock cycle time
.
cylce time = 1/CPU clock rate in hertz units
3.MIPS (mega instructions per second)= #instrucrions/ CPU X
1000000
Typically, processors’ performance is measured using a wide...
Consider the following assembly language code. The clock frequency is 4 MHz- and all initialization steps have been done correctly (like setting up digital I/O, the oscillator configuration, etc.) Constants Bit Pattern EQU H'20' LoopCtr EQU H'21' Max Count EQU .23; Main program loop MainLoop CLRF BitPattern CALL Output BSF BitPattern, 1 CALL Output RRF BitPattern CALL Output BSF BitPattern, 1 CALL Output GOTO MainLoop Output MOVF BitPattern, W MOVWF PORTB MOVLW MaxCount MOVWF LoopCtr Loop NOP DECFSZ LoopCtr GOTO...
Can someone please help me with this problem? We are using
CodeWarrior to write this program in assembly language.
The array sample contains eight 8-bit signed binary numbers (integers) as shown below. Write a program which stores the negative numbers in the array nelements, computes the sum of the positive numbens to be stored in the variable psum and stores the number of the positive numbers in the variable pnumber. Note that a zero is ther positive nor negative. Your...
Step 1. Write a program in assembly language (using macros) to print out the following messages on the screen [20 marks]: Hello, programmers! Welcome to the world of, Linux assembly programming! Step 2. Write a C function to passed two numbers to the function and calculate the sum of all the numbers between them (both inclusive). [50 marks] a. Make a version with for loop b. Make a version with while loop c. Make a version with do.. while loop...
Solve using C language
The mathematician Euler proved that: tan-(x) = x -. Write a C program to do the following: -Ask user to enter the value of (x) radians, -0.5<=x<=0.5. -Calculate and print the actual value atan (x)in degrees. - Use loops to calculate and print the series sum in degrees. -loop should stop when absolute difference between actual and series sum become <=10-3. -Print out number of iterations needed to get the result. - The program should run...
Write a simple program in arm, assembly language , using only
Registers, to test if 371 is an Armstrong number. The program
written should only have instruction set from the Cortex m0+. And
then put a 1 in a register to show it
It is, or 0 if it isn’t.
The second program is about the Armstrong numbers. You assume it will be a 3-digit number which will be entered through the data area. You can use a register so...
4) Consider the following assembly language code: INSTRUCTIONS T01 T02 T03 T04 T05 T06 T07 T08 T09 T10 T11 T12 T13 T14 (as a table) Loop: sll $t1, $s3, 2 add $t1, $t1, $s6 lw $t0, 0($t1) beq $t0, $s5, Exit addi $s3, $s3, 1 j Loop Exit: Use a pipeline with forwarding, hazard detection, and 1 delay slot for branches. The pipeline is the typical 5-stage IF, ID, EX, MEM, WB MIPS design. For the above code, complete the...
Step 1: Create a new ASSEMBLY project using Keil Software (1) Make sure you use the M3 option Step 2: “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....