showevar.asm

来自「开放源码的编译器open watcom 1.6.0版的源代码」· 汇编 代码 · 共 43 行

ASM
43
字号
.model small
STDOUT  EQU 1
.stack 100h
.data
crlf	DB	13,10
	DW	4000 DUP (0)	; bulk up size by 8K to make large enough for modifications
.code
start:
	mov	ds,es:[2ch]	; ds -> e-var block (es -> PSP on entry)
	xor	si,si		; init offset in block
	mov	bx,STDOUT

loop2:
	mov	al,ds:[si]	; get first char of string
	or	al,al		; see if null (no more strings)
	je	done

loop1:
	mov	dx,si		; ds:dx -> string to print
	mov	cx,1
	mov	ah,40h		; write to device
	int	21h
	inc	si			; move to next char in string
	mov	al,ds:[si]	; print remaining chars in string one at a time
	or	al,al		; see if null (end of string)
	jne	loop1		; nope

	push	ds		; save ds -> e-var block
	mov	ax,DGROUP
	mov	ds,ax
	mov	dx,OFFSET DGROUP:crlf	; write CR/LF pair after string end
	mov	cl,2
	mov	ah,40h		; write to device
	int	21h
	pop	ds			; restore ds -> e-var block
	inc	si
	jmp	SHORT loop2

done:
	mov	ax,4c00h	; terminate with zero return code
	int	21h
end start

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?