3 Replies - 5077 Views - Last Post: 10 June 2012 - 08:59 PM

#1 Guest_Rei*


Reputation:

Add 2 numbers and output it with 2 or more numbers

Posted 18 February 2010 - 07:06 AM

T_T I need your help. I encoded a program that you can input one integer and add it to another one integer, but my problem is the output. When the sum comes to a two integer it gives a wrong answer (to be specific a character), how can I fix this?

org 100h

jmp start
inp1 db 'Enter first number: ',24h
inp2 db 0dh,0ah,'Enter second number: ',24h
out1 db 0dh,0ah,0dh,0ah,'The first inputted number: ',24h
out2 db 0dh,0ah,'The second inputted number: ',24h
sum db 0dh,0ah,0dh,0ah,'The sum is: ',24h

start:

mov ah,9
mov dx,inp1
int 21h

mov ah,1
int 21h
mov dl,al
mov [1],dl      ;input first number 

mov ah,9
mov dx,inp2
int 21h

mov ah,1
int 21h
mov [2],al      ;input second number 

mov ah,9
mov dx,out1
int 21h

mov dx,[1]      ;output first number
mov ah,2
int 21h

mov ah,9
mov dx,out2
int 21h

mov dx,[2]      ;output second number
mov ah,2
int 21h

mov ah,9
mov dx,sum
int 21h

mov dl,[1]
mov bl,[2]
sub dl,30h ;here's my problem... if the sum is one digit it gives the correct answer, but if the sum is 2 digit integer, it gives an incorrect answer.. help plzz
sub bl,30h
add dl,bl
add dl,30h
mov ah,2
int 21h

mov ah,0
int 16h
int 20h


edit by ishkabible: please use code tags when posting code. like so, :code: thank you :)

This post has been edited by ishkabible: 18 July 2011 - 11:09 AM


Is This A Good Question/Topic? 0

Replies To: Add 2 numbers and output it with 2 or more numbers

#2 e3rtwin  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 05-October 09

Re: Add 2 numbers and output it with 2 or more numbers

Posted 18 July 2011 - 03:09 AM

View PostRei, on 18 February 2010 - 07:06 AM, said:

T_T I need your help. I encoded a program that you can input one integer and add it to another one integer, but my problem is the output. When the sum comes to a two integer it gives a wrong answer (to be specific a character), how can I fix this?

org 100h

jmp start
inp1 db 'Enter first number: ',24h
inp2 db 0dh,0ah,'Enter second number: ',24h
out1 db 0dh,0ah,0dh,0ah,'The first inputted number: ',24h
out2 db 0dh,0ah,'The second inputted number: ',24h
sum db 0dh,0ah,0dh,0ah,'The sum is: ',24h

start:

mov ah,9
mov dx,inp1
int 21h

mov ah,1
int 21h
mov dl,al
mov [1],dl ;input first number

mov ah,9
mov dx,inp2
int 21h

mov ah,1
int 21h
mov [2],al ;input second number

mov ah,9
mov dx,out1
int 21h

mov dx,[1] ;output first number
mov ah,2
int 21h

mov ah,9
mov dx,out2
int 21h

mov dx,[2] ;output second number
mov ah,2
int 21h

mov ah,9
mov dx,sum
int 21h

mov dl,[1]
mov bl,[2]
sub dl,30h ;here's my problem... if the sum is one digit it gives the correct answer, but if the sum is 2 digit integer, it gives an incorrect answer.. help plzz
sub bl,30h
add dl,bl
add dl,30h
mov ah,2
int 21h

mov ah,0
int 16h
int 20h


add it per bit..use..a jc jump instructions then make shift or rotate algorithm

This post has been edited by ishkabible: 18 July 2011 - 11:10 AM
Reason for edit:: please don't quote the same thing twice

Was This Post Helpful? 0
  • +
  • -

#3 rkdeiss  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 10-June 12

Re: Add 2 numbers and output it with 2 or more numbers

Posted 10 June 2012 - 08:30 PM

Did you get your code fixed. Can I please send me the fixed program

REK
Was This Post Helpful? 0
  • +
  • -

#4 GunnerInc  Icon User is online

  • "Hurry up and wait"
  • member icon




Reputation: 858
  • View blog
  • Posts: 2,302
  • Joined: 28-March 11

Re: Add 2 numbers and output it with 2 or more numbers

Posted 10 June 2012 - 08:59 PM

1. Your posting in a topic created 2 years ago.
2. Nobody is going to just give you a program our code. You must make an effort on your part.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1