在打印组件3位数 [英] Printing 3 digits in assembly

查看:181
本文介绍了在打印组件3位数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的打印功能,它应该输出3digit结果。我存储我的结果RES这是一个数据仓库。 push和pop固定我的问题,在打印前,现在我不知道哪里出了问题。

  XOR AX,AX
XOR BX,BX    ;这把我3digit号100给了我,百位
MOV AX,RES
MOV BX,100
DIV BX    ;打印百位数
ADD AL,'0'
MOV DL,AL
PUSH AX; AX保存在栈上
MOV AH,02H
INT 21H
POP AX;恢复斧    ;除以10的余数给了我十位
MOV BX,10
DIV BX    ;打印我的十位数
ADD AL,'0'
MOV DL,AL
PUSH AX; AX保存在栈上
MOV AH,02H
INT 21H
POP AX;恢复斧    ;打印我的最后的剩余这是我的人
ADD AH,'0'
MOV DL,AH
MOV AH,02H
INT 21H


通过BX斧:

解决方案

DIV BX分DX。那么,什么是你的DX?

This is my printing function, it should output a 3digit result. I store my result in RES which is a dw. The push and pop fixed my problems with printing before now I don't know where it goes wrong.

XOR AX, AX
XOR BX, BX

    ;this divides my 3digit number by 100 giving me my, hundredth digit
MOV AX, RES
MOV BX, 100
DIV BX

    ;prints the hundredth digit
ADD AL, '0'
MOV DL, AL
PUSH AX ; save AX on the stack 
MOV AH, 02h
INT 21h
POP AX ; restore ax

    ;divides the remainder by 10 giving me my tens digit
MOV BX, 10
DIV BX

    ;prints my tens digit
ADD AL, '0'
MOV DL, AL
PUSH AX ; save AX on the stack
MOV AH, 02h
INT 21h
POP AX ; restore ax

    ;print my last remainder which is my ones
ADD AH, '0'
MOV DL, AH
MOV AH, 02h
INT 21h

解决方案

"div bx" divides dx:ax by bx. So, what is your dx?

这篇关于在打印组件3位数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆