ELFORUM - Forumul electronistilor

Cod

Recommended Posts

Salut, ma poate ajuta cineva cu un cod de mplab in asembler pentru ordonarea in ordine crescatoare/descrescatoare a 3 numere ?

Edited by Lilith
• Replies 2
• Created

Popular Days

Salut. După ce găseşti algoritmul, implementarea în asm sau orice alt limbaj ar trebui să fie floare la ureche.

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

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.

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

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your previous content has been restored.   Clear editor

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

×

×