Advertisement
Nahid8195

Lab 3 (print the hexa value of input)

Oct 28th, 2021
2,374
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;   Write a program to PRINT THE HEXA VALUE
  2. ;   Sample execution:
  3. ;   Enter letter between (A-F) :  A
  4. ;   IN HEXA DIGIT IT IS: 10
  5.  
  6.  
  7. .MODEL SMALL   ; IN THIS COURSE ALL MODEL ARE SMALL
  8. .STACK 100H    ; WE ALWAYS USE STACK 100H
  9.  
  10.  
  11. .DATA     ; DATA SEGMENT
  12.     A DB ?
  13.     MSG1 DB 'Enter letter between (A-F) : $'        ; to print the line  we store it on MSG1
  14.     MSG2 DB 0AH,0DH,"IN HEXA DIGIT IT IS: $"        ; we give new line and store it on MSG2
  15.    
  16.    
  17. .CODE
  18.  
  19.     MAIN PROC   ; main code start here
  20.  
  21.     ;PROGRAMME SEGMENT PREFIX
  22.     MOV AX,@DATA
  23.     MOV DS,AX    ; INITILATION OF DS
  24.  
  25.     MOV AH,9     ; the function will use to print string
  26.     LEA DX,MSG1  ; this print the str value
  27.     INT 21H      ; make this computer to do
  28.  
  29.     MOV AH,1     ; this will use to take input
  30.     INT 21H      ; make this work to get input
  31.     MOV A,AL     ; WE SHIFT THE INPUT INTO A
  32.    
  33.     MOV AH,9     ; the function will use to print string
  34.     LEA DX,MSG2  ; this print the str value
  35.     INT 21H      ; make this computer to do
  36.    
  37.    
  38.     MOV AH,2     ; the function will use to print
  39.     MOV DL,31H   ; WE PRINT 1 AS THE FIRST DIGIT OF EVERY ASCII VALUE FROM A-F...  A=10,B=11,C=12,D=13,E=14,F=15
  40.     INT 21H      ; make computer to do this
  41.    
  42.     MOV AH,2     ; the function will use to print
  43.     SUB A,11H    ; THIS WILL SUBTRACT 11H FROM A TO PRINT 0,1,2,3,4,5 AFTER 1
  44.     MOV DL,A     ; NOW MOVE THE FINAL VALUE INTO DL
  45.     INT 21H      ; THIS WILL COMPLETE THIS WORK
  46.  
  47.     MOV AH,4CH   ; TERMINATED THE CODE AND EXI
  48.     INT 21H
  49.  
  50.     MAIN ENDP
  51. END MAIN
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement