⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ex9_1.asm

📁 ART OF Assembly Language Programming, 很不错
💻 ASM
字号:

dseg		segment	para public 'data'

I		word	0
J		word	0
K		word	0

dseg		ends


cseg		segment	para public 'code'
		assume	cs:cseg, ds:dseg


; This program is useful for debugging purposes only!
; The intent is to execute this code from inside CodeView.
;
; This program is riddled with bugs.  The bugs are very obvious in
; this short code sequence, within a larger program these bugs might
; not be quite so obvious.

Main		proc
		mov	ax, dseg
		mov	ds, ax
		mov	es, ax

; The following loop increments I until it reaches 10

ForILoop:	inc	I
		cmp	I, 10
		jb	ForILoop

; This loop is supposed to do the same thing as the loop above, but we
; forgot to reinitialize I back to zero.  What happens?

ForILoop2:	inc	I
		cmp	I, 10
		jb	ForILoop2


; The following loop, once again, attempts to do the same thing as the first
; for loop above.  However, this time we remembered to reinitialize I.  Alas,
; there is another problem with this code, a typo which the assembler cannot
; catch.

		mov	I, 0
ForILoop3:	inc	I
		cmp	I, 10
		jb	ForILoop	;<<<-- Whoops! Typo.

; The following loop adds I to J until J reaches 100.  Unfortunately,
; the author of this code must have been confused and thought that AX
; contained the sum accumulating in J.  It compares AX against 100 when
; it should really be comparing J against 100.

WhileJLoop:	mov	ax, I
		add	J, ax
		cmp	ax, 100		;This is a bug!
		jb	WhileJLoop




		mov	ah, 4ch		;Quit to CodeView/DOS.
		int	21h
Main		endp

cseg            ends



; Allocate a reasonable amount of space for the stack (8k).
; Note: if you use the pattern matching package you should set up a
;	somewhat larger stack.

sseg		segment	para stack 'stack'
stk		db	1024 dup ("stack   ")
sseg		ends


; zzzzzzseg must be the last segment that gets loaded into memory!
; This is where the heap begins.

zzzzzzseg	segment	para public 'zzzzzz'
LastBytes	db	16 dup (?)
zzzzzzseg	ends
		end	Main

⌨️ 快捷键说明

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