- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
我目前正在学习 Windows/DOS 汇编。我只是在制作一个小程序,将两个以 10 为底的整数相加,并将结果输出到标准输出。这是我当前的代码:
org 100h
MOV al,5
ADD al,3
mov dx,al
mov ah,9
int 21h
ret
我很困惑为什么在编译时出现错误:
错误:操作码和操作数的组合无效
因为理论上我就是把5放到AL寄存器里,加上3,把AL寄存器的内容取出来放到DX寄存器里输出,然后显示出来。
任何帮助将不胜感激,谢谢!
最佳答案
DX
是 16 位寄存器,而 AL
是 8 位寄存器。
将AL
载入DL
,并设置DH
为0。
但这不会做你想做的;函数 9 [显示以 null 结尾的字符串]。您告诉它显示一个从数据段的偏移量 9 开始的字符串,这可能是垃圾。
您需要先将您的答案转换成一系列数字,然后调用函数 9。
converting the contents of a register to a string 有一些示例代码可用的。复制于此以供引用,由别名为 Bitdog 的用户撰写.
; ------ WDDD = Write a Decimal Digit Dword at the cursor & a CRLF ------
;
; Call with, DX:AX = Dword value to print
; Returns, CF set on error, if DX:AX > 655359 max#
; (see WDECEAX.inc for larger number prints)
align 16
WDDD: CMP DX,10
JB WDDDok
STC ;CF=set
RET ;error DX:AX exceeded max value
WDDDok: PUSH AX
PUSH BX
PUSH CX
PUSH DX
XOR CX,CX ; clear count register for push count
MOV BX,10
WDDDnz: DIV BX ; divide DX:AX by BX=10
PUSH DX ; put least siginificant number (remainder) on stack
XOR DX,DX ; clear remainder reciever for next divide
OR AX,AX ; check to see if AX=number is divided to 0 yet
LOOPNE WDDDnz ; get another digit? count the pushes
MOV AH,2 ; function 2 for interupt 21h write digit
NEG CX ; two's compliment, reverse CX
MOV BL,48 ; '0'
WDDDwr: POP DX ; get digit to print, last pushed=most significant
ADD DL,BL ; convert remainder to ASCII character
INT 21h ; print ascii interupt 21h ( function 2 in AH )
LOOP WDDDwr ; deincrement CX, write another, if CX=0 we done
MOV DL,13 ; CR carriage return (AH=2 still)
INT 21h
MOV DL,10 ; LF line feed
INT 21h
POP DX
POP CX
POP BX
POP AX
CLC ;CF=clear, sucess
RET
; A divide error occurs if DX has any value
; when DIV trys to put the remainder into it
; after the DIVide is completed.
; So, DX:AX can be a larger number if the divisor is a larger number.
关于Windows/DOS 汇编 - 简单数学,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1297808/
在MS-DOS中,如果输入dir *.pdf,我将在目录中获取所有PDF文件。除了PDF文件,有什么方法可以获取所有内容?像dir !*.pdf一样? 谢谢! 最佳答案 我认为findstr有一个/v
我们如何在 DOS 中实现递归目录列表? 我正在 DOS 中寻找一个命令或脚本,它可以为我提供类似于 Unix 中的 ls -R 命令的递归目录列表。 最佳答案 您可以使用: dir /s 如果您需要
当我使用 ren "C:\folder\file""C:\folder\file.txt" 出现错误“命令的语法不正确。” 但是如果我 CD 到文件夹并使用 ren "file""file.txt"
比如,我能不能做 回显 3 + 5 并得到 8? 是否可以使用日期进行计算? 最佳答案 您可以使用set/a 来计算数学表达式: set /a x=3+5 echo %x% 编辑:这是一行: @for
我正在寻找一个 DOS 脚本来删除根目录中的所有文件和子目录,但根目录中的一组批处理文件 (*.bat) 除外。任何 DOS 运动员都知道一种简单的方法来做到这一点? 更新 谢谢大家的帮助。这就是我现
如何在目录及其子目录中搜索文件并以简洁的格式显示文件名及其创建时间。 我尝试了dir sam.csv/b/s/a-d 但是不起作用。 输出应该如下所示 c:\Data\Sam.txt 10/10/20
我有一个在并发 DOS 3.1 上运行的软件,我使用 QEMU 5.1 对其进行模拟。 在此程序中,有多个打印数据的选项。问题是到达我的主机的数据与发送的数据不对应。 启动qemu的命令: qemu-
我有一个在并发 DOS 3.1 上运行的软件,我使用 QEMU 5.1 对其进行模拟。 在此程序中,有多个打印数据的选项。问题是到达我的主机的数据与发送的数据不对应。 启动qemu的命令: qemu-
在 C 中,我如何写入特定的内存位置,例如视频内存 b800,在 DOS 下(真正的 DOS,MS DOS 6.22) 我知道 C 没有内置任何东西可以做到这一点,但可能有一些特定于平台的东西,例如可
我有一个大约 15 年前购买的非常古老的应用程序,它由 5 个 .exe 文件组成,用于存储患者的个人资料和信息。问题是该应用程序被编程为在特定计算机上运行。 由于我对破解知之甚少,我尝试使用 win
这个问题已经有答案了: How to redirect stderr to null in cmd.exe (1 个回答) 已关闭 4 年前。 我想抑制在 DOS 下运行的脚本的输出,类似于 *nix
我想从 MATLAB 在 dos 中执行一个批处理文件,并立即将控制权返回给 MATLAB。但是,我想在不打开 dos 窗口的情况下执行此操作(或者,至少,让 dos 窗口在最后消失)。 如果我这样格
最初... 我在 10 年前(大学)开始用 C 编程。我使用的 IDE 是 Turbo C++ IDE。 我所有的 c 程序都是 16 位的。 内存模型:巨大。 图形:4 位(16 色)。 图形驱动:
关闭。这个问题是off-topic .它目前不接受答案。 想改善这个问题吗? Update the question所以它是 on-topic对于堆栈溢出。 11 年前关闭。 Improve this
我需要一个批处理文件中的脚本,当我运行它时,它会将我昨天的日期放入一个变量中。包括 3 月 1 日等条件(根据年份可能是 2 月 28 日或 29 日) 最佳答案 假设您的意思是 ms-dos 批处理
我有一个可以做几件事的批处理文件。如果其中一个失败,我想退出整个程序。例如: @echo off type foo.txt 2>> error.txt >> success.txt mkdir bob
我正在尝试编写一个批处理脚本,将多个 css 文件合并到一个文件中。到目前为止,我已经想出了这个...... # Set start folders & files set fn1=filename.
我有不同的文件夹,例如:a、b、c 等,每个文件夹都有不同的文件,例如:x、y、z 等。 文件 x,y,z 位于每个文件夹中。有没有办法使用单个命令从不同文件夹复制每个文件?我希望结果是所有文件夹中的
我需要获取命令行输出的第一行而不是所有行,例如,如果我给 C:\Temp> dir 我只需要显示第一行, 11/15/2012 06:58 PM
如何使用 dos 批处理文件命令将日期设置为当前日期。 最佳答案 如果您需要在批处理文件中使用当前日期,则变量 %date% 具有当前日期: echo %date% 23/02/2010 它使用您计算
我是一名优秀的程序员,十分优秀!