简单汇编程序设计
来源:百度知道 编辑:UC知道 时间:2024/05/10 11:21:28
由10个数组成的字节数组:1,-2,3,0,60,-30,45,52,90,70 现要对其进行如下操作:
1.统计数组中正数个数 负数及零的个数。分别存数至c1,c2,c3变量中。
2.求该数组的累加和 结果存方在r1变量中。
要求用结构话的程序设计方法进行代码的编写
最好快点啊。急用
1.统计数组中正数个数 负数及零的个数。分别存数至c1,c2,c3变量中。
2.求该数组的累加和 结果存方在r1变量中。
要求用结构话的程序设计方法进行代码的编写
最好快点啊。急用
做的匆忙,细节还要你自己修改一下:)
第一题
datarea segment
arr db 1,-2,3,0,60,-30,45,52,90,70
len dw 10 ;length of arr
positive db 10 dup(?) ;>0
c1 dw ?
negative db 10 dup(?) ;<0
c2 dw ?
c3 dw ?
datarea ends
coderea segment
main proc far
assume cs:coderea,ds:datarea
start:
push ds
sub ax,ax
push ax
mov ax,datarea
mov ds,ax
mov si,0 ;index of arr
mov di,0 ;index of positive
mov bx,0 ;index of negative
repeat:
cmp si,len
jge exit
cmp arr[si],0
jl movetonegative
jg movetopositive
inc si
jmp repeat
movetonegative:
mov al,arr[si]
mov negative[bx],al
inc bx
inc si
jmp repeat
movetopositive:
mov al,arr[si]