iplregdmp.asm
comment *
MASM32 SDK
ml /c /AT /Fl iplregdmp.asm
link16 /t iplregdmp;
*
		.186
		.model	tiny
		.code
		org	0h			; IPL
 
TVRAM		equ	0a000h			; TEXT VRAM
 
main		proc
		push	es
		push	ds
 
		push	cs
		pop	ds
 
		call	dmpip
		mov	si, offset str_cs
		mov	ax, cs
		call	regdmp
		mov	si, offset str_ds
		pop	ax			; pop ds
		call	regdmp
		mov	si, offset str_es
		pop	ax			; pop es
		call	regdmp
		mov	si, offset str_ss
		mov	ax, ss
		call	regdmp
		mov	si, offset str_sp
		mov	ax, sp
		call	regdmp
 
		cli
		hlt
main		endp
 
dmpip		proc
		mov	si, offset str_ip
		mov	bp, sp
		mov	ax, [bp]
		call	regdmp
		ret
dmpip		endp
 
regdmp		proc
		push	cs
		pop	es
		mov	di, offset buf
		cld
		movsb
		movsb
		inc	di
		call	itoa4
 
		mov	si, offset buf
		call	puts
		ret
regdmp		endp
 
itoa4		proc
		cld
		mov	cx, 4
@@loop:
		rol	ax, 4
		push	ax
		and	al, 0fh
		cmp	al, 0ah
		sbb	al, 69h
		das
		stosb
		pop	ax
		loop	@@loop
		ret
itoa4		endp
 
puts		proc
		mov	ax, TVRAM
		mov	es, ax
		mov	al, 160
		mul	posy
		mov	di, ax
		cld
@@loop:
		lodsb
		cmp	al, 0
		je	@@exit
		stosb
		inc	di
		jmp	@@loop
@@exit:
		inc	posy
		ret
puts		endp
 
posy		db	0
buf		db	'xx:xxxx', 0
str_cs		db	'CS'
str_ds		db	'DS'
str_es		db	'ES'
str_ss		db	'SS'
str_sp		db	'SP'
str_ip		db	'IP'
 
		end	main
 

最終更新:2018年08月18日 11:43
添付ファイル