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.

Simple Question in Assembly Programming

Status
Not open for further replies.

reyge

Member level 4
Joined
Jan 23, 2007
Messages
75
Helped
2
Reputation
4
Reaction score
1
Trophy points
1,288
Activity points
1,828
notepad++ how do you comment

Hello Experts!

I am a newbie in assembly. A and B are 8-bit registers. How do you efficiently implement this in assembly using the instruction set of pic16f876a?

if ( A == B )
call subroutine1
else
call subroutine2


One way, i think is to XOR A and B then use bit testing for all 8 bits. But that could be long.
Another way is to XOR A and B, then add one to the result, then use DECFSZ.

Any other way?

thanks!
 

mpasm notepad++

Hi,

movf A , w
xorwf B , w
btfss STATUS , Z
call routine different_case
call routine equal_case

You have not to check if all the 8 bits are 0 but only check the Zero flag status of the operation. If Z is set this mean that A=B. And that's all.

Hope it help. Please press the helped me boutton.
Thanks.
Regards,
Master_PicEngineer
 

    reyge

    Points: 2
    Helpful Answer Positive Rating
notepad++ assembly comment block

right! thanks!
 

notepad++ mplab

Hello again!

How do you comment several lines of code at once?

Like in C or C++, one can do this by placing /* at the start then */ at the end.

Thanks!
 

ohh.. how sad.. haha
 

if you are using MPLAB (and you probably are), you can select a block of text ot once, right-click it, and select Advanced / Comment Block. this way you can comment larg parts at once. you can of course uncomment it the same way, by using the un-comment block option.

0x41 0x56 0x45!!
 

    reyge

    Points: 2
    Helpful Answer Positive Rating
Yup, I am using MPLAB but I am using Notepad++ to write the code.. But I didn't know there's a comment/uncomment block option in MPLAB. I just found out that there's also that option in Notepad++ for Assembly. Thanks!

Freddie Chopin, are you spanish?

I have another question, I know how to set the delay between two packets but how do you set the baud rate for USART simulation in the MPLAB?

Thanks!
 

Location: Poland
are you one of those, who doesn't know where that country is? that's not a part of spain... actually it's quite far away...

as for USART simulation - sorry - I have not played with usart simulation yet. maybe mplab is able to guess the bps from the setting of usart module in pic.

0x41 0x56 0x45!!
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top