"IBM personal computer assembly language tutorial" - читать интересную книгу автора (Auerbach J.)Line comments are frequently set off with a semi-colon in column 1. I use this approach for block comments too, although there is a COMMENT statement which can be used to introduce a block comment. Being an old 370 type, I like to see assembler code in upper case, although my comments are mixed case. Actually, the assembler is quite happy with mixed case anywhere. As with any assembler, the core of the opcode set consists of opcodes which generate machine instructions but there are also opcodes which generate data and ones which function as instructions to the assembler itself, some- times called pseudo-ops. In the example, there are five lines which gener- ate machine code (JMP, MOV, MOV, INT, RET), one line which generates data (DB) and five pseudo-ops (SEGMENT, ASSUME, ORG, ENDS, and END). We will discuss all of them. Now, about labels. You will see that some labels in the example end in a colon and some don't. This is just a bit confusing at first, but no real mystery. If a label is attached to a piece of code (as opposed to data), then the assembler needs to know what to do when you JMP to or CALL that label. By convention, if the label ends in a colon, the assembler will use the NEAR form of JMP or CALL. If the label does not end in a colon, it label you are jumping to inside your program because such jumps are always NEAR; there is no reason to use a FAR jump within a single code section. I mention this, though, because leaving off the colon isn't usually trapped as a syntax error, it will generally cause something more abstruse to go wrong. On the other hand, a label attached to a piece of data or a pseudo-op never ends in a colon. Machine instructions will generally take zero, one or two operands. Where there are two operands, the one which receives the result goes on the left as in 370 assembler. I tried to explain this before, now maybe it will be even clearer: there are many more 8086 machine opcodes then there are assembler opcodes to rep- resent them. For example, there are five kinds of JMP, four kinds of CALL, two kinds of RET, and at least five kinds of MOV depending on how you count them. The macro assembler makes a lot of decisions for you based on the form taken by the operands or on attributes assigned to symbols elsewhere in your program. In the example above, the assembler will generate the NEAR DIRECT form of JMP because the target label BEGIN labels a piece of code instead of a piece of data (this makes the JMP DIRECT) and ends in a colon (this makes the JMP NEAR). The assembler will generate the immediate forms of MOV because the form OFFSET MSG refers to immediate data and |
|
© 2025 Библиотека RealLib.org
(support [a t] reallib.org) |