

clear
;

;ターゲットメモリの定義
echo $_FILE
;
;define debug -d
define debug

;          data   io   endian addressing
define_mem 10000 10000 BE     BA

add_mem_area	reg		0000 0100 1 RW
add_mem_area	com_io	8000 2000 2 RW
add_mem_area	exram	c000 1000 8 RW
add_permanent_area font a000 1000 1  R font_han2.bin

add_io_area		switch	0000 0010

list $debug
;echo @inc(20, @byte(0030))
;set -s8040.1 -w @inc(20, 30)
;#exit

echo @addr(1234)
echo @addr(1234,0)
echo @addr(1234,1)
echo @addr(1234,f)
echo @addr(1234,)
echo @addr(1234k,jk)
echo @addr(h,jk)

echo @saddr(reg)
echo @saddr(reg,0)
echo @saddr(reg, 10)
echo @saddr(reg,  ff)
echo @saddr(reg, 100)
echo @saddr(regx)
echo @saddr(reg, 10v)
echo @saddr( reg , )
echo @saddr( reg x , 1)

echo @saddr(switch)

echo @addr(@saddr(reg))
echo @addr(@saddr(reg,10))
echo @addr(@saddr(reg,10t))
echo @addr(@saddr(reg,10_))
echo @addr(@saddr(exram))
echo @addr(@saddr(exram, fff))
echo @addr(@saddr(exram,1000))
echo @addr(@saddr(exram) , 1)
echo @addr(@saddr(exram, fff), 2)
echo @addr(@saddr(exram,1000), 3)



list $debug
set -s8000 "0123456789ABCDEF"
set        "GHIJKLMNOPQRSTUV"
set -s8000.1 -w 10 11 12 13 14 15 16 17 18 19 1A 1B 1C 1D 1E 1F
set -s8040.1 -w @inc(20, 30)

;バイト
echo @peek(8000)
echo @peek(8000, )
echo @peek(8000, 0)
echo @peek(8001, 0)
echo @peek(8000,1)
echo @peek(8001,1)
echo @peek(8001h,1t)  @peek(8001h,2t)
echo @peek(8010,fff)  @peek(8010,-1t)
echo @peek(8000,1000) @peek(8000,1000)
echo @peek(8000.1)    @peek(8001.1)
echo @peek(8000x,1)   @peek(8000,rt)
echo @peek(8000.g,1)  @peek(8000.-1t,rt)
echo @peek(8000.-1t)
echo @peek(8000.2t)
echo @peek(800)
echo @peek(800, )
echo @peek(8000.5,2)

;ワード
echo @peekw(8000)
echo @peekw(8000, )
echo @peekw(8000, 0)　	@peekw(8002, 0)
echo @peekw(8000,1)	@peekw(8002,1)
echo @peekw(8001h,1t)  @peekw(8001h,2t)
echo @peekw(8010,fff)  @peekw(8010,-1t)
echo @peekw(8000.1)    @peekw(8002.1)

;ダブルワード
echo @peekl(8000)
echo @peekl(8000, )
echo @peekl(8000, 0)　	@peekl(8004, 0)
echo @peekl(8000,1)	@peekl(8004,1)
echo @peekl(8001h,1t)  @peekl(8001h,2t)
echo @peekl(8010,fff)  @peekl(8010,-1t)
echo @peekl(8000.1)    @peekl(8004.1)




echo @addr(8000,10*4)
echo @addr(8000, 10 * 4 )
echo @addr(@saddr(reg), (4 * 3) + 5)

echo @addr(@saddr(reg),  @peekw(8004.1))
echo @addr(@saddr(reg),  2*@peekw(8004.1)+3)
echo @addr(@saddr(reg),  @peekw(8004.1)+3)
echo @addr(@saddr(reg),  @peekw(8004.1)*2)
echo @addr(@saddr(reg), ( @peekw(8004.1 * 3) + 5))
echo @addr(@saddr(reg), (@peekw(8004.1 * 3) + 5))


get -sa000 -w8
get -s @saddr(font) -w8

define font	  @saddr(font)
define font_sum  @saddr(font,aH)
define font_sumw @saddr(font,5H)

define IsBigEndian		@tmem(3)==1
define IsLittleEndian		@tmem(3)==2
define IsByteAddressing	@tmem(4)==1
define IsWordAddressing	@tmem(4)==2
define ResultValue		@tmem(10)
define ZeroFlag		@tmem(11)


#if $IsByteAddressing
echo @peek($font) @peekw($font_sum) @checksum(@saddr(font,2), 8)
#else
echo @peek(@saddr(font)) @checksum(@saddr(font,1), 8)
#endif

echo @peek(@saddr(font)) @checksumw(@saddr(font,2), 4)
echo @peek(@saddr(font)) @checksumw(@saddr(font,1), 4)
echo @checksumw(00, 4)
;font block
get -sa000 -w10
echo @checksum(a002, 8)		;
echo @checksum(@saddr(font)+2, @peekw(@saddr(font)*2))		;

echo @checksumw()
echo @checksumw(,)
echo @checksumw(,,)
echo @checksumw(gh)
echo @checksumw(8000,jk)
echo @checksumw(8000,8,)
echo @checksumw(8000,8,bnm)

