Write an assembly program to find the number of ones in


Question 1:. Find the duration of the delay of each of the code segments below if the crystal frequency is 16 MHz.

(a)

 

(b)

 

COUNTER EQU 0x40

 

COUNTER1 EQU 0x40

 

COUNT EQU OxAD

 

COUNTER2 EQU 0x41

 

 

 

COUNT1 EQU OxAD

 

DELAY MOVLW COUNT

 

COUNT2 EQU Ox7E

 

MOVWF COUNTER

 

 

 

AGAIN NOP

 

DELAY MOVLW COUNT1

 

NOP

 

MOVWF COUNTER1

 

NOP

 

LOOP1 MOVLW COUNT2

 

DECF COUNTER, BNZ AGAIN

F

MOVWF COUNTER2 LOOP2 NOP

 

RETURN

 

NOP

 

 

 

NOP

 

 

 

DECF COUNTER2,

BNZ LOOP2

F

 

 

DECF COUNTER1,

BNZ LOOP1

F

 

 

RETURN

 

Question 2. What are the values of pons C and ID at the end of each of the following ro

(a)

 

(b)

 

ORG Ox10

 

ORG Ox10

 

CLRF TRISC

 

MOVLW 0x14

 

CLRF TRISD

 

MULLW 0x19

 

MOVLW Ox80

 

MULLW OxIE

 

MOVWF PORTC MOVLW OxAS MOVWF PORTD

 

MOVFF PRODL, MOVFF PRODH, END

PORTC
PORTD

REPEAT RACE PORTC,

F

 

 

BTG PORTD, 5

 

 

 

BTFSS PORTC,

3

 

 

BRA REPEAT

 

 

 

HERE    GOTO HERE

 

 

 

END

 

 

 

Question 3. Three LEDs are connected to pins 5 to 7 of port C. Write an Assembly program that will add 10 values that it receives through port B one value at a time. Once the sum of the values reaches or exceeds 0'100', one LED should turn on. Once the sum reaches or exceeds D'150', two LEDs should turn on. Finally, when the sum reaches or exceeds D'200', all LEDs should turn on. Verify the operation of your programs using MPLAB simulator. Include printout of the list file and file registers after execution.

Question 4. Write an Assembly program to find the number of ones in file register location 10H. Verify the operation of your programs using MPLAB simulator. Include printout of the list file and file registers after execution.

Question 5. Write a NOS Assembly program that will read 30 values through port B one value at a time. The first 10 values should be stored in addresses 50H to 59H, the second 10 values in addresses 60H to 69H, and the last 10 values in addresses 70H to 79H. Verify the operation of your programs using MPLAB simulator. Include printout of the list file and file registers after execution.

Request for Solution File

Ask an Expert for Answer!!
Electrical Engineering: Write an assembly program to find the number of ones in
Reference No:- TGS0928586

Expected delivery within 24 Hours