![]() | ||
| Home | SwiftX Archive | SwiftForth Archive | |

Kevin,
with IF THEN and BEGIN UNTIL you do not need any labels & forward
references.
please see working example:
CODE CHFL \ a --- f, check 128kby block if erased, f=0 erased
S )+ A0 MOV D2 CLR 8000 # D0 MOV \ 32768 * 4 = 131072 bytes
BEGIN
A0 )+ D1 MOV FFFFFFFF # D1 EOR
0= NOT IF ( not erased) 1 # D2 MOV 1 # D0 MOV THEN
1 #Q D0 SUB 0= UNTIL
D2 S -) MOV
RTS END-CODE
----- Original Message -----
From: "Bulgrien, Kevin" <Kevin.Bulgrien_at_GDSATCOM.com>
To: <swiftx_at_forth.com>
Sent: Thursday, 05 October, 2006 11:08
Subject: [swiftx] Labels/branching in assembler macros
> I am interested in learning a good way to use labels and forward
references
> to labels in ASSEMBLER macros or CODE/END-CODE blocks using FORTH style so
I
> do not have to manually calculate the PC offset. Is this possible, and
does
> anyone care to offer a bit of insight that might help me accumulate a
> modicum
> of FORTHish understanding to store up for the future encounters with
> assembly
> language in this environment? The context in which this question occurs
is
> shown in following paragraphs.
>
> A recent debug effort put me face to face with the SwiftX assembler as I
> needed to do some debug in an interrupt handler. The TMS320C3X DSP has
> a pipeline too, so I wanted the code to be fast by inlining code instead
> of calling it, and I wanted to avoid causing pipeline conflicts due to
> branching. It did appear that using forward references was faster,
> smaller, and simpler, but being a FORTH novice and a FORTH assembler
> initiate, I did not know how to handle labels in the FORTH assembler.
> Take the following assembly pseudo-code:
>
> COMPARE_INSTRUCTION
> Label DEFERRED_BRANCH_INSTRUCTION
> INSTRUCTION
> INSTRUCTION
> INSTRUCTION
> CONDITIONAL_INSTRUCTIONS
> Label: BRANCH_DESTINATION
> MORE_CODE
>
> A fellow developer had to remind me that IF ELSE THEN and the other code
> block words work in assembler, so I looked at them but understandably they
> were not implemented with deferred branches. Unfortunately I did not look
> deeper, but left to my own devices, and using asm.f as an example, I came
> up with code to create an instruction-relative branch "mnemonic" such that
> BLTD --> BLTDR for BLTD Relative that allowed a deferred branch to be
> written like the following where BLTDR is a variation on BLTD:
>
> COMPARE_INSTRUCTION
> 1 # BLTDR
> INSTRUCTION
> INSTRUCTION
> INSTRUCTION
> CONDITIONAL_INSTRUCTION
> BRANCH_DESTINATION
> MORE_CODE
>
> I asked another peer about it and learned that the following does the same
> thing without making any special mnemonics, so the above has gone in the
> trash bin and has been chalked up as a learning experience.
>
> COMPARE_INSTRUCTION
> BEGIN 1+ BLTD
> INSTRUCTION
> INSTRUCTION
> INSTRUCTION
> CONDITIONAL_INSTRUCTION
> BRANCH_DESTINATION
> MORE_CODE
>
> --
> Kevin R. Bulgrien
> Design and Development Engineer
>
>
> CONFIDENTIAL/PROPRIETARY
>
> Unless otherwise indicated, all information (including attachments)
> contained in this e-mail communication is confidential and proprietary
> information exclusively owned by the sender and/or its related or
affiliated
> companies and shall not, without the prior written consent of the sender,
be
> used, disclosed, distributed or reproduced, in whole or in part, by anyone
> other than the individual or entity to whom this communication is
addressed
> exclusively for the purpose expressly indicated in this communication.
>
> This e-mail communication is intended for the use of the individual or
> entity to whom it is addressed. If you are not the intended recipient of
> this communication, you are hereby notified that any use, dissemination,
> distribution or copying of this communication is strictly prohibited. If
> you have received this communication in error, please destroy any copies,
> electronic, paper or otherwise that you may have.
> ----------------------------------------------------------------------
> swiftx_at_forth.com The SwiftX programming discussion email list
> To unsubscribe, send subject "unsubscribe" to swiftx-request_at_forth.com
> For list command help, send subject "help" to swiftx-request_at_forth.com
> Message archives are located at http://www.forth.com/archive/swiftx
> ----------------------------------------------------------------------
> This list is a forum for SwiftX users. For product support and bug
> reports, please send email to support_at_forth.com
> ----------------------------------------------------------------------
>
>
----------------------------------------------------------------------
swiftx_at_forth.com The SwiftX programming discussion email list
To unsubscribe, send subject "unsubscribe" to swiftx-request_at_forth.com
For list command help, send subject "help" to swiftx-request_at_forth.com
Message archives are located at http://www.forth.com/archive/swiftx
----------------------------------------------------------------------
This list is a forum for SwiftX users. For product support and bug
reports, please send email to support_at_forth.com
----------------------------------------------------------------------
Received on Thu Oct 05 2006 - 14:34:36 PDT
This archive was generated by hypermail 2.2.0 : Tue Dec 02 2008 - 03:04:51 PST