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

📄 proj6_5.asm

📁 汇编编程艺术
💻 ASM
字号:
; PROJ6_5.ASM-
;
; An integer output routine.
;
; PUTINT is passed an unsigned integer value in the AX register.
; It should print the value of that integer as a sequence of characters
; providing the decimal representation of that integer.  See the lab
; manual for the exact algorithm.



dseg		segment	para public 'data'
; Put any variables you need here.
dseg		ends

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


; PutChar prints the character in the AL register to the display.

PutChar		proc
		push	ax		;Preserve value in AH
		mov	ah, 0eh		;BIOS call to print a character.
		int	10h
		pop	ax		;Restore AH's value.
		ret
PutChar		endp


; Newline-	Prints the cr/lf pair to the screen (a new line).

NewLine		proc
		push	ax
		mov	ax, 0e0dh	;Carriage return
		int	10h
		mov	ax, 0e0ah	;Linefeed
		int	10h
		pop	ax
		ret
NewLine		endp



; Here is the routine you've got to write for this project.
; On entry, AX contains an unsigned integer value.  It needs to
; print this value as a string of decimal digits.  Be sure to
; preserve (on the stack) all registers you modify.

PutInt		proc
		ret
PutInt		endp




; Main program to test the PutInt routine.

Main		proc
		mov	ax, dseg
		mov	ds, ax


		mov	ax, 12345
		call	PutInt
		call	NewLine

		mov	ax, 54321
		call	PutInt
		call	NewLine

		mov	ax, 0
		call	PutInt
		call	NewLine

		mov	ax, 65535
		call	PutInt
		call	NewLine

		mov	ax, 1
		call	PutInt
		call	NewLine

		mov	ax, 10
		call	PutInt
		call	NewLine

		mov	ax, 100
		call	PutInt
		call	NewLine

		mov	ax, 1000
		call	PutInt
		call	NewLine

		mov	ax, 10000
		call	PutInt
		call	NewLine


Quit:		mov	ah, 4ch	  	;DOS opcode to quit program.
		int	21h		;Call DOS.
Main		endp

cseg		ends

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

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

⌨️ 快捷键说明

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