Python,C,C++ and JAVA programs for CBSE, ISC, B.Tech and I.T Computer Science and MCA students

The Programming Project: ROGRAMMING IN 8086

Sunday, September 29, 2013

ROGRAMMING IN 8086

  1. Write an assembly program that converts a number in the word variable D, 0 <= D <= 15 to an ASCII character in the byte variable HEXD which is its hex value. For instance, if D = 3 then HEXD = ‘3’ and if D = 14 then HEXD = ‘E’.


TITLE  word variable to ASCII character
;----------------------------------------------------------------
     .MODEL SMALL
     .STACK 64
     .DATA
     ;ACODE   DB '0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'
     ACODE DB '0123456789ABCDEF'
     VALUE   DW 7  
     INDEX   DB 0
     HEXVAL  DB '?'  
;----------------------------------------------------------------
     .CODE
MAIN PROC FAR
     MOV AX,@DATA
     MOV DS,AX
     MOV ES,AX
     MOV CX,15
     LOOP:
            MOV AX,CX
            CMP AX,VALUE
            JE GOT
            INC INDEX
            DEC CX
            JNZ LOOP
     GOT:MOV AL,15
     SUB AL,INDEX
     MOV INDEX,AL
     MOV CL,INDEX
     INC CL
     LEA SI,ACODE
     LOOP1:MOV AL,[SI]
           MOV HEXVAL,AL
          INC SI
          DEC CL
          JNZ LOOP1
     MOV AX,4C00H
     INT 21H
MAIN ENDP
     END MAIN  ;END MAIN PROCEDURE
    

No comments:

Post a Comment