Fortune Telling Collection - Fortune-telling birth date - How to Add Multi-digit Decimal Numbers in Assembly Language

How to Add Multi-digit Decimal Numbers in Assembly Language

Enter two decimal values within 10 from the keyboard, sum and display the result.

When the program runs, you will be prompted to enter addend and addend. After calculating and displaying the results, continue and exit will be displayed.

The code segment assumes cs:code, ds:code.

org 100h; Standard COM format

Start:

mov ax,3; text mode

int 10h

Push cs

Popular digital camera

Push ds

Popular element

Once again:

lea dx,mes 1; point out

mov ah,9

int 2 1h

mov di,30fh

Call input; Receiving number a

Lea dx, mes2 pointed out that

mov ah,9

int 2 1h

mov di,3 1fh

Call input; Receiving number b

Call counting; sue for peace

lea dx,mes3

mov ah,9

int 2 1h

; * * * Output decimal result * * *

Call crt

lea dx,mes4

mov ah,9

int 2 1h

mov ah,0; discontinue

int 16h

Cmp,15h; "Y(y)" continues.

Jz again; Calculate the next question

Mov ah, 4ch is over.

int 2 1h

Input:

mov CX 10

T 1:mov ah,0; Receiving number

int 16h

cmp al,0dh

jz ok

cmp al,“0”; data check

jb T 1

cmp al,' 9 '

ja t 1

Yes:

Mov ah, 0eh displays valid data.

int 10h

W2: Push the axe; Press into the stack

Loop T 1

Good: mobile bp, cx

Company bp

mov cx, 1 1

Subcx, bp

standard

jcxz u3

u 1:pop ax

stosb

Loop u 1

U3: Move al,' 0'

mov cx,bp

U2:stob

Loop u2

Soak in water to soften

Count: mov si, 30fh

mov di,3 1fh

xor dx,dx; Clear carry

mov cx, 1 1; Changing this value can realize the addition of super numbers.

T3: call subs _ c;; Bitwise accumulation

4 December

December 2 nd

T3 loop

Soak in water to soften

subs _ c:; Multi-bit addition core subroutine

mov al,[si]; Lowest bit alignment

mov ah,[di]

And ax, 0f0fh.

Gael, ah; Self-adding

Add al, dl; Carry after addition

Aam turns two into ten.

mov dl,ah; carry bit

Or aluminum, 30h

mov [SI],al; Save the 1 bit and value, which is copied incorrectly here.

Soak in water to soften

crt:cld

XOR bp, bp

mov si,305h

mov CX 10

cr3:

mov al,[si]

cmp al,' 0 '

jnz cr0

Company bp

Company si

Cyclic cr3

cr0:

mov cx, 1 1

Subcx, bp

mov si,305h

Add si and bp.

cr 1:lodsb

Move, 0eh.

int 10h

Cyclic cr 1

Soak in water to soften

Mes 1 db 0dh, 0ah, 09,' input A(0-9, 999, 999, 999): $'

Mes2 db 0dh, 0ah, 09,' Enter B(0-9, 999, 999, 999): $'

mes3 db 0dh,0ah,09,' Sum A+B= $ '

Mes4 db 0dh, 0ah, 09,' Continue Y(y)? $'

End of code

End start