05-02-2011, 10:40 PM
[org 0x0100]
jmp start
num: db 117 ; 8bit number
NumMask: db 255
start: mov bl, [num] ; Copies 117 to bx register
not bl ; Inverting number to get 1’s complement using NOT
add bl,1 ; adding 1 to 1’s complement to get 2’s complement
; Inverting bits using XOR
mov dl, [num]
xor dl, [NumMask]
add dl, 1
mov ax, 0x4c00 ; terminate program
int 0x21
Another solution of this question is
[org 0x100]
jmp start
number: dw 13
start:
mov ax,[number]
xor ax,0xffff
inc ax
mov ax,0x4c00
int 21h
jmp start
num: db 117 ; 8bit number
NumMask: db 255
start: mov bl, [num] ; Copies 117 to bx register
not bl ; Inverting number to get 1’s complement using NOT
add bl,1 ; adding 1 to 1’s complement to get 2’s complement
; Inverting bits using XOR
mov dl, [num]
xor dl, [NumMask]
add dl, 1
mov ax, 0x4c00 ; terminate program
int 0x21
Another solution of this question is
[org 0x100]
jmp start
number: dw 13
start:
mov ax,[number]
xor ax,0xffff
inc ax
mov ax,0x4c00
int 21h
