programb1 - Microprocessors& Applications(UPTU ØØ...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the 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. 000 1 SUB 1 AX, 001 1 010 0 = 1234 H 111 0 NEG AX 001 0 110 1 110 0 110 0 = EDCC – 1 111 0 • ØØ 110 1 110 0 101 1 = EDCB i.e. 1’s complement of 1234 H = EDCB. Algorithm : Step I Step II Step III Step IV Step V 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 .data a dw 1234H .code mov ax, @data mov ds, ax mov ax, a neg ax sub ax, 1 mov ch, 04h mov cl, 04h mov bx, ax l2: rol bx, cl mov dl, bl and dl, 0fH cmp dl, 09 jbe 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 l4: add mov int dec jnz mov int end ØØ dl, 07 dl, 30H ah, 02 21H ch l2 ah, 4cH 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 Passes: 1 Remaining memory: 438k C:\programs>tlink 1'scomp.obj Turbo Link Version 3.0 Copyright (c) 1987, 1990 Borland International Warning: No stack C:\programs>1'scomp EDCB 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.

Page1 / 2

programb1 - Microprocessors& Applications(UPTU ØØ...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online