Skip to content

Instantly share code, notes, and snippets.

@theArjun
Created May 27, 2019 14:11
Show Gist options
  • Select an option

  • Save theArjun/15d175747f4f27111f0b24dc728bec13 to your computer and use it in GitHub Desktop.

Select an option

Save theArjun/15d175747f4f27111f0b24dc728bec13 to your computer and use it in GitHub Desktop.
Add Two numbers from keyboard in 8086
.model small
.stack 100h
.data
first db 10,13, "Enter first character : $"
second db 10,13, "Enter second character : $"
output db 10,13, "The output is : $"
.code
main proc
mov ax, @data
mov ds, ax
; macro for displaying message
disp macro msg
lea dx, msg
mov ah, 09h
int 21h
endm
; macro for reading character from keyboard
read macro
mov ah, 01h
int 21h
endm
; printing character
print macro
mov ah, 02h
int 21h
endm
; first a message is displayed
disp first
; reading first character
read
; moving the input character to bl register
mov bl, al
; displaying the second message
disp second
; reading second character
read
; adding the content of al to bl
add bl, al
; the number is in ascii form, so converting into decimal.
sub bl, 30h
; displaying the output message
disp output
mov dl, bl
print
main endp
end main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment