
谁会用汇编语言在80x86里帮我写个【循环和分支结构设计多字节无符号加法运算】啊?
1个回答
2013-06-18
展开全部
; multi-segment executable file template.
data segment
mes1 db 'input x:',0dh,0ah,'$'
mes2 db 'input y:',0ah,0dh,'$'
mes3 db 'x+y=','$'
mes4 db 'input a number','$'
x db ?,'$'
y db ?,'$'
z db ?,'$'
ends
stack segment
dw 128 dup(0)
ends
code segment
assume cs:code,ds:data,es:data,ss:stack
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
ks: lea dx,mes1
mov ah,09h
int 21h ; output string at ds:dx
mov ah,01h ;输入X
int 21h
mov x,al
mov ah,x ;比较输入字符是否为数字
call bijiao
sub x,30h ;将X中数值转换为十进制数
lea dx,mes2
mov ah,09h
int 21h ; output string at ds:dx
mov ah,01h ;录入Y并判断Y是否为数字
int 21h
mov y,al
mov ah,y
call bijiao
sub y,30h
mov al,x
add al,y
mov z,al
add z,30h
call huiche
lea dx,mes3
mov ah,09h
int 21h
cmp z,39h
ja zh
jmp zj
zh: mov dl,31h
mov ah,02h
int 21h
sub z,0ah
zj: mov dl,z
mov ah,02h
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
;比较函数判断Ah中数值ASC码是否为数字
bijiao proc
cmp ah,39h
ja xianshi
cmp ax,30h
jb xianshi
call huiche
ret
xianshi: call huiche
lea dx,mes4
mov ah,09h
int 21h
call huiche
jmp ks
bijiao endp
;显示回车换行
huiche proc
mov dl,0dh ;执行回车+换行
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
ret
huiche endp
ends
end start ; set entry point and stop the assembler.
这是一个单字节的,你自己稍加修改就可以了,想当初这还是我们作业呢(第一节课)
data segment
mes1 db 'input x:',0dh,0ah,'$'
mes2 db 'input y:',0ah,0dh,'$'
mes3 db 'x+y=','$'
mes4 db 'input a number','$'
x db ?,'$'
y db ?,'$'
z db ?,'$'
ends
stack segment
dw 128 dup(0)
ends
code segment
assume cs:code,ds:data,es:data,ss:stack
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
ks: lea dx,mes1
mov ah,09h
int 21h ; output string at ds:dx
mov ah,01h ;输入X
int 21h
mov x,al
mov ah,x ;比较输入字符是否为数字
call bijiao
sub x,30h ;将X中数值转换为十进制数
lea dx,mes2
mov ah,09h
int 21h ; output string at ds:dx
mov ah,01h ;录入Y并判断Y是否为数字
int 21h
mov y,al
mov ah,y
call bijiao
sub y,30h
mov al,x
add al,y
mov z,al
add z,30h
call huiche
lea dx,mes3
mov ah,09h
int 21h
cmp z,39h
ja zh
jmp zj
zh: mov dl,31h
mov ah,02h
int 21h
sub z,0ah
zj: mov dl,z
mov ah,02h
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
;比较函数判断Ah中数值ASC码是否为数字
bijiao proc
cmp ah,39h
ja xianshi
cmp ax,30h
jb xianshi
call huiche
ret
xianshi: call huiche
lea dx,mes4
mov ah,09h
int 21h
call huiche
jmp ks
bijiao endp
;显示回车换行
huiche proc
mov dl,0dh ;执行回车+换行
mov ah,2
int 21h
mov dl,0ah
mov ah,2
int 21h
ret
huiche endp
ends
end start ; set entry point and stop the assembler.
这是一个单字节的,你自己稍加修改就可以了,想当初这还是我们作业呢(第一节课)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询