Continue to Site

Welcome to our site!

Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

  • Welcome to our site! Electro Tech is an online community (with over 170,000 members) who enjoy talking about and building electronic circuits, projects and gadgets. To participate you need to register. Registration is free. Click here to register now.

Testing entire registers in assembly

Status
Not open for further replies.

dak246

Member
I'm just checking to see if theres an easier way to test the values of entire registers. What I do now is this; If im looking for an entire register to be zero, I simply move it to w, add 255, and check the carry bit. If I'm looking for a value to be within a range of some sort, say less than or equal to 45, I simply subtract w from 45 and check the carry bit. Is this a correct way of doing things? I notice some code uses the "tstf" and various other functions, but I'm wondering if these just filter down into what Im already doing. Also, when testing more than bit, but less than the entire register, I just use and/or functions and then the method I described above.
 
You don't mention what processor you are using?, but PIC's have a couple of flags associated with these kinds of tests. By checking either or both you can test for '=', '<>', '>', '<', '<=', '>=' - there's a complete section on the PICList about it, with examples for 8 or 16 bits.
 
If we are talking PICs here...

...checking for zero is simple as this:

MOVF register,F ;register copies to itself (thus nothing changes)
;but in next line you can check STATUS,Z

Few weeks ago, waiting for a vessel to enter port, I spent two days of continuous rain, in a hotel. :( I had time to somehow improve :?: a bunch of macros destined to skip (or not) the next line after the macro, based on the comparison of a register against another register or a value.

They are for 8 and 16-bit values.

You could take a look here:

**broken link removed** - Look for PICs

¡Buena suerte!

Agustín Tomás
 
I assumed everyone would know I was talking about PICs but in hindsight I see that I definatly should've pointed that out.

Anyway, I never even knew the zero bit was there in the status register so thats a big help, and so were the PIClist references and atferrari's site. Thanks guys.
 
Status
Not open for further replies.

New Articles From Microcontroller Tips

Back
Top