CDA-4101 Lecture 22 Notes




Data Types


Numeric Data Types


Non-Numeric Data Types


Machine Data Types

Pentium UltraSPARC II JVM
  • signed integer (8, 16 and 32 bits)
  • unsigned integer (8, 16 and 32 bits)
  • BCD (8 bits)
  • floating point (32 and 64 bits)
  • characters (ASCII)
  • strings (fixed length and null terminated)
  • signed integer (8, 16 and 32 bits)
  • unsigned integer (8, 16 and 32 bits)
  • floating point (32, 64 and 128 bits)
  • signed integer (8, 16 and 32 bits)
  • floating point (32 and 64 bits)
  • characters (16 bit UNICODE)
  • pointers (limited support)


Instruction Formats

  • Some machines have all instructions the same length, others variable length
  • Am advantage of them all being the same length is easier decoding
  • A disadvantage of this is wasted space, since all instructiosn need to accomodate the longest one.

Expanding Op-codes


Expanding Op-code Example

4-bit op-codes (14) 6-bit op-codes (7) 9-bit op-codes (8)
0000  aaa aaaa aaaa
0001  aaa aaaa aaaa
0010  aaa aaaa aaaa
0011  aaa aaaa aaaa
0100  aaa aaaa aaaa
0101  aaa aaaa aaaa
0110  aaa aaaa aaaa
0111  aaa aaaa aaaa
1000  aaa aaaa aaaa
1001  aaa aaaa aaaa
1010  aaa aaaa aaaa
1011  aaa aaaa aaaa
1100  aaa aaaa aaaa
1101  aaa aaaa aaaa


    
1110 00  aa aaaa aaaa
1110 01  aa aaaa aaaa
1110 10  aa aaaa aaaa
1110 11  aa aaaa aaaa
1111 00  aa aaaa aaaa
1111 01  aa aaaa aaaa
1111 10  aa aaaa aaaa


    
1111 1100  0  aaa aaaa
1111 1100  1  aaa aaaa
1111 1101  0  aaa aaaa
1111 1101  1  aaa aaaa
1111 1110  0  aaa aaaa
1111 1110  1  aaa aaaa
1111 1111  0  aaa aaaa
1111 1111  1  aaa aaaa



Addressing


Explicit and Implicit Addressing


Addressing Modes


Immediate Addressing


Direct Addressing

  • memory address encoded directly in the instruction
  • value can change, but address determined at compile/assemble time
  • can only really be used for global constants

Register Addressing


Register Indirect Addressing

  • the memory address of the operand is stored in a register, and the register number is stored in the instruction
  • Here's some generic assembly code for summing all elements of an array A

           MOV R1,#0           ; accumulate the sum in R1, initially 0
           MOV R5,#A           ; R5 = address of the array A
           MOV R3,#A+4096      ; R3 = address of first word beyond A
    LOOP:  ADD R1,(R5)         ; register indirect through R5 to get operand
           ADD R5,#4           ; increment R5 by one word (4 bytes)
           CMP R5,R3           ; are we done yet?
           BLT LOOP            ; if R5 < R3, we are not done, so continue
      

  • note the special assembly language syntax for this mode of addressing
  • note the separation of the comparison from the branch: the comparison will set status bits, the branch uses the current status bits to branch (IJVM rolls both these into one instruction)
"...the Pentium II's standard assembly language syntax (MASM) verges on the bizarre..." --- A.S. Tanenbaum

Indexed Addressing


Based-Indexed Addressing


Stack Addressing

  • old news