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.

How to Divide Big .asm file?

Status
Not open for further replies.

rahul_sanghavi

Member level 2
Joined
Dec 7, 2004
Messages
47
Helped
0
Reputation
0
Reaction score
1
Trophy points
1,286
Activity points
404
how to divide assembler

Hi,

I have very big .asm file of my project.

Now i want to divide in small .asm files like .h file in C language.

I do coding using MPLAB IDE & i use PIC controller.

Plz. Help Me.

Regards
Rahul Sanghavi
 

asm divide

This feature is built into MPLAB. You need to use the include directive, just like C to include another file (usually .inc). Sometimes you have to be careful where you include a file around ORG statements for code. Just include near the beginning if its macros only.

I do this with my macros alot and with other parts of the program I want to break apart. Most of the time I separate macros and constants from code into seperate include files.

One other convention I use, is my include file refers to registers, but I force myself to declare them with a CBLOCK in the main program (as if they're global). Often I also use the set or equ command to have multiple names for the same register depending on how they're named and used in the include files and main program (reusing registers as if they're local). Doing these things in the main program helps me keep up with the register data flow so I get what I want when I put it all together.

You don't have to do these things, but I find it adds alot of structure to my assembly programs and generally helps me keep up with my constants, code, and registers. Refer to the MPASM help menu for more information.
 

asm11 project

Hi jonw0224

Thanks for reply.

Can You Plz give me any sample code for better understanding?

Regards
Rahul Sanghavi
 

mplab include asm files

Code:
; P r o c e s s o r
;==============================================================================
    list p=16f84a
    include p16f84a.inc

; D a t a   M e m o r y
;==============================================================================
    cblock 0x0C
        cntr
    endc
    temp equ cntr

; M A C R O S
;==============================================================================

MOVLF macro lit, reg
    movlw lit
    movwf reg
    endm

; R e s e t   V e c t o r
;==============================================================================
    org 0x0000
        goto Initialize

; I n t e r r u p t   V e c t o r
;==============================================================================
    org 0x0004
        retfie


; M A I N
;==============================================================================
Initialize

Main
	MOVLF 0x10, cntr
	call DumbLoop
	MOVLF 0x20, temp
	call DumbLoop	
    goto $

DumbLoop
	decfsz cntr, f
		goto DumbLoop
	return

; I N C L U D E S
;==============================================================================

;==============================================================================
    end

can be rewritten among many files. Let's use 3 files, one for macros, and one for subroutines. Here's the new main file:

Code:
; P r o c e s s o r
;==============================================================================
    list p=16f84a
    include p16f84a.inc

; D a t a   M e m o r y
;==============================================================================
    cblock 0x0C
        cntr
    endc
    temp equ cntr

; M A C R O S
;==============================================================================

	include "movlf.inc"
	
; R e s e t   V e c t o r
;==============================================================================
    org 0x0000
        goto Initialize

; I n t e r r u p t   V e c t o r
;==============================================================================
    org 0x0004
        retfie


; M A I N
;==============================================================================
Initialize

Main
	MOVLF 0x10, cntr
	call DumbLoop
	MOVLF 0x20, temp
	call DumbLoop	
    goto $

; I N C L U D E S
;==============================================================================

	include "dumloop.inc"

;==============================================================================
    end

Here's movlf.inc:

Code:
MOVLF macro lit, reg
    movlw lit
    movwf reg
    endm

Here's dumloop.inc:

Code:
DumbLoop
	decfsz cntr, f
		goto DumbLoop
	return

Notice also, that the same register cntr, I can refer to by two different names. This may sound trivial, but when I've got registers doing "double duty", its a good way to keep the "role" seperate from the "register location".
 
c include assembly files

Hi jonw0224

Thanks for ur help .

I paste ur sample code & build but unfortunately program cannot build successfully & give some of errors like.
Warning[207] E:\PROJECT\TECSINEUPS500\WORKSPACE\TEST.ASM 11 : Found label after column 1. (temp)
Error[105] E:\PROJECT\TECSINEUPS500\WORKSPACE\TEST.ASM 16 : Cannot open file (Include File "movlf.inc" not found)
Warning[207] E:\PROJECT\TECSINEUPS500\WORKSPACE\TEST.ASM 34 : Found label after column 1. (MOVLF)
Error[108] E:\PROJECT\TECSINEUPS500\WORKSPACE\TEST.ASM 34 : Illegal character (0)
Error[113] E:\PROJECT\TECSINEUPS500\WORKSPACE\TEST.ASM 35 : Symbol not previously defined (DumbLoop)
Warning[207] E:\PROJECT\TECSINEUPS500\WORKSPACE\TEST.ASM 36 : Found label after column 1. (MOVLF)
Error[108] E:\PROJECT\TECSINEUPS500\WORKSPACE\TEST.ASM 36 : Illegal character (0)
Error[113] E:\PROJECT\TECSINEUPS500\WORKSPACE\TEST.ASM 37 : Symbol not previously defined (DumbLoop)
Error[105] E:\PROJECT\TECSINEUPS500\WORKSPACE\TEST.ASM 43 : Cannot open file (Include File "dumloop.inc" not found)
Halting build on first failure as requested.
BUILD FAILED: Thu Dec 15 10:43:23 2005

I use MPLAB IDE 7.20
I create project & include test.asm as source file & two other file(.inc one for macro & other for subroutine) include in header file.
All files (.asm , .inc & project files) in same path.


Regards
Rahul :cry:
 

divide with assembler

That's the error message I get when I don't create the .inc files. Are you sure you created them? It works fine for me. I'm using MPLAB IDE 6.20.

You should have three files:

E:\PROJECT\TECSINEUPS500\WORKSPACE\TEST.ASM
E:\PROJECT\TECSINEUPS500\WORKSPACE\movlf.inc
E:\PROJECT\TECSINEUPS500\WORKSPACE\dumloop.inc
 
mplab ide cannot open file (include file

Hi, jonw0224

Thanks a lot,

I found my mistake !!!

Once again Thk. :D

Regards
Rahul Sanghavi :)
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top