2’s Complement of a Quantity Meeting Language
Write a Program to search out the 2’s Complement of quantity given by the person . Program ought to load quantity into register after which discover 2’s Complement of Quantity .
Algorithm behind the 2’s Complement is given beneath and primarily based on this technique you may simply implement 2’s Complement program in Meeting Language .
Algorithm for 2’s Complement of Quantity:
Step I : Initialize the information reminiscence.
Step II : Load the quantity in AX.
Step III : Discover 2’scomplement of quantity.
Step IV : Show the outcome.
Step V : Cease.
Movement Chart
Program for 2’s Complement :
1 |
<br/><br/>.mannequin small <br/> .knowledge <br/> a dw 1234H <br/> .code <br/> mov ax, @knowledge ; Initialize knowledge part <br/> mov ds, ax <br/> mov ax, a ; Load number1 in ax <br/> neg ax ; discover 2's compement. End in ax <br/> mov ch, 04h ; Rely of digits to be displayed <br/> mov cl, 04h ; Rely to roll by 4 bits <br/> mov bx, ax ; End in reg bx <br/> l2: rol bx, cl ; roll bl in order that msb involves lsb <br/> mov dl, bl ; load dl with knowledge to be displayed <br/> and dl, 0fH ; get solely lsb <br/> cmp dl, 09 ; test if digit is 0-9 or letter A-F <br/> jbe l4 <br/> add dl, 07 ; if letter add 37H else solely add 30H <br/> l4: add dl, 30H <br/> mov ah, 02 ; Perform 2 beneath INT 21H (Show character) <br/> int 21H <br/> dec ch ; Decrement Rely <br/> jnz l2 <br/> mov ah, 4cH ; Terminate Program <br/> int 21H <br/> finish |
Tips on how to Run this Program :
For Operating this program it’s best to have put in Tasm on you laptop .
C:applications>tasm 2’scomp.asm
Turbo Assembler Model 3.0 Copyright (c) 1988, 1991 Borland Worldwide
Assembling file: 2’scomp.asm
Passes: 1
Remaining reminiscence: 438okay
C:applications>tlink 2’scomp.obj
Turbo Hyperlink Model 3.Zero Copyright (c) 1987, 1990 Borland Worldwide
Warning: No stack
C:applications>2’scomp
EDCC
Supply projectgeek.com