鱼C论坛

 找回密码
 立即注册
查看: 1551|回复: 2

大家来看看我实验十的第三小题这样写有问题没

[复制链接]
发表于 2013-1-3 22:53:33 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能^_^

您需要 登录 才可以下载或查看,没有账号?立即注册

x
assume cs:code
data segment
db 10 dup (0)
data ends
  code segment
  start: mov ax,12666
         mov bx,data
                 mov ds,bx
                 mov si,0
                 call dtoc
                 
                 mov dh,8
                 mov dl,3
                 mov cl,2
                 call show_str
                 
                 mov ax,4c00h
                 int 21h
                 
                 
                 
                show_str: push ax
                       push bx
                           push si
                           push es
                           mov bx,0b800h
                           moc es,bx
             dtoc: mov cx,ax
                   jcxz ok
                   div ax
                           add dx,30h
                           mov ds:[si],dl
                           inc si
                           jamp offste dtoc
                          
               ok:
                       mov si,0
                  
                       mov al,2
                           mov di,1123h
                           mov cx,ds:[si]
                           jcxz s
                           mov dl,ds:[si]
                           mov es:[di],dl
                           inc di
                           mov es:[di],al
                           inc si
                           inc di
                           jamp ok
                          s: pop ax
                 pop bx
                 pop si
                 pop es
                 ret
                 code ends
                 end start
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2013-1-4 11:20:11 | 显示全部楼层
会出现溢出。。还有就是JAMP&MOC这样的笔误要多留心。
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
发表于 2013-1-4 17:42:03 | 显示全部楼层
assume cs:code
data segment
I DW 10 dup (0) 
SAX DW ?
data ends 

code segment
start: mov ax,12666
mov bx,data
mov ds,bx
mov si,0
call dtoc

mov dh,8
mov dl,3
mov cl,2
call show_str

mov ax,4c00h
int 21h

;==================================
;字符串显示 
;================================== 
show_str:
PUSH SI
PUSH DI
PUSH CX
PUSH DX
MOV AX,0B800H
MOV ES,AX
SUB DI,DI 

ADD DL,DL
SUB AX,AX
MOV AL,DL
MOV DI,AX
MOV AL,DH
MOV AH,0 
MOV BX,160
MUL BX
ADD DI,AX


LOOP_: MOV AL,DS:[SI]
CMP AL,0
JZ EXIT_
INC SI
MOV ES:[DI],AL
INC DI
MOV ES:[DI],CL
INC DI 
JMP LOOP_
EXIT_:

POP DX
POP CX
POP DI
POP SI 
RET
;==================================
;ASCII码转换DTOC 
;================================== 
dtoc: 
PUSH SI
PUSH DI
PUSH BP
PUSH CX 
MOV CX,0
MOV BX,10


TEST AX,DX
JNZ EXIT 
MOV SAX,AX
MOV AX,DX
XOR DX,DX
CMP AX,0
JZ AX_PROC
DX_PROC:DIV BX
ADD DX,30H 
PUSH DX 
SUB DX,DX
INC CX
CMP AX,0
JNZ DX_PROC
AX_PROC:
MOV AX,SAX
TEST AX,DX
JNZ POP_
AX_: DIV BX
ADD DX,30H
PUSH DX
XOR DX,DX
INC CX
CMP AX,0
JNZ AX_ 
POP_: 
POP DS:[SI]
INC SI
LOOP POP_ 
EXIT: POP CX
POP BP
POP DI
POP SI
ret
code ends
end start
想知道小甲鱼最近在做啥?请访问 -> ilovefishc.com
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

小黑屋|手机版|Archiver|鱼C工作室 ( 粤ICP备18085999号-1 | 粤公网安备 44051102000585号)

GMT+8, 2024-10-8 00:31

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回复 返回顶部 返回列表