2016-07-24 11 views
6

gnu as (asemblera GNU) dodaje kod montuje bez błędu:Division powoduje niesymetryczne nawiasy

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

Niemniej jednak ta nie:

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

emitujących bardzo nieoczekiwany błąd:

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

Jedyna różnica polega na tym, że ta ostatnia używa podziału zamiast reklamy dition. To powinno być ważne, according to the manual.

($<expression> osadza natychmiastowe do zmontowanego wyjściowego; tj., Stała arytmetyczna jest wykonywana na „kompilacji” Mógłbym pracować z matematyki, ale to sprawia, że ​​więcej sensu w rozszerzonej formie.).

Odpowiedz

7

/ oznacza początek komentarza, w moim konkretnym przypadku.

--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 sugeruje również podobną historię:

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.

I stało się montażem za cel x86_64-elf, co przypuszczam jest wystarczająco podobny do wymienionych i386-elf (dawna jest dla amd64 lub " x86_64 "arch, ten ostatni jest taki sam, ale dla starszej 32-bitowej architektury x86).