3 Replies - 2483 Views - Last Post: 28 July 2019 - 10:12 AM

#1 thrawn235   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 1
  • Joined: 17-July 19

How to structure (large) assembly programs?

Posted 17 July 2019 - 10:28 AM

Hello,

I have used quite a bit of inline assembly in a project recently.
I liked it quite a bit and decided to write a program just using assembly.

Since i have not done that before, i was wondering, how does one typically structure an assembly project.
I assume not everything goes in the same file, so do you typically split it up in different modules ?
if so, how many functions do you put in one module and how do you avoid the use of duplicate label names ?
Is there some rule or strategy on including files (header files)? what do you put in a header and what goes in another module ?

I was looking for a book on advanced assembly but that specific aspect is never discussed.
beginner books are about mnemonics, memory models etc and advanced books seem to be on interrupts, TSRs and all the specific PC hardware components (which is fine and interesting)
But doesn't really help me right now.
Im quite willing to read(and buy) a book or a tutorial on the topic if you guys can recommend one.

Thanks.

Is This A Good Question/Topic? 0
  • +

Replies To: How to structure (large) assembly programs?

#2 no2pencil   User is online

  • Professor Snuggly Pants
  • member icon

Reputation: 6832
  • View blog
  • Posts: 31,491
  • Joined: 10-May 07

Re: How to structure (large) assembly programs?

Posted 17 July 2019 - 03:26 PM

** Moved to assembly **
Was This Post Helpful? 0
  • +
  • -

#3 turboscrew   User is offline

  • D.I.C Lover
  • member icon

Reputation: 172
  • View blog
  • Posts: 1,114
  • Joined: 03-April 12

Re: How to structure (large) assembly programs?

Posted 28 July 2019 - 09:55 AM

You write modules like you would with C, and select a prefix for each module to be used for global names.
Then you assemble the files and link the object files into executable.

You might want to split the code in a bit smaller modules when you use assembly than when you use C.

You use includes the way you _should_ use includes in C. They describe the module interface to other modules that use the module.

The module is not some number of lines or functions. It contains all the stuff for some functional entity. I'd put ISRs in the same module that handles the device, unless I have a good reason to do otherwise, like one IRQ shared with several devices. Then I'd make the shared interrupt handling a module of its own.

The number of lines or functions given for good module are not really about lines/functions, but rather try to describe a good "scope" of a module. "A good module is such that everything relevant fits into n lines/functions."

This post has been edited by turboscrew: 28 July 2019 - 10:08 AM

Was This Post Helpful? 0
  • +
  • -

#4 turboscrew   User is offline

  • D.I.C Lover
  • member icon

Reputation: 172
  • View blog
  • Posts: 1,114
  • Joined: 03-April 12

Re: How to structure (large) assembly programs?

Posted 28 July 2019 - 10:12 AM

They usually tell you to write something like 100 line modules for clarity, but think: which would be clearer: 10 000 modules of 100 lines each or 100 modules of 10 000 lines each.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1