编程求1-200中所有奇数之和,结果以16进制数据显示到屏幕上
答案:2 悬赏:30 手机版
解决时间 2021-03-18 09:02
- 提问者网友:沦陷
- 2021-03-17 21:43
编程求1-200中所有奇数之和,结果以16进制数据显示到屏幕上
最佳答案
- 五星知识达人网友:慢性怪人
- 2021-03-17 22:26
assume cs:code, ds:data
data segment
tbl db '0123456789ABCDEF'
data ends
code segment
begin:
mov ax,data
mov ds,ax
mov cx, 200
xor di, di
l1:
test cx, 1
jz l2
add di, cx
l2:
loop l1
mov cx, 4
mov si, 4
mov bx, offset tbl
next:
rol di, cl
mov ax, di
and al, 0fh
xlat
mov dl, al
mov ah, 2
int 21h
dec si
jnz next
mov ax, 4c00h
int 21h
code ends
end begin
data segment
tbl db '0123456789ABCDEF'
data ends
code segment
begin:
mov ax,data
mov ds,ax
mov cx, 200
xor di, di
l1:
test cx, 1
jz l2
add di, cx
l2:
loop l1
mov cx, 4
mov si, 4
mov bx, offset tbl
next:
rol di, cl
mov ax, di
and al, 0fh
xlat
mov dl, al
mov ah, 2
int 21h
dec si
jnz next
mov ax, 4c00h
int 21h
code ends
end begin
全部回答
- 1楼网友:爱难随人意
- 2021-03-17 22:55
程序代码如下:
data segment
a dw ?
b db 'result=$'
c db 'h',0dh,0ah,'$'
data ends
stack1 segment para stack
dw 20h dup(?)
stack1 ends
code segment
assume ds:data,ss:stack1,cs:code
start: mov ax,data
mov ds,ax
lea dx,b
mov ah,9
int 21h
;***********
mov bx,0
mov cx,400
count: mov ax,01h
and ax,cx
cmp ax,01h
jne odd
add bx,cx
odd: loop count
mov a,bx
;***********
mov cx,size a
sal cx,1
next: mov al,4
mov dx,0
lop: shl bx,1
rcl dx,1
dec al
jne lop
cmp dl,10
jae char
add dl,30h
jmp disp
char: add dl,37h
disp: mov ah,2
int 21h
loop next
;***********
lea dx,c
mov ah,9
int 21h
mov ah,4ch
int 21h
code ends
end start
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯