.model small
.stack 
.data
.code

start:
mov ah,1  
int 21h
mov ah,2
mov dl,0ah
int 21h
push ax
mov ah,1
int 21h
mov ah,2
int 21h
pop bx
add ax,bx
aaa
add al,30h
mov dl,al
mov ah,2
int 21h
end start

Ok guys?this is another addition program in tasm..
im using a different approach in adding 2 digits..
i was wondering why my 2nd input wont show even there is service 2,,can someone help me with this problem..thnks

You need something like the following. I did this in an editor so you'll have to debug it! Note the comments!

.model small
.stack 
.data
.code

start:
	mov ah,1  
	int 21h		; DOS - Read character from StdIn (Key)
		; al=char read

;	mov ah,2
;	mov dl,0ah	; WRITE LineFeed ????
;	int 21h		; DOS - Write character to StdOut
;		; NOTE: AL is now destroyed! as LineFeed was written!

;;; BASED upon your error, and this next push....
	mov	ah,2
	mov	dl,al
	int	21h

	push ax		; Save Old Character

	mov ah,1
	int 21h		; DOS - Read character from StdIn (Key)
		; al = char read

	mov ah,2
	int 21h		; DOS - Write character to StdOut

	pop bx		; Restore Old Character
		; al = 2nd char   bl = 1st char

; You aren't doing BCD so why are you using the instruction AAA ?

;;;	add ax,bx
;;;	aaa

	mov	ah,0
	add al,bl
	daa			; Decimal adjust  High Nibble, Low Nibble
                       ;ah=high digit, al=low digit

	mov	dh,al	; Save lower digit

	mov	dl,ah	; Upper digit
	add	dl,30h
	mov ah,2
	int 21h		; DOS - Write Digit Upper ASCII

	mov dl,dh	; Lower Digit
	add	dl,30h
	mov ah,2
	int 21h		; DOS - Write digit Lower ASCII



	end start

My mistake

Line #40 should be

;daa         ; Decimal adjust
aaa           ; Ascii adjust

daa puts result of two unpacked adds into upper nibble of al.
aaa adds the BCD (lower nibble) carry result onto the ah register. Why it needs to be pre-cleared.

ok thanks wildgoose im gona try and debug..cheers

awts... is this code right?im troubled by this codes.. NEW kid in town.. just studied assembly..can any1 help me out? here is me e-add..

lockheart_l@yahoo.com

sir can u make an assembly code that will add 2 input please?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.