From: "Thomas R. Dean" <deantr@cogeco.ca>
To: binutils@sources.redhat.com
Subject: short displacement in AT&T syntax
Date: Tue, 09 Nov 2004 01:11:00 -0000 [thread overview]
Message-ID: <41901A8D.7020900@cogeco.ca> (raw)
I'm not sure if this is the right place to ask. I've checked the docs,
been through the archives, searched the web but have not able to find
any mention of this issue. I've been working on this on and off for
several days now. If this is not the right place, please point me in
the right direction.
I teach an OS class and I use linux (x86) to teach it. For the next
lab, I want to use the gnu assembler, but I am running into a slight
problem. I need to be able restrict the displacement to a single byte,
for example:
movl %eax,0x23(%edi)
This works fine (generates 89 47 23). But if the displacement contains
any expression with a reference to a forward label, the assembler
generates a 2 byte displacement (89 87 23 00) even if the value will
fit into a single byte displacement:
move %eax,(L2-L1)(%edi)
...
L1: .asci "......"
...
L2: .asci "....."
where edi happens to point to L1, and the distance between L1 and L2 is less
than 127 bytes. In MASM, you can restrict the size of the displacement as
follows:
mov [byte edi+L2-L1],eax
And you will get an error if the displacement does not fit. The gnu
assembler seems to be able to optimize jumps automatically (you have
to use "jmp short label" manually to get the same optimization in MASM). Is
there an option or directive that will optimize the displacements as well?
I would prefer to use AT&T syntax, and the students have only seen
accumulator assembly
languages until now (68HC11). While test solving the assignment myself,
I have done
a two pass approach where I assemble the code with a list file, look at
the list for the
values of the offsets, and hand replace the expressions with the values
to get the short
displacements. This would not be an acceptable approach to use in class.
I have to
finish writing up and the assignment to hand out next tuesday. If
necessary, I will rework the
assignment to use Intel Syntax, but as I said I would prefer to use AT&T
syntax.
Thanks in advance for any help the list can give me.
Tom.
next reply other threads:[~2004-11-09 1:11 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-11-09 1:11 Thomas R. Dean [this message]
2004-11-09 2:46 ` Alan Modra
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=41901A8D.7020900@cogeco.ca \
--to=deantr@cogeco.ca \
--cc=binutils@sources.redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).