Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Explantation of assembly language code

Status
Not open for further replies.

rangerskm

Full Member level 4
Full Member level 4
Joined
Jan 23, 2013
Messages
199
Helped
0
Reputation
2
Reaction score
0
Trophy points
1,296
Visit site
Activity points
2,663
Code:
    list p=pic16f73
    #include "p16f73.inc"
    cblock 0x20
    r0,r1
    endc
    org 0x00
    movlw 0x03
    movwf r0
    movlw 0x00
    movwf r1
 x: Movlw 0x0a
    addwf r1,1
    decfsz r0,1
    goto x 
    goto $
    end

please explain the calculation with an example
 

Re: Please explain the below assembly language code in pic

Code:
LIST P=PIC16F73
#INCLUDE"P16F73.INC"
CBLOCK 0X20
 R0,R1,R2,R5
ENDC
          ORG 0X00
 	  MOVLW 0X06
 	  MOVWF R0
	  MOVWF R1
	  MOVWF R2
      MOVWF R5
      DECF R5,1
	  DECF R2,1
      DECF R1,1
	           CLRW
LOOP2:CALL MUL
      DECFSZ R2,1
      MOVF R2,W
      MOVWF R1
      CLRW
      DECFSZ R5,1
      GOTO LOOP2
      GOTO L1

     
MUL:
     ADDWF R0,0
     DECFSZ R1,1
     GOTO MUL
     MOVWF R0
     RETURN
    
 L1:NOP    
 END

it will be thank full if you helped with me with some more problems
 

Re: Please explain the below assembly language code in pic

Why create pdfs for reply instead of simply typing the reply here?

Keith
 

Re: Please explain the below assembly language code in pic

hi nishanth,

thanks for your effort for helping me.some more problems has to be solved .i will be posting one by one .

- - - Updated - - -

code 3
Code:
LIST P=PIC16F73
#INCLUDE"P16F73.INC"

CBLOCK 0X20
INDEX,R0,R1,TEMP1,TEMP2,TEMP3
ENDC

ORG 0X00
MOVLW 0X00
MOVWF INDEX
MOVLW 0X30
MOVWF FSR
MOVLW 0X0A
MOVWF R0
MOVWF R1
CLRW 

AGAIN:CALL TKE
MOVWF INDF
INCF FSR,1
DECFSZ R0,1
GOTO AGAIN
GOTO LAST





TKE:MOVF INDEX ,W
   INCF INDEX,1
   ADDWF PCL,1
   DT 8,5,4,1,3,10,7,2,9,6


	LAST:MOVLW 0X30
         MOVWF FSR
         MOVLW 0X0A
         MOVWF R0
  AGAIN1:DECFSZ R0,1
         GOTO AGAIN2
         GOTO LAST1
AGAIN2:  MOVF INDF,W
         MOVWF TEMP1
         INCF FSR,1
         MOVF FSR,0
         MOVWF TEMP3
         MOVF INDF,W
         MOVWF TEMP2
         SUBWF TEMP1,0
         BTFSC STATUS,0
         GOTO AGAIN1

        MOVF TEMP1,W
        MOVWF INDF
        MOVF TEMP2,W
        DECF FSR,1
        MOVWF INDF
        MOVF TEMP3,W
        MOVWF FSR
        GOTO AGAIN1 

LAST1:DECFSZ R1,1
GOTO LAST
GOTO $



END

explain with an example

- - - Updated - - -

code 4
Code:
    LIST P=PIC16F73
	#INCLUDE "P16F73.INC"
	 
	CBLOCK 0X20
	R1,R2,R0,R3,R4
	ENDC
	
	ORG 0X00
	BSF STATUS,5
	CLRF TRISC
	BCF STATUS,5
    MOVLW 0XFF
    MOVWF R4
    CLRW
AGAIN:	MOVLW 0X01
		MOVWF R0
		MOVWF PORTC
LOOP	CALL DEL
		RLF R0,1
		MOVF R0,W 
		MOVWF PORTC
    	
        BTFSC R0,7
        GOTO AGAIN
        GOTO LOOP	
	DEL:CLRW
		MOVLW 0XAA
		MOVWF R1
	L1:	CLRW
		MOVLW 0XFF
	    MOVWF R2
	 L2:DECFSZ R2,1
		GOTO L2
		DECFSZ R1,1
	    GOTO L1		
	    RETURN
	    END

- - - Updated - - -

code 5
Code:
LIST P=PIC16F73
#INCLUDE"P16F73.INC"
CBLOCK 0X20
 R0,R1,R2,R3,R4,PRIME
 ENDC
 ORG 0X00
    MOVLW 0X18
    MOVWF STATUS
    MOVLW 0X09
    MOVWF R1
    MOVWF R3
    MOVWF R2
   ; DEC 2
    MOVLW 0X01
    MOVWF R0
AGAIN:INCF R0,1
      MOVF R0,W
      SUBWF R2,0
      BTFSC STATUS,2
      GOTO LAST
      CLRW
      MOVF R3,W
      MOVWF R1
     



DIV:NOP
LOOP:MOVF R0,W
     SUBWF R1,1
     BTFSC STATUS,0
     INCF R4,1
     BTFSC STATUS,0
     GOTO LOOP
     ADDWF R1,1
     CLRW
     MOVF R1,W
     BTFSS STATUS ,2
     GOTO AGAIN
     GOTO LAS
LAST:MOVLW 0X01
     MOVWF PRIME
     GOTO $
LAS: CLRF PRIME
     GOTO $
END
 

Re: Please explain the below assembly language code in pic

Is pdfs create any problem ???
 

Re: Please explain the below assembly language code in pic

No problem in it.its clear to read
 

Re: Please explain the below assembly language code in pic

It is a problem for some people. If means that instead of simply browsing the forum and reading it you need to download a pdf and have a pdf reader. Quite a few people (myself included) use mobile phones for browsing the forum.

It also makes interaction with the reply more difficult as people cannot use the forum features such as quoting without manually cutting and pasting parts from a pdf and manually inserting it into the reply.

Keith
 

Re: Please explain the below assembly language code in pic

Explanation for code 4:

output of the code at port c:

0000 0001

Delay

1000 0000

delay

0100 0000

delay

0010 0000

delay

0001 0000

delay

0000 1000

delay

0000 0100

delay

0000 0010

delay

0000 0001

delay

.....

the code will be executing the above operation infinite times.
 

Re: Please explain the below assembly language code in pic

i am not able to understand the logic in the below code
this code is for HEX to DEC convertion
Code:
LIST P=PIC16F73
#INCLUDE"P16F73.INC"
CBLOCK 0X20
R1
R2
H1
H2
H0
ENDC
ORG 00H
MOVLW 0X0F
MOVWF R1
MOVLW 0X64
CALL DIV
MOVF R2,W
MOVWF H2
MOVLW 0X64
CALL L3
MOVLW 0X0A
CALL DIV
MOVF R2,W
MOVWF H1
MOVLW 0X0A
CALL L3
MOVF R1,W
MOVWF H0
GOTO L4
DIV: NOP
L1: INCF R2
SUBWF R1,1
BTFSC STATUS,0
GOTO L1
DECF R2
RETURN
L3: ADDWF R1,1
CLRF R2
RETURN
L4: NOP
END
 

Re: Please explain the below assembly language code in pic

That code snippets seem to be lacking proper labelling, are you dissassembling code from a high level language? (and if so... why?)

Brian.
 

Re: Please explain the below assembly language code in pic

That code snippets seem to be lacking proper labelling, are you dissassembling code from a high level language? (and if so... why?)

Brian.

Hi,

Agree with Betwixt, you seem to be making things so difficult for yourself by using such code examples from whatever source.

There are masses of good tutorials out there for programming in Assembly or C.

If you tell us what you are trying to do I am sure one of us can help you get going a lot easier than the confusing methods you are currently struggling with.
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top