File:  [Isaki's NoNo m68k/m88k emulator] / nono / exp / pack1.has
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Wed Apr 29 17:05:59 2026 UTC (2 months, 3 weeks ago) by root
Branches: MAIN, Isaki
CVS tags: v027, HEAD
nono 1.7.0

; vi:set ts=8:

; nono
; Copyright (C) 2025 Tetsuya Isaki
;
; Permission to use, copy, modify, and/or distribute this software for any
; purpose with or without fee is hereby granted.
;
; THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
; WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
; MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
; ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
; WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
; ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
; OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.

; PACK/UNPK のアクセスサイズを調べる。
; 68030 実機ではどちらもワードアクセスをしている。
;
; How to build and use:
; > has pack1.has
; > hlk pack1.o
; > pack1.x
; PACK SSW.size=2
; UNPK SSW.size=2

	.include	doscall.mac
	.include	iocscall.mac

	.cpu	68030
	.list
	.text
	.even
start:
	; バスエラーハンドラを差し替える。
	pea.l	buserr_handler
	move.w	#2,-(sp)
	DOS	_INTVCS
	addq.l	#6,sp
	move.l	d0,buserr_backup

test_pack:
	; PACK -(Ax),-(Ay),#imm は
	; -(Ax) から2バイト読んで -(Ay) に1バイト書き込む。
	; この読み込みのアクセスサイズを調べる。
	pea.l	msg_pack(pc)
	DOS	_PRINT
	addq.l	#4,sp

	move.l	#$ed4002,d0
	movea.l	d0,a0
	lea.l	buf+2(pc),a1
	lea.l	@f,a2
	pack	-(a0),-(a1),#0
@@:
	move.b	d0,msg_res0
	pea	msg_res(pc)
	DOS	_PRINT
	addq.l	#4,sp

test_unpk:
	; UNPK -(Ax),-(Ay),#imm は
	; -(Ax) から1バイト読んで -(Ay) に2バイト書き込む。
	; この書き込みのアクセスサイズを調べる。
	pea.l	msg_unpk(pc)
	DOS	_PRINT
	addq.l	#4,sp

	lea.l	buf+2(pc),a0
	move.l	#$ed4002,d0
	movea.l	d0,a1
	lea.l	@f,a2
	unpk	-(a0),-(a1),#0
@@:
	move.b	d0,msg_res0
	pea	msg_res(pc)
	DOS	_PRINT
	addq.l	#4,sp

done:
	move.l	buserr_handler,-(sp)
	move.w	#2,-(sp)
	DOS	_INTVCS

	DOS	_EXIT

; SSW のサイズフィールドから '1' or '2' を d0 に入れて a2 に帰る。
buserr_handler:
	move.w	$a(sp),d0
	andi.w	#$0eff,d0	; Clear Rerun flags
	move.w	d0,$a(sp)
	lsr.w	#4,d0
	andi.w	#3,d0
	addi.b	#'0',d0
	move.l	a2,2(sp)
	rte

msg_pack:
	.dc.b	"PACK",0
msg_unpk:
	.dc.b	"UNPK",0
	.data
	.even
buf:
	.dc.b	2
msg_res:
	.dc.b	": SSW.size="
msg_res0:
	.dc.b	"x",$d,$a,0

	.bss
	.even
buserr_backup:
	.ds.l	1
	.end

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.