salarjan
سه شنبه 13 تیر 1391, 15:37 عصر
عزیزان و مهندسین
خواهشا حداقل به این سوال من پاسخ بدین
چطور میشه برای این کد (جمع 2 عدد بزرگ)
به جای دو رشته ثابت
x db "75000000000000000000"
y db "25536000000000000000"
ورودی رو از کیبورد گرفت
; add your data here!
pkey db 13,10,"press any key...$"
x db "75000000000000000000"
y db "25536000000000000000"
sum db 5 dup(0)
MAX EQU 19
dw 128 dup(0)
start:
; set segment registers:
; add your code here
;convert char to int
mov cx,MAX + 1
mov bx,MAX
x1:
sub x[bx],30h
sub y[bx],30h
dec bx
loop x1
;sum char(number) array
xor si,si
mov si, MAX
mov cx,MAX
add_loop:
mov al,x[si]
mov ah,y[si]
add al,ah
cmp al,10
jae carry
add sum[si+1],al
jmp endcarray
carry:
sub al,10
add sum[si+1],al
add sum[si-1],1
endcarray:
dec si
loop add_loop
;convert int to char & display output
xor bx,bx
mov ah,2
x2:
add sum[bx],30h
mov dl,sum[bx]
int 21h
inc bx
cmp bx,MAX + 2
je endx2
jmp x2
endx2:
lea dx, pkey
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
ret
خواهشا حداقل به این سوال من پاسخ بدین
چطور میشه برای این کد (جمع 2 عدد بزرگ)
به جای دو رشته ثابت
x db "75000000000000000000"
y db "25536000000000000000"
ورودی رو از کیبورد گرفت
; add your data here!
pkey db 13,10,"press any key...$"
x db "75000000000000000000"
y db "25536000000000000000"
sum db 5 dup(0)
MAX EQU 19
dw 128 dup(0)
start:
; set segment registers:
; add your code here
;convert char to int
mov cx,MAX + 1
mov bx,MAX
x1:
sub x[bx],30h
sub y[bx],30h
dec bx
loop x1
;sum char(number) array
xor si,si
mov si, MAX
mov cx,MAX
add_loop:
mov al,x[si]
mov ah,y[si]
add al,ah
cmp al,10
jae carry
add sum[si+1],al
jmp endcarray
carry:
sub al,10
add sum[si+1],al
add sum[si-1],1
endcarray:
dec si
loop add_loop
;convert int to char & display output
xor bx,bx
mov ah,2
x2:
add sum[bx],30h
mov dl,sum[bx]
int 21h
inc bx
cmp bx,MAX + 2
je endx2
jmp x2
endx2:
lea dx, pkey
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
ret