Searching \ for '[PIC]: ASM helper' in subject line. ()
Make payments with PayPal - it's fast, free and secure! Help us get a faster server
FAQ page: massmind.org/techref/microchip/languages.htm?key=asm
Search entire site for: 'ASM helper'.

Exact match. Not showing close matches.
PICList Thread
'[PIC]: ASM helper'
2001\05\06@200519 by Tony Nixon

flavicon
picon face
Hi all,

I get caught with ASM code a lot of time when I have to do 8 or 16 bit
comparisons like if A >= B goto Bigger type stuff.

I did write some macros and I have asm code handy, but it's still a pain
to merge it in.

For those that like ASM code writing, I have created a small utillity
called HelpASM.exe which allows you to write a line of BASIC type of
code and it transforms it into PIC ASM.

For an 8 bit example you could write...

 if Timer > Count goto EndTime

which generates...

;
; if Timer > Count goto EndTime
;
       movf Timer,W
       subwf Count,W
       btfss STATUS,C
       goto EndTime
;

For a 16 bit example you could write...

 if TimerH:TimerL >= CountH:CountL goto EndTime

which generates...

;
; if TimerH:TimerL >= CountH:CountL goto EndTime
;
       movf CountL,W
       subwf TimerL,W
       movf CountH,W
       btfss STATUS,C
       addlw 1h
       subwf TimerH,W
       btfsc STATUS,C
       goto EndTime
;


These are the simple functions it supports so far.

>       - Greater Than
<       - Less Than
=       - Equal To
<>      - Not Equal To
<=      - Less Than or Equal To
>=      - Greater Than or Equal To
W range - W in range of values
Swap    - if Value1 > Value2 then swap them
Inc     - Increment 16 bit register
Dec     - Decrement 16 bit register

When the code is compiled, it is transferred to the clipboard and the
exe file minimizes itself out of the way leaving the normal code editor
visible. Just SHIFT - INSERT to paste the code into the ASM file and on
you go.

I tried to make it drag and drop but MPLAB won't accept the drop.


http://www.bubblesoftonline.com/demo/helper.zip


--
Best regards

Tony

mICros
http://www.bubblesoftonline.com
spam_OUTsalesTakeThisOuTspampicnpoke.com

--
http://www.piclist.com hint: To leave the PICList
.....piclist-unsubscribe-requestKILLspamspam@spam@mitvma.mit.edu


2001\05\07@030502 by Andrew Warren

face
flavicon
face
Tony Nixon <PICLISTspamKILLspamMITVMA.MIT.EDU> wrote:

> I have created a small utillity called HelpASM.exe which allows you
> to write a line of BASIC type of code and it transforms it into PIC
> ASM.
> ....
> For a 16 bit example you could write...
>
>   if TimerH:TimerL >= CountH:CountL goto EndTime
>
> which generates...
>
>         movf CountL,W
>         subwf TimerL,W
>         movf CountH,W
>         btfss STATUS,C
>         addlw 1h
>         subwf TimerH,W
>         btfsc STATUS,C
>         goto EndTime

Tony:

I hope you write better code than your HelpASM.exe program does.  Try
executing that fragment with TimerH:L = 0x01FE and CountH:L = 0xFF00.


-Andy

P.S.  The right way to do it is to replace the "addlw 1h" with
     "incfsz CountH,w'.


=== Andrew Warren - .....fastfwdKILLspamspam.....ix.netcom.com
=== Fast Forward Engineering - San Diego, California
=== http://www.geocities.com/SiliconValley/2499

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\05\07@124913 by David Cary

flavicon
face
Dear Tony Nixon and other compiler writers,

Tony Nixon <EraseMETony.Nixonspam_OUTspamTakeThisOuTENG.MONASH.EDU.AU> on 2001-05-06 07:03:39 PM
> For those that like ASM code writing, I have created a small utillity
> called HelpASM.exe which allows you to write a line of BASIC type of
> code and it transforms it into PIC ASM.
>
> http://www.bubblesoftonline.com/demo/helper.zip

Sounds nifty. I'm going to suggest some additions, but if you accept everyone's
additions, it will end up being a full-fledged compiler.

Here's some short sequences to do AND, OR, NAND, etc. All of these logical
operators preserve the W register (except the one that returns its results in
the W register). (Please tell me about bugs, or if these these sequences have
already been documented somewhere on piclist.com).

Talking about compilers, what (shareware and open-source) compilers exist / are
in development ?
 JAL
 piclist.com/techref/microchip/language/jal/index.htm
 Pascal-like

 http://www.dattalo.com/
 SDCC Pic Port - Is a port of SDCC - Small Device C Compiler to the PIC.

Am I missing any ?

...
data_section_5 UDATA
; set up some Byte-wide variables
A res 1
B res 1
C res 1
D res 1
X res 1
...
; set up some bit-wide variables
bits res 1
bA EQU 0
bB EQU 1
bC EQU 2
bD EQU 3

....
code_section_4 CODE
...

 ; logical operators on bit variables

 ; bD = bA or bB ; logical ``or''
 bcf bits, bD
 btfss bits,bA     ; use btfsc bits,bA to get bD = !bA or ...;
 btfsc bits,bB     ; use btfss bits,bB to get bD =... or !bB;
 bsf bits,bD

 ; bD = !bA or !bB = !( bA and bB)
 bcf bits, bD
 btfsc bits,bA
 btfss bits,bB
 bsf bits,bD

 ; bD = bA and bB ; logical ``and''.
 bsf bits,bD
 btfsc bits,bA     ; use btfss bits,bA to get bD = !bA and ...;
 btfss bits,bB     ; use btfsc bits,bB to get bD =... and !bB;
 bcf bits,bD

 ; bD = !(bA or bB) = !bA and !bB
 bsf bits,bD
 btfss bA
 btfsc bB
 bcf bits,bD

 ; X = bA or bB ; logical ``or''; return byte 0 for false, 1 for true.
 clrf X
 btfss bits,bA
 btfsc bits,bB
 incf X

 ; w = (bA or bB) ? C : D;
 movfw D
 btfss bits,bA
   btfsc bits,bB
   movfw C

 ; w = (bA and bB) ? C : D;
 movfw C
 btfsc bits,bA
   btfss bits,bB
   movfw D

 ; if( bA or bB ){ start_foo(); };
 btfss bits, bA
 btfsc bits, bB
 call start_foo


 ; logical operators on Byte variables

 ; X = A or B ; logical ``or''.
 clrf X
 tstf A
 skpnz
 tstf B
 skpz
 bsf X,1

 ; X = A and B ; logical ``and''
 clrf X
 tstf A
 skpz
 tstf B
 skpz
 bsf X,1

; if( A or B ){ start_foo(); };
 tstf A
 skpnz
 tstf B
 skpz
 call foo

; if( foo() and_then bar() ){ foo_bar(); } // standard C language ``&&''
shortcut...
 call foo ; foo() returns status (0=false) in Carry flag
 skpnc
 call bar ; bar() also returns status in Carry flag
 skpnc
 ; repeat last 2 lines as many times as needed to aggregate lots of terms.
 call foo_bar ; called only when Carry flag was set both times.

; if( baz() or_else quux() ){ foo_bar(); } // standard C language ``||''
shortcut...
 call baz ; assume baz() returns status in Zero flag
 skpnz
 call quux ; quux() also returns status in Zero flag
 skpz
 call foo_bar ; skipped only when Zero flag was set both times.

--
David Cary

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


2001\05\07@202610 by Tony Nixon

flavicon
picon face
Andrew Warren wrote:
{Quote hidden}

Hi Andy,

Dead right!!

It gets caught when CountH = 0xFF.

I'll ammend all the code and update it - thanks.

--
Best regards

Tony

mICros
http://www.bubblesoftonline.com
KILLspamsalesKILLspamspampicnpoke.com

--
http://www.piclist.com hint: PICList Posts must start with ONE topic:
[PIC]:,[SX]:,[AVR]: ->uP ONLY! [EE]:,[OT]: ->Other [BUY]:,[AD]: ->Ads


More... (looser matching)
- Last day of these posts
- In 2001 , 2002 only
- Today
- New search...