The CBW instruction

Convert a byte into a word.

The CBW instruction format

InstructionDescription
CBWAX := sign extension of AL.

Doubles the size of the source operand by means of sign extension. The cbw (convert byte to word) instruction copies the sign (bit 7) of the source operand into every bit of the ah register.

Usage example

title Author: Evgeny Sergeevich Dovgopolov

.model small
.stack 100h

code segment public        ; Start of the code segment
    assume cs:code

    main proc              ; Start of the main procedure
        mov     al, 79     ; Copy the value 79 into the al register
        cbw                ; Perform sign extension

        mov     al, -4     ; Copy the value -4 into the al register
        cbw                ; Perform sign extension

        mov     ax, 4C00h  ; Copy the process termination function number into ah and the value into al
        int     21h        ; Call the interrupt
    main endp              ; End of the main procedure

code ends                  ; End of the code segment
end main                   ; End of file. The main procedure is the entry point

Example taken from the textbook "HANDYFAR - MASM (Evgeny Sergeevich Dovgopolov)".

Processor status flags

CF
No
PF
No
AF
No
ZF
No
SF
No
TF
No
IF
No
DF
No
OF
No