Monday, November 28, 2011

The Battle over Assembly Comments

I've been working toward having a single file, asm64.tex, to serve as the source for the printed book (pdf format), the Kindle e-book (mobi format) and the Nook e-book (epub format).  My adventures with htlatex are starting to gel into a reasonable plan, except for assembly language comments.

Assembly code is normally divided into columns like this:

label:   instruction   operands      ; comments

My habit is to start the instructions in column 9 with operands starting in column 17.  This looks pretty good, but many of my lines of code are a little long.  I originally shrank them somewhat to fit the width of the printed book (about 6 inches).  Then I ran into the Kindle.

The Kindle is limited to 47 characters of monospaced text per line or 65 characters in landscape mode.  I was originally fairly happy when I discovered the landscape mode.  Nearly all my comments were 65 or fewer characters.

Then I borrowed my son's Nook.  The Nook apparently did not have a landscape mode.  I opted from the start to make the Nook version be the same as the Kindle version, so I have to live with the portrait mode.

I have gone through the code once (or twice) shrinking comments and spreading comments out onto 2 lines to make the book look fairly good on the Kindle with 47 characters, but I was not too happy with short lines for the printed version of the book.  So after some thought I decided to dive in and solve the problem with a bash/awk script.

I wrote a fairly good script which tries to break long comments near the middle and apparently break one line into 2 lines is sufficient for my needs.  I was afraid that I would need more robust code, but I'll leave it as is for now.

My script does allow a command-line parameter for the number of columns.  I need to borrow the Nook again and study it in detail.  Perhaps it has a smaller monospaced font which will allow wider lines.  I also don't know precisely the number of characters across the Nook screen.  I will be prepared for updating the Kindle and Nook books fairly soon.  I have also found a moderate number of typos, so I might update the printed book on Create Space as well.

Hopefully I will get around to doing some Windows assembly language during the Christmas break...

5 comments:

Anonymous said...

Hmm is anyone else having problems with the pictures on this blog
loading? I'm trying to determine if its a problem on my end or if it's the blog.
Any suggestions would be greatly appreciated.



my page; league of legends hack

Unknown said...

It seems fine when I try it. Can you give more details so I can try to figure out what failed? Maybe it was a temporary problem.

Anonymous said...

Hi there would you mind sharing which blog platform you're working with?
I'm looking to start my own blog in the near future but I'm having a hard time choosing between BlogEngine/Wordpress/B2evolution and Drupal.
The reason I ask is because your design and style seems different then most blogs and
I'm looking for something completely unique.

P.S Apologies for being off-topic but I had to ask!

Unknown said...

This is blogger.com. I haven't tried to discover what software they use.

Anonymous said...

Great post.