Monday, 18 July 2016

Write a program in assembly language(8086) to matching two strings of same length stored in memory locations.


DATA SEGMENT
        PASSWORD DB 'FAILSAFE'
        DESTSTR DB 'FEELSAFE'
        MESSAGE DB 'String are equal $'
DATA ENDS
CODE SEGMENT
        ASSUME CS:CODE, DS:DATA, ES:DATA
        MOV AX, DATA
        MOV DS, AX
        MOV ES, AX
        LEA SI, PASSWORD
        LEA DI, DESTSTR
        MOV CX, 08
        CLD

        REPE CMPSB
        JNE NOTEQUAL
        MOV AH, 09
        MOV DX, OFFSET MESSAGE
        INT 21h
NOTEQUAL:
        MOV AX, 4C00h
        INT 21h
CODE ENDS
END


Write a program in assembly language(8086) to convert an ASCII input to equivalent hex digit that it represents.


DATA SEGMENT
        ASCII DB 39h
DATA ENDS
CODE SEGMENT
        ASSUME CS:CODE, DS:DATA
START:
        MOV AX, DATA
        MOV DS, AX
        MOV AL, ASCII

        CMP AL, 30h
        JB ERROR
        CMP AL, 3Ah
        JB NUMBER
        CMP AL, 41h

        JB ERROR
        CMP AL, 46h
        JA ERROR
        SUB AL, 37h
        JMP CONVERTED
NUMBER:
        SUB AL, 30h
        JMP CONVERTED
ERROR:
        MOV AL, 0FFh
CONVERTED:
        MOV AX, 4C00h
        INT 21h
CODE ENDS
END START

Write a program in assembly language(8086) to convert the ASCII code to its BCD equivalent.


CODE SEGMENT
        ASSUME CS:CODE
START:
        MOV BL,'5'
        MOV AL,'9'
        AND BL,0Fh
        AND AL,0Fh
        MOV CL,04h
        ROL BL,CL
        OR AL,BL
CODE ENDS
END START

Popular Posts