8051 microcontroller 8051 microcontroller
Forums

Rickey's World of Microcontrollers & Microprocessors :: Forums :: Discuss and Learn :: 8051 Discussion Forum
 
<< Previous thread | Next thread >>
*.asm include to another *.asm help in Keil
Page 1 of 2    [1] 2
Moderators: Ajay Bhargav, Arun Kumar V, pdi33, Shailesh NAYAK, ۞ TPS ۞, shyam, sashijoseph, ExperimenterUK, DavesGarage, majoka
Author Post
Nisar Ahmed
Mon Jul 27 2009, 10:25AM
Registered Member #1201
Joined: Sat May 26 2007, 02:27AM
Location (Home Town): Pakistan
Posts: 465
Hello everyone
I have a file" table.asm",I want to include with another file" main.asm".Plz help me how i call file "table.asm"in the file "main.asm".I have using Keil assembler.

Thanks in advance
Nisar Ahmed
Back to top
M.Mohsin
Mon Jul 27 2009, 01:03PM

Registered Member #17093
Joined: Mon Mar 30 2009, 03:33PM
Location (Home Town): Pakistan
Posts: 105
have u added the file to your source group of "main.asm"?
Back to top
Ajay Bhargav
Mon Jul 27 2009, 03:22PM
Rickey's World Admin


Registered Member #1
Joined: Fri Feb 24 2006, 07:56AM
Location (Home Town): Punjab, India
Posts: 12587
there are rules to follow when writing distributed assembly code..
you can download the PDF document from download section regarding Assembly programming in keil.

look for the use of keyword
"extrn" and "segment code" etc.
Back to top
ajayhhh
Tue Jul 28 2009, 02:37PM
Registered Member #20602
Joined: Wed Jul 22 2009, 03:27PM
Location (Home Town): Bangalore
Posts: 10
hi guys.. can any 1 post a ScreenShot of them working with multi-file (asm)..
i wana see the declarations made in main pgm and sub-pgms..
Back to top
Nisar Ahmed
Wed Jul 29 2009, 04:39AM
Registered Member #1201
Joined: Sat May 26 2007, 02:27AM
Location (Home Town): Pakistan
Posts: 465
Now it's ok
In" main.asm" file .I use directive #include<table.asm>

Regards
Nisar Ahmed
Back to top
Ajay Bhargav
Wed Jul 29 2009, 05:16PM
Rickey's World Admin


Registered Member #1
Joined: Fri Feb 24 2006, 07:56AM
Location (Home Town): Punjab, India
Posts: 12587
make sure you are not getting any warnings coz that can ruin your program.

to call a routine from external asm file.. you need to declare that segment as public. i will give you an example soon..
Back to top
Nisar Ahmed
Wed Jul 29 2009, 11:40PM
Registered Member #1201
Joined: Sat May 26 2007, 02:27AM
Location (Home Town): Pakistan
Posts: 465
There is no any warning.
Back to top
Ajay Bhargav
Fri Jul 31 2009, 02:54PM
Rickey's World Admin


Registered Member #1
Joined: Fri Feb 24 2006, 07:56AM
Location (Home Town): Punjab, India
Posts: 12587
here is the exact Keil example..

File: ADD.asm

CODE:
;Add routine which will be called from other file
PUBLIC ADDNUM ;declare function as public

ADDNUM_ SEGMENT CODE  ;define code segment for linker
RSEG ADDNUM_ ;select segment ADDNUM

ADDNUM:  ;Our add routine
MOV R2,R1
ADD R2,R0
RET
 


File: Test.asm

CODE:
EXTRN CODE (ADDNUM) ;define the external symbol

CSEG at 0 ;code starts at 0
MOV R0,#50  ;Some dummy instructions
MOV R1,#51
ACALL ADDNUM ;lets call this routine which is in second file
 


Link it and check..

[ Edited Fri Jul 31 2009, 02:56PM ]
Back to top
Nisar Ahmed
Fri Jul 31 2009, 11:30PM
Registered Member #1201
Joined: Sat May 26 2007, 02:27AM
Location (Home Town): Pakistan
Posts: 465
Thanks for help
Back to top
ajayhhh
Mon Aug 03 2009, 01:10PM
Registered Member #20602
Joined: Wed Jul 22 2009, 03:27PM
Location (Home Town): Bangalore
Posts: 10
Ok i guess Ajay's example is enough to learn the multi file concept..

I have written a code of about 31KB in a notepad which includes main pgm, LCD initilizations, 3 timer configurations and settings, ADC and its lookup table, Serial intializations and its Tx and Rx, keypad routine and some more things..

Unfortunately i dont know the concept of multi file in asm formats and i have written all these in a single file with countless jumps.... Thank god its working and thanks to JTAG debugger as well...

Now i wana seperate them into individual files and add them into my project...

So i request any 1 to plz share me a project where such concept of multi files is used... so i can get a clear idea of it...

And i dont understand why multi file is required when the solo single file is working fine....

Anyways both formats jumps to specified sequence right ? Can any 1 plz explain why they insist on multifile ?

[ Edited Mon Aug 03 2009, 01:13PM ]
Back to top
Page 1 of 2    [1] 2  

Jump:     Back to top

Syndicate this thread: rss 0.92 Syndicate this thread: rss 2.0 Syndicate this thread: RDF
Powered by e107 Forum System

© 2010 Rickey's World
Render time: 0.0755 sec, 0.0085 of that for queries. DB queries: 68. Memory Usage: 2,899kB