Assembly 如何调用过程并打印它?
大家好,在一切发生之前,我是一个新手,正在努力理解它。我有一个tasm的过程,我试图进行一个系统调用并打印这个过程的输出,但我找不到如何进行系统调用Assembly 如何调用过程并打印它?,assembly,x86,Assembly,X86,大家好,在一切发生之前,我是一个新手,正在努力理解它。我有一个tasm的过程,我试图进行一个系统调用并打印这个过程的输出,但我找不到如何进行系统调用 .MODEL small .DATA ;The string to be printed STRING DB '047119047', '$' .CODE ; Purpose: ; Calculates the check digit for
.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上是必需的):
这是什么站台?系统调用的方式高度依赖于此。我目前正在使用Tasm,但我也有emu8086。这两个都很好。谢谢你,我实际上正在尝试使用这个过程,并尝试在过程中将字符串值(9位数字)作为[isbn]变量,然后得到输出。
mov si, offset STRING
mov dl, [si]
More:
mov ah, 02h ; DOS.PrintChar
int 21h
inc si
mov dl, [si]
cmp dl, '$'
jne More