assembly - 如何调用一个程序并打印它?
问题描述
您好,在一切之前,我是组装新手并试图理解它。我有一个 tasm 程序,我正在尝试进行系统调用并打印此程序的输出,但我找不到如何进行系统调用。
.MODEL small
.DATA
;The string to be printed
STRING DB '047119047', '$'
.CODE
; Purpose:
; Calculates the check digit for a ten digit ISBN, converts that
; digit to its ASCII representation and returns that answer.
;
; Entry:
;
; isbn = a nine digit ASCII string containing the ISBN
; (with or without the check digit which is not used here)
;
; Register usage within the routine:
;
; AL = current ISBN digit
; AH = sum of digits so far
; BX = start pointer into ISBN for each outer loop
; CX = digit counter (inner loop)
; DX = start value for digit counter
; SI = points to current ISBN digit
;
; Exit:
;
; AX = ASCII representation of calculated check digit
;
; Trashed:
; none
;
;***************************************************************************/
isbncheck proc C isbn:ptr byte
push bx
push cx
push dx
push si
mov bx,[isbn] ;
mov dx,9 ; number of digits in raw ISBN
xor ax,ax ; clear out our total
cld ; count up
@@bigloop: ;
mov si,bx ; point to a digit in the ISBN
mov cx,dx ; get digit count in CX
@@AddEmUp: ;
lodsb ; fetch digit into AL
and al,0fh ; convert from ASCII
add ah,al ; add it to our total in AH
loop @@AddEmUp ; do all digits
inc bx ; and advance the digit pointer
dec dx ; now decrement digit count
jnz @@bigloop ; keep going if digits left
mov al,ah ; move sum into al
xor ah,ah ; clear out high half
mov cl,11 ; we'll be doing a mod 11 operation
div cl ; ah = sum mod 11
mov al,ah ; move calculated check digit to AL
xor ah,ah ; clear out high half
or al,30h ; convert to ASCII digit
cmp al,3Ah ;
jnz NotTen ;
mov al,'X' ;
NotTen: ;
pop si
pop dx
pop cx
pop bx
ret ; return
isbncheck endp
END
我希望你们能帮助我。如果我的问题不清楚,请告诉我。所以我可以更清楚地解释它。
解决方案
我正在尝试进行系统调用并打印此过程的输出
;The string to be printed STRING DB '047119047', '$'
由于我可以看到字符串以 '$' 结尾,因此我将向您展示如何在 DOS 环境中执行此操作:
mov dx, offset STRING
mov ah, 09h ; DOS.PrintString
int 21h
这将从光标所在的屏幕开始输出这 9 个数字(不包括仅用作终止符的“$”字符)。此后光标将超出最后一个字符。
或者,您可以使用循环。这将允许您不必使用那个 '$' 终止符(函数 09h 强制):
mov si, offset STRING
mov dl, [si]
More:
mov ah, 02h ; DOS.PrintChar
int 21h
inc si
mov dl, [si]
cmp dl, '$'
jne More
推荐阅读
- javascript - 是否可以使用 Flow 禁用某种类型的错误?
- php - 上传的 PHP 文件未显示在文件夹中
- python - 如何使用字符串用户输入对 3 个数字进行减法、除法或求幂
- php - 为什么扩展类在 Laravel 中与 Modules 没有关系?
- kubernetes - Kubernetes 服务在与分配端口不同的端口上响应
- python - 无法将数据帧写入 db2。收到错误:意外的令牌“?” 发现以下“
- node.js - NodeJS API 测试
- java - Hadoop Hdfs DFSAdmin - 无法初始化集群或 hdfs 指向 file:/// 而不是 hdfs://
- javascript - Django,如何对 JsonResponse 进行分页?
- c# - 在实体框架中处理嵌套对象