ext
Sign-extend
Sign-extends a data register’s low byte to word or its low word to long.
Sizes .w .l, .w by default
Used in
- Bytes, words and longsM68K assembly
- trap #15 and its tasksM68K assembly
- Flappy ASMM68K assembly
- Numbers and sizesAssembly basics
XNZVC –●●00
- ● depends on the result
- 0 always 0
- – not changed
Forms
ext
Operands
Dn- A data register,
d0tod7. More
ext.w, the default, copies the byte’s sign bit into bits 8 through 15 and leaves the upper word unchanged. ext.l copies the word’s sign bit into bits 16 through 31. The newly filled bits are 1 for a negative input and 0 for a nonnegative input.
* --- Byte to word: sign-extends byte in low word ---
move.l #$0000007F, d0
ext.w d0 ; d0 = $0000007F (positive, no change)
move.l #$000000FF, d1
ext.w d1 ; d1 = $0000FFFF (-1 sign-extended)
* --- Word to long: sign-extends word ---
move.l #$00008000, d2
ext.l d2 ; d2 = $FFFF8000