【正文】
=0 Suggested coding standards (1 of 2) ? Some approaches to capitalization – capitalize nothing – capitalize everything – capitalize all reserved words, including instruction mnemonics and register names – capitalize only directives and operators (used by the book) ? Other suggestions – descriptive identifier names – spaces surrounding arithmetic operators – blank lines between procedures Suggested coding standards (2 of 2) ? Indentation and spacing – code and data labels – no indentation – executable instructions – indent 45 spaces – ments: begin at column 4045, aligned vertically – 13 spaces between instruction and its operands ? ex: mov ax,bx – 12 blank lines between procedures Alternative version of AddSub TITLE Add and Subtract () 。 add 1 to ax – mov count, bx 。2 (E127) Real number constants (decimal reals) ? [sign]integer.[integer][exponent] sign → {+|} exponent → E[{+|}]integer ? Examples: 2. + +05 Character and string constants ? Enclose character in single or double quotes – 39。t a test Reserved words and identifiers ? Reserved words (Appendix D) cannot be used as identifiers – Instruction mnemonics, directives, type attributes, operators, predefined symbols ? Identifiers – 1247 characters, including digits – case insensitive (by default) – first character must be a letter, _, , or $ – examples: var1 Count $first _main MAX open_file myfile xVal _12345 Directives ? Commands that are recognized and acted upon by the assembler – Part of assembler’s syntax but not part of the Intel instruction set – Used to declare code, data areas, select memory model, declare procedures, etc. – case insensitive ? Different assemblers have different directives – NASM != MASM, for example ? Examples: .data .code PROC Instructions ? Assembled into machine code by assembler ? Executed at runtime by the CPU ? Member of the Intel IA32 instruction set ? Four parts – Label (optional) – Mnemonic (required) – Operand (usually required) – Comment (optional) Label: Mnemonic Operand(s) 。 EAX = 10000h add eax,40000h 。 Program Description: 。 8bit signed integer ? WORD, SWORD – 16bit unsigned amp。 smallest signed byte value5 SBYTE +127 。,39。 20 bytes, uninitialized var3 BYTE 4 DUP(STACK) 。 unsigned val2 SDWORD –2147483648 。 subtract 20200h mov finalVal,eax 。 evaluates the expression move TEXTEQU mov setupAL TEXTEQU move al,count .code setupAL 。 start with 10000h add eax,val2 。 array of words array WORD 5 DUP(?) 。 greeting1 BYTE Wele to the Encryption Demo program BYTE created by Kip Irvine.,0 greeting2 \ BYTE Wele to the Encryption Demo program BYTE created by Kip Irvine.,0 Defining strings (2 of 2) ? Endofline cha