Slide 5.5: Data definition statements (cont.)
Slide 5.7: Multiple initializers
Home

Defining BYTE and SBYTE Data


     val0   SBYTE   50h+10h   ; integer expression
     val1   BYTE    'A'       ; character constant
     val2   BYTE    255       ; largest unsigned byte
     val3   SBYTE   -128      ; smallest signed byte
     val4   BYTE    ?         ; space allocated but not the value
Each initializer must be an 8-bit integer expression or character constant.
Type Usage
BYTE 8-bit unsigned integer
SBYTE 8-bit signed integer

 0 + (–10)  0 + 246  BYTE: (–10) + 20
 .data
 X   BYTE  -10
 .code
 sub   eax, eax
 add   al, X
 call  DumpRegs
 .data
 X   BYTE  246
 .code
 sub   eax, eax
 add   al, X
 call  DumpRegs
 .data
 X   BYTE  -10
 Y   BYTE   20
 .code
 sub   eax, eax
 add   al, X
 add   al, Y
 call  WriteInt
 Output  Output  Output
  EAX =  



  EAX =  



   




 SBYTE: (–10) + 20  SBYTE: 10 + (–20)  MOVSX: 10 + (–20)
 .data
 X   SBYTE  -10
 Y   SBYTE   20
 .code
 sub   eax, eax
 add   al, X
 add   al, Y
 call  WriteInt
 .data
 X   SBYTE   10
 Y   SBYTE  -20
 .code
 sub   eax, eax
 add   al, X
 add   al, Y
 call  WriteInt
 .data
 X   SBYTE   10
 Y   SBYTE  -20
 .code
 sub    eax, eax
 add    al, X
 add    al, Y
 movsx  eax, al
 call   WriteInt
 Output  Output  Output