Advertisement
4doorsmorehories

8086 Add two 4bit no.

Jan 4th, 2023
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ASM (NASM) 0.89 KB | Source Code | 0 0
  1. Addition Of Two 4bit numbers
  2.  
  3. ASSUME CS:CODE,DS:DATA
  4. DATA SEGMENT
  5.     msg1 DB "Enter the first number : $"
  6.     msg2 DB 0ah,0dh,"Enter the second number : $"
  7.     msg3 DB 0ah,0dh,"Result :$"
  8. DATA ENDS
  9. CODE SEGMENT
  10. START: MOV AX,data
  11.     MOV DS,AX
  12.     LEA DX,msg1
  13.     MOV AH,09H
  14.     INT 21H
  15.     MOV AH,01H
  16.     INT 21H
  17.     SUB AL,30H
  18.     MOV BL,AL
  19.     LEA DX,msg2
  20.     MOV AH,09H
  21.     INT 21H
  22.     MOV AH,01H
  23.     INT 21H
  24.     SUB AL,30H
  25.     ADD AL,BL
  26.     AAA
  27.     ADD AL,30H
  28.     LEA DX,msg3
  29.     MOV AH,09H
  30.     INT 21H
  31.     MOV DL,AL
  32.     MOV AH,02H
  33.     INT 21H
  34.     MOV AH,4CH
  35.     INT 21H
  36. CODE ENDS
  37. END START
  38.  
  39. Output
  40. C:\><filename.exe>
  41. Enter the first number : 2
  42. Enter the second number : 5
  43. Result : 7
  44.  
  45.  
  46.  
  47. DosBox Commands
  48.  
  49. accessing directory
  50. MOUNT C: ~/Downloads/masm
  51. C:                          //accesing to C
  52.  
  53. masm <filename.asm>         //compiling
  54. link <filename.obj>
  55. <filename.exe>              //executing file
  56.  
  57. debug <filename.exe>        //incase an error occur, debug the file
  58. -g
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement