汇编语言基于x86处理器课后答案第七版

Answers to End of Chapter Reviews and Exercises
for Assembly Language for x86 Processors, 7th Edition
by Kip R. Irvine
Chapters 1 to 13
Revision date: 1/18/2014

第一章

Chapter 1
1.7.1 Short Answer Questions

  1. Most significant bit (the highest numbered bit).
  2. (a) 53 (b) 150 © 204
  3. (a) 110001010 (b) 110010110 © 100100001
  4. 00000110
  5. (a) 8 (b) 32 © 64 (d) 128
  6. (a) 12 (b) 16 © 16
  7. (a) 35DA (b) CEA3 © FEDB
  8. (a) 0000 0001 0010 0110 1111 1001 1101 0100
    (b) 0110 1010 1100 1101 1111 1010 1001 0101
    © 1111 0110 1001 1011 1101 1100 0010 1010
  9. (a) 58 (b) 447 © 16534
  10. (a) 98 (b) 1203 © 671
  11. (a) FFE8 (b) FEB5
  12. (a) FFEB (b) FFD3
  13. (a) 27641 (b) −16093
  14. (a) 19666 (b) −32208
  15. (a) −75 (b) +42 © −16
  16. (a) −128 (b) −52 © −73
  17. (a) 11111011 (b) 11010110 © 11110000
  18. (a) 10111000 (b) 10011110 © 11100110
  19. (a) AB2 (b) 1106
  20. (a) B82 (b) 1316
  21. 42h and 66d
  22. 47h and 71d
  23. 229 − 1, or 6.8056473384187692692674921486353 X 1038
  24. 286 − 1, or 77371252455336267181195263
  25. Truth table:
  26. Truth table: (last column is the same as #25)
  27. It requires 24 (16) rows.
  28. 2 bits, producing the following values: 00, 01, 10, 11
    1.7.2 Algorithm Workbench
  29. Code example (C++)
    int toInt32(string s) {
    int num = 0;
    for(int i = 0; s[i] >= ‘0’ && s[i] <= ‘1’; i++) {
    num = num * 2 + s[i]-‘0’;
    }
    return num;
    }
  30. Code example (C++)
    int hexStrToInt32(string s) {
    int num = 0;
    for(int i = 0; ; i++) {
    if( s[i] >= ‘0’ && s[i] <= ‘9’ )
    num = num * 16 + s[i]-‘0’;
    else if( s[i] >= ‘A’ && s[i] <= ‘F’ )
    num = num * 16 + (s[i]-‘A’+10);
    else
    break;
    }
    return num;
    }
  31. Code example (C++)
    string intToBinStr( int n ) {
    vector stack;
    do {
    int quotient = n / 2;
    int remainder = n % 2;
    stack.push_back(remainder);
    n = quotient;
    } while( n > 0 );
    string s;
    while( stack.size() > 0 ) {
    s += (stack.back() + ‘0’);
    stack.pop_back();
    }
    return s;
    } 4. Code example (C++)
    string intToHexStr( int n ) {
    vector stack;
    do {
    int quotient = n / 16;
    int remainder = n % 16;
    stack.push_back(remainder);
    n = quotient;
    } while( n > 0 );
    string s;
    while( stack.size() > 0 ) {
    int d = stack.back();
    if( d >= 0 && d <= 9 )
    s += (stack.back() + ‘0’);
    else // probably a hex digit
    s += (stack.back() - 10 + ‘A’);
    stack.pop_back();
    }
    return s;
    }
  32. Code example (C++)
    string addDigitStrings( string s1, string s2, int base ) {
    string sumStr;
    int carry = 0;
    for(int i = s1.size() - 1; i >= 0; i–) {
    int dval = (s1[i] - ‘0’) + (s2[i] - ‘0’) + carry;
    carry = 0;
    if( dval > (base - 1) ) {
    carry = 1;
    dval = dval % base;
    }
    sumStr.insert(sumStr.begin(), (dval + ‘0’));
    }
    if( carry == 1 )
    sumStr.insert( sumStr.begin(), 1 + ‘0’);
    return sumStr;
    }

第二章

Chapter 2
2.8.1 Short Answer Questions

  1. EBP
  2. Choose 4 from: Carry, Zero, Sign, Direction, Aux Carry, Overflow, Parity.
  3. Carry flag
  4. Overflow flag
  5. True
  6. Sign flag
  7. Floating-point unit
  8. 80 bits
  9. True
  10. False
  11. True
  12. False
  13. True
  14. False
  15. False
  16. False
  17. True
  18. False
  19. True
  20. False
  21. False
  22. True
  23. True
  24. False
  25. False
  26. Hardware, BIOS, and OS
  27. It gives them more precise control of hardware, and execution is faster.
    Chapter

第三章

Chapter 3
3.9.1 Short Answer Questions(简答题)

  1. ADD, SUB, MOV
  2. A calling convention determines how parameters are passed to subroutines, and how the stack is
    restored after the subroutine call.
  3. By subtracting a value from the stack pointer register.
  4. Assembler means the program that translates your source code. A more correct term is “assembly
    language”.
  5. Little endian places the least significant bit in position 0, on the right side of the number. Big endian
    does the opposite.
  6. An integer literal, such as 35, has no direct meaning to someone reading the program’s source code.
    Instead, a symbolic constant such as MIN_CAPACITY can be assigned an integer value, and is selfdocumenting.
  7. A source file is given as input to the assembler. A listing file has additional text that will not
    assemble. It is a file that iscreated by the assembler.
  8. Data labels exist in the data segment as variable offsets. Code labels are in the code segment, and are
    offsets for transfer of control instructions.
  9. True
  10. False (this notation is used in C, but not in assembly language).
  11. False
  12. True
  13. Label, mnemonic, operand(s), comment
  14. True
  15. True
  16. Code example:
    COMMENT !
    this is the first comment line
    this is the second comment line
    !
  17. You do not use numeric addresses (offsets) for variables because the addresses would change if new
    variables were inserted before the existing ones.
    3.9.2 Algorithm Workbench(算法基础)
  18. Code example:
    one = 25
    two = 11001b
    three = 31o
    four = 19h
  19. Yes, it can have multiple code and data segments.
  20. Storing the value 01020304h
    myVal LABEL DWORD
    BYTE 04h,03h,02h,01h
  21. Yes, you can. The assembler does not check the number’s sign.
  22. Code example. The two instructions have different opcodes.
    add eax,5
    add edx,5
  23. Little endian order: ABh, 89h, 67h, 45h
  24. myArray DWORD 120 DUP(?)
  25. firstFive BYTE “ABCDE”
  26. smallVal SDWORD 80000000h ; -32,768
  27. wArray WORD 1000h, 2000h, 3000h
  28. favColor BYTE “blue”,0
  29. dArray DWORD 50 DUP(?)
  30. msg BYTE 500 DUP(“TEST”)
  31. bArray BYTE 20 DUP(0)

链接:

资源链接

汇编语言基于x86处理器第七版,含答案(习题答案,编程答案),教师资源,PPT等

原书:Assembly Language for x86 Processors Seventh Edition

你可能感兴趣的:(生活,深度学习,动态规划,机器学习)