回答
你试过int 21h
service 2? DL
是要打印的字符。
mov dl,'A' ; print 'A'
mov ah,2
int 21h
要打印的整数值,你必须写一个循环来分解整数单个字符。如果你可以用十六进制打印这个值,这很简单。
如果您不能依靠DOS服务,您可能也可以使用BIOS int 10h
和AL
设置为0Eh
或0Ah
。
真棒帮助..很长一段时间..到处都是mov啊,09这是用于打印数组而不是mov啊,02用于打印单个值。 – unrealsoul007 2014-04-22 20:46:10
调用WinAPI函数(如果你正在开发win应用程序)
如果你在asm或C中编写了一个windows应用程序(甚至是)...那么函数将是一个WinAPI函数。这就好像回答“*你应该看医生*”给有人说“*我生病*”。 – user2284570 2014-04-07 21:19:35
汇编语言没有直接打印任何东西的方法。您的汇编程序可能会或可能不会提供一个提供这种设施的库,否则您必须自己编写它,这将是一个相当复杂的功能。您还必须决定在哪里打印东西 - 在窗口中,在打印机上?在汇编中,这些都不是为你完成的。
虽然Win16是否支持该特定方法是为了让别人回答,但您可能会有一些运气调用Win32 API的MessageBoxA。
PRINT_SUM PROC NEAR
CMP AL, 0
JNE PRINT_AX
PUSH AX
MOV AL, '0'
MOV AH, 0EH
INT 10H
POP AX
RET
PRINT_AX:
PUSHA
MOV AH, 0
CMP AX, 0
JE PN_DONE
MOV DL, 10
DIV DL
CALL PRINT_AX
MOV AL, AH
ADD AL, 30H
MOV AH, 0EH
INT 10H
PN_DONE:
POPA
RET
PRINT_SUM ENDP
请添加一些句子,这些句子不是代码的一部分,以详细解答答案... – user2284570 2014-04-04 22:10:26
mov al,3 ;print ♥
mov dl,al
;call print service(2) to print from dl
mov ah,2
int 21h
;return to DOS
mov ah,76 ;76 = 4ch
int 21h ;call interrupt
mov al,4 ; input
; print AL
or al,30h ; Important! =>Convert an integer from 0-9 to its ASCII encoding
mov i,al
MOV AH, 2 ;
MOV DL, i ; Print Character.
INT 21H ;
非常感谢凯。 – 2013-12-27 20:28:16
没有必要通过内存中的“i”反弹值。 'mov dl,al'可以正常工作。 – 2016-06-28 18:35:16
4年过去了,我忘了汇编语言。 :( 这很可能你是对的。 谢谢。 <3 – 2017-01-10 10:00:52
; good example of unlimited num print
.model small
.stack 100h
.data
number word 6432
string db 10 dup('$')
.code
main proc
mov ax,@data
mov ds,ax
mov ax,number
mov bx ,10
mov cx,0
l1:
mov dx,0
div bx
add dx,48
push dx
inc cx
cmp ax,0
jne l1
mov bx ,offset string
l2:
pop dx
mov [bx],dx
inc bx
loop l2
mov ah,09
mov dx,offset string
int 21h
mov ax,4c00h
int 21h
main endp
end main
请添加一些句子,这些句子不是代码的一部分,以详细解答答案... – user2284570 2014-04-04 21:59:43
可怕的格式。 Downvoted几乎无法读取大量的空白,没有缩进,也没有评论。 – 2016-06-28 18:30:56
(在64位操作系统使用DOSBOX)
.code
mov ax,@DATA ; get the address of the data segment
mov ds,ax ; store the address in the data segment register
;-----------------------
mov eax,0FFFFFFFFh ; 32 bit value (0 - FFFFFFFF) for example
;-----------------------
; convert the value in EAX to hexadecimal ASCIIs
;-----------------------
mov di,OFFSET ASCII ; get the offset address
mov cl,8 ; number of ASCII
P1: rol eax,4 ; 1 Nibble (start with highest byte)
mov bl,al
and bl,0Fh ; only low-Nibble
add bl,30h ; convert to ASCII
cmp bl,39h ; above 9?
jna short P2
add bl,7 ; "A" to "F"
P2: mov [di],bl ; store ASCII in buffer
inc di ; increase target address
dec cl ; decrease loop counter
jnz P1 ; jump if cl is not equal 0 (zeroflag is not set)
;-----------------------
; Print string
;-----------------------
mov dx,OFFSET ASCII ; DOS 1+ WRITE STRING TO STANDARD OUTPUT
mov ah,9 ; DS:DX->'$'-terminated string
int 21h ; maybe redirected under DOS 2+ for output to file
; (using pipe character">") or output to printer
; terminate program...
.data
ASCII DB "00000000",0Dh,0Ah,"$" ; buffer for ASCII string
替代
DOS打印32位值字符串直接输出到videobuffer而不使用软件中断:
;-----------------------
; Print string
;-----------------------
mov ax,0B800h ; segment address of textmode video buffer
mov es,ax ; store address in extra segment register
mov si,OFFSET ASCII ; get the offset address of the string
; using a fixed target address for example (screen page 0)
; Position`on screen = (Line_number*80*2) + (Row_number*2)
mov di,(10*80*2)+(10*2)
mov cl,8 ; number of ASCII
cld ; clear direction flag
P3: lodsb ; get the ASCII from the address in DS:SI + increase si
stosb ; write ASCII directly to the screen using ES:DI + increase di
inc di ; step over attribut byte
dec cl ; decrease counter
jnz P3 ; repeat (print only 8 ASCII, not used bytes are: 0Dh,0Ah,"$")
; Hint: this directly output to the screen do not touch or move the cursor
; but feel free to modify..
AH = 09 DS:DX =指向字符串 “$”
returns nothing
- outputs character string to STDOUT up to "$"
- backspace is treated as non-destructive
- if Ctrl-Break is detected, INT 23 is executed
裁判结束:http://stanislavs.org/helppc/int_21-9.html
.data
string db 2 dup(' ')
.code
mov ax,@data
mov ds,ax
mov al,10
add al,15
mov si,offset string+1
mov bl,10
div bl
add ah,48
mov [si],ah
dec si
div bl
add ah,48
mov [si],ah
mov ah,9
mov dx,string
int 21h
请尝试解释一些您的代码。 – Marcs 2016-09-19 16:25:28
- 1. 用汇编语言输入数字
- 2. 以汇编语言打印十进制数?
- 3. 打印打包的BCD(DT) - 汇编语言(TASM)
- 4. 如何用汇编语言打印框大纲
- 5. 汇编语言
- 6. 如何使用fasm汇编器打印出一个数字?
- 7. 打印字符串(汇编)
- 8. 汇编语言字节计数
- 9. 汇编语言86:胶印间接操作的一个结构
- 10. 汇编语言和打印结果。 Fibbonacci序列
- 11. 在8086中打印出十进制值汇编语言
- 12. 以汇编语言(LC-3)打印*的三角形
- 13. 汇编在屏幕上打印数字
- 14. MIPS汇编语言
- 15. 8086汇编语言
- 16. x86汇编语言
- 17. 汇编语言环
- 18. 汇编语言 - LDI
- 19. CMP汇编语言
- 20. 汇编语言:cbw
- 21. MIPS汇编语言
- 22. 用汇编语言将一个数字存储到一个变量中
- 23. 汇编语言的用法
- 24. 分割用汇编语言
- 25. 在MARIE汇编语言中打印奇数至用户输入值
- 26. 如何用Python编程语言打印
- 27. 将汇编语言宏转换为纯汇编语言
- 28. 不能使用数据汇编语言
- 29. 用MS-DOS int 21h系统调用打印汇编语言的新行
- 30. 如何在汇编语言中添加两个16位数字?
您需要指定您的机器类型和操作系统系统,因为I/O通常非常依赖于平台。 – unwind 2009-12-17 14:26:33
他做到了,它有一个“win16”标签。 – 2009-12-17 14:28:09
win16真的吗?我们仍然使用Windows 3.1吗? – 2009-12-17 14:34:31