Created
February 17, 2016 13:24
-
-
Save SohanChy/9b201870f00c33b67cee to your computer and use it in GitHub Desktop.
String printing in assembly 8086
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| .model small | |
| .stack 100h | |
| .data | |
| a db ? | |
| b db ? | |
| txt1 dw 'Enter 1st input: $' | |
| txt2 dw 'Enter 2nd input: $' | |
| txt3 dw 'a: $' | |
| txt4 dw 'b: $' | |
| txt5 dw 'sum: $' | |
| .code | |
| main proc | |
| mov ax,@data ;Load data? | |
| mov ds,ax | |
| lea dx,txt1 ;output first string | |
| mov ah,9 | |
| int 21h | |
| mov ah,1 | |
| int 21h ;input a | |
| mov a,al | |
| mov ah,2 | |
| mov dl,0ah | |
| int 21h | |
| mov dl,0dh ;output newline and caret ret | |
| int 21h | |
| mov ah,9 | |
| lea dx,txt2 ;output second string | |
| int 21h | |
| mov ah,1 | |
| int 21h | |
| mov b,al ;input b | |
| mov ah,2 | |
| mov dl,0ah | |
| int 21h | |
| mov dl,0dh ;output newline and caret ret | |
| int 21h | |
| mov ah,9 | |
| lea dx,txt3 ;output 3rd string | |
| int 21h | |
| mov ah,2 | |
| mov dl,a ;output value of a | |
| int 21h | |
| mov ah,2 | |
| mov dl,0ah | |
| int 21h | |
| mov dl,0dh ;output newline and caret ret | |
| int 21h | |
| mov ah,9 | |
| lea dx,txt4 ;output 4th string | |
| int 21h | |
| mov ah,2 | |
| mov dl,b ;output value of b | |
| int 21h | |
| mov ah,2 | |
| mov dl,0ah | |
| int 21h | |
| mov dl,0dh ;output newline and caret ret | |
| int 21h | |
| mov bl,a | |
| mov bh,b | |
| add bl,bh | |
| sub bl,30h | |
| mov a,bl | |
| mov ah,9 | |
| lea dx,txt5 ;output 5th string | |
| int 21h | |
| mov ah,2 | |
| mov dl,a ;output value of a | |
| int 21h | |
| main endp | |
| end main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment