2016-07-24 15 views
6

In GNU as (das GNU Assembler), fügt der folgende Code ohne Fehler:Abteilung verursacht unausgewogene Klammern

mov $(80 * 24 + 4), %cx 

jedoch dieser Code nicht:

mov $(80 * 24/4), %cx 

den hoch unerwarteten Fehler Ausstrahlen:

example.S: Assembler messages: 
example.S:42: Error: unbalanced parenthesis in operand 1. 

Der einzige Unterschied ist, dass letzterer Divisionen anstelle von ad verwendet dition. Dies sollte gültig sein, according to the manual.

($<expression> bettet eine sofortige in der montierten Ausgang;. Dh eine konstante Der arithmetische bei durchgeführt wird „kompilieren-time“ Ich konnte die Mathematik arbeiten, aber es macht mehr Sinn, in seiner erweiterten Form..)

Antwort

7

/ bedeutet der Beginn eines Kommentars, in meinem speziellen Fall.

--divide

On SVR4-derived platforms, the character / is treated as a comment character, which means that it cannot be used in expressions. The --divide option turns / into a normal character. This does not disable / at the beginning of a line starting a comment, or affect using # for starting a comment.

This post on the binutils mailing list schlägt auch eine ähnliche Geschichte:

For compatibility with other assemblers, ' / ' starts a comment on the i386-elf target. So you can't use division. If you configure for i386-linux (or any of the bsds, or netware), you won't have this problem.

ich zufällig für das x86_64-elf Ziel zu Montage, die ich nehme an ausreichend ähnlich ist zu dem genannten i386-elf (ersteres ist für die amd64 oder " x86_64 "Arch, Letzteres ist das gleiche, aber für die ältere 32-Bit-x86-Architektur).