This preview has intentionally blurred sections. Sign up to view the full version.View Full Document
Unformatted text preview: Microprocessors & Applications (UPTU)
ØØ Appendix B Explanation :
• We have a number. Let the number be loaded in the register AX. Now, we have to find
1’s complement of this number. One’s complement of a number means to invert each bit
of a number. NEG instruction in 8086 allows us, to find 2’s complement of a number,
subtracting 1 from 2’s complement gives the 1’s complement of the number.
eg. : AX = 1234 H.
1 AX, 001
0 = 1234 H 111
0 NEG AX 001
0 = EDCC –
1 = EDCB i.e. 1’s complement of 1234 H = EDCB. Algorithm :
Step VI :
: Initialize the data memory.
Load the number in AX.
Find 2’s complement of number.
1’s comp = 2’s comp – 1.
Display the result.
Stop. ØØ Flowchart : Refer flowchart 1. ØØ Program : .model small
a dw 1234H
mov ax, @data
mov ds, ax
mov ax, a
mov ch, 04h
mov cl, 04h
mov bx, ax
mov dl, bl
and dl, 0fH
cmp dl, 09
l4 Flowchart 1 ; Initialize data section
; Load number1 in ax
; find 2's compement. Result in ax
; 1's complement=2's comp-1
; Count of digits to be displayed
; Count to roll by 4 bits
; Result in reg bx
; roll bl so that msb comes to lsb
; load dl with data to be displayed
; get only lsb
; check if digit is 0-9 or letter A-F Microprocessors & Applications (UPTU) add
ØØ dl, 07
21H ; if letter add 37H else only add 30H
; Function 2 under INT 21H (Display character)
; Decrement Count
; Terminate Program Result : C:\programs>tasm 1'scomp.asm
Turbo Assembler Version 3.0 Copyright (c) 1988, 1991 Borland International
Assembling file: 1'scomp.asm
Error messages: None
Warning messages: None
Remaining memory: 438k
Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International
Warning: No stack
C:\programs> Appendix B ...
View Full Document
This note was uploaded on 08/04/2011 for the course ECON 101 taught by Professor Lucky during the Spring '11 term at Silver Lake.
- Spring '11