Jump to content
ELFORUM - Forumul electronistilor

Recommended Posts

  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Top Posters In This Topic

Va rog frumos sa-mi spuneti ce mai trebuie facut la codul din asembler, cel din c merge...De cateva zile m-am apucat de asembler si as vrea sa invat..

C:

#include<htc.h>
unsigned char Ra@0x20,Rb@0x21,Rc@0x22,Rmij@0x23,Rmax@0x24,Rmin@0x25;
void main(void)
{
    Ra=70;Rb=50;Rc=30;
    
  if(Ra>Rb)
  {
     Rmij=Ra;
     Rmin=Rb;
  }else{
      Rmij=Rb;
      Rmin=Ra;
    }
  if(Rmij>Rc)
  {
   Rmax=Rmij;
  if(Rmin>Rc){
  Rmij=Rmin;
  Rmin=Rc;
  }else{Rmij=Rc;}
  }else Rmax=Rc;
  asm("NOP");
}


asm:

#include p16f84.inc
Ra equ 0x20
Rb equ 0x21
Rc equ 0x22
Rmin equ 0x23
Rmij equ 0x24
Rmax equ 0x25
main:MOVLW D'70'
     MOVWF Ra
     MOVLW D'50'
     MOVWF Rb
     MOVLW D'30'
     MOVWF Rc
     MOVF Ra,0
     SUBWF Rb,0
     BTFSC STATUS,C
     GOTO else1
if1:MOVF Ra,0
    MOVWF Rmij
    MOVF Rb,0
    MOVWF Rmin
else1:MOVF Rb,0
      MOVWF Rmij
      MOVF Ra,0
      MOVWF Rmin
      MOVF Rmij,0
      SUBWF Rc,0
      BTFSC STATUS,C
      GOTO if3
 if2:MOVF Rmij,0
     MOVWF Rmax
  if3:MOVF Rmin,0
      SUBWF Rc,0
   BTFSC STATUS,C
   GOTO else2
if4:MOVF Rmin,0
    MOVWF Rmij
    MOVF Rc,0
    MOVWF Rmin
else2:MOVF Rc,0
      MOVWF Rmij
  BTFSC STATUS,C
GOTO end1
   MOVF Rmax,0
   MOVWF Rc
end1:NOP
end

 

Edited by ratza
Cod formatat
Link to comment

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.




×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.Terms of Use si Guidelines