Re: ÄɲüÁÌä



[ ¤³¤Î¥á¥Ã¥»¡¼¥¸¤Ø¤ÎÊÖ»ö ] [ ÊÖ»ö¤ò½ñ¤¯ ] [ home.html ]



Åê¹Æ¼Ô¡§ movem.l d0-d7/a0-a5,-(sp) @ h003.p066.iij4u.or.jp on 97/9/21 08:43:44

In Reply to: Re: ÄɲüÁÌä

posted by 68user @ oryo.inforyoma.or.jp on 97/9/21 06:57:13

> int *base_addr = malloc( ( size_t ) 2000 );
>
> for ( int h=0 , int *p=base_addr+100 ; p < base_addr+1000 ; p++ ){
> ¢³h += *p;
> }
>
> ¤Ï¡¢
>
> # $19 = base_addr
>
> ¢³¢³¢³add $8,$0,$0 ¢³¢³¢³¢³# h = 0
> ¢³¢³¢³addi $20,$19,1000*4 ¢³# $19 = base_addr + 1000 * sizeof(int)
> Loop:
> ¢³¢³¢³lw $9,0($19)¢³¢³¢³ # $9 = base_addr + $19
> ¢³¢³¢³add $8,$8,$9¢³¢³¢³ # h += $9
> ¢³¢³¢³addi $19,$19,4¢³¢³ # $19 += sizeof(int)
> ¢³¢³¢³bne $19,$20,Loop
>
> ¤³¤ó¤Ê´¶¤¸¤Ë¤Ê¤ë¤ó¤Ç¤·¤ç¤¦¤«¡©
>

ÂçÂÎÎɤ¤¤È»×¤¤¤Þ¤¹¡£(¢«¤è¤¯¤ï¤«¤Ã¤Æ¤¤¤Ê¤¤¤¯¤»¤Ë)
¤¿¤À¡¢forʸ¤Î"*p=base_addr+100"¤Ï¤É¤³¡©(^^;)

¢³¢³¢³add $8,$0,$0 ¢³¢³¢³¢³# h = 0
¢³¢³¢³addi $20,$19,1000*4 ¢³# $20 = base_addr + 1000 * sizeof(int)
¢³¢³¢³addi $21,$19,100*4 ¢³# $21 = base_addr + 100 * sizeof(int)
Loop:
¢³¢³¢³lw $9,0($21)¢³¢³¢³ # $9 = *p
¡¡¡¡¡¡nop¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡¡# Ãٱ䥹¥í¥Ã¥È¤Î°Ù¡¢$9¤ò»È¤Ã¤¿Ì¿Î᤬¼Â¹Ô¤Ç¤­¤Ê¤¤
¢³¢³¢³add $8,$8,$9¢³¢³¢³ # h += $9
¢³¢³¢³addi $21,$21,4¢³¢³ # $21 += sizeof(int)
¢³¢³¢³bne $21,$20,Loop

¤³¤ó¤Ê¤È¤³¤í¤Ç¤¹¤«¡©
nop¤Ë´Ø¤·¤Æ¤Ï¥¢¥»¥ó¥Ö¥é¤Ç¾¡¼ê¤ËÆþ¤ì¤Æ¤¯¤ì¤Þ¤·¤¿¤¬¡¢¤È¤ê¤¢¤¨¤º½ñ¤¤¤Æ¤ª¤­¤Þ¤¹¡£
¤Þ¤¢¡¢ºÇŬ²½¤¹¤ë¤È¤³¤¦¤Ê¤ë¤È»×¤¤¤Þ¤¹¡£

Loop:
¢³¢³¢³lw $9,0($21)¢³¢³¢³ # $9 = *p
¢³¢³¢³addi $21,$21,4¢³¢³ # $21 += sizeof(int)
¢³¢³¢³add $8,$8,$9¢³¢³¢³ # h += $9
¢³¢³¢³bne $21,$20,Loop

¤°¤Ã¡¢¤µ¤é¤Ë¤³¤¦¤Ê¤ë¤é¤·¤¤...¡£(¥¢¥»¥ó¥Ö¥é¤òÄ̤·¤¿¤é¤³¤¦¤Ê¤Ã¤¿)

Loop:
¢³¢³¢³lw $9,0($21)¢³¢³¢³ # $9 = *p
¢³¢³¢³addi $21,$21,4¢³¢³ # $21 += sizeof(int)
¢³¢³¢³bne $21,$20,Loop
¢³¢³¢³add $8,$8,$9¢³¢³¢³ # h += $9¡¡(ʬ´ô¤Ë¤è¤ëÃٱ䥹¥í¥Ã¥È)

¤Ç¤â¡¢ÉáÄ̤˽ñ¤¤¤¿¤é

¢³¢³¢³bne $21,$20,Loop
¡¡¡¡¡¡nop
¢³¢³¢³add $8,$8,$9¢³¢³¢³ # h += $9

¤È¡¢Ç§¼±¤µ¤ì¤Æ¤·¤Þ¤Ã¤¿¡£¤¤¤ä¤Ï¤ä¡¢±ü¤¬¿¼¤¤¡£(^^;)
¤ä¤Ï¤ê¡¢ÁÇľ¤Ë¥³¥ó¥Ñ¥¤¥é¤ò»È¤¦¤Ù¤­¤Ç¤·¤ç¤¦¤Í¡£


> ¤È¤³¤í¤Ç¡¢
>
> > movem.l d0-d7/a0-a5,-(sp)
>
> ¤³¤ó¤Ê¹âµ¡Ç½¤ÊÌ¿Îá¤Ã¤ÆRISC¤Ç¤ÏÉáÄ̤ϸºß¤·¤Ê¤¤¤ó¤Ç¤¹¤«¤Í¡©
> 68000·Ï¤Ç¤âµ¿»÷Ì¿Îá¤À¤Ã¤¿¤Î¤«¤â¤·¤ì¤Ê¤¤¤±¤É(¤è¤¯ÃΤé¤Ê¤¤)

¤³¤ì¤Ï»ØÄꤷ¤¿¥ì¥¸¥¹¥¿¤ò½çÈÖ¤ËPUSH¤·¤Æ¤¤¤¯¤ï¤±¤Ç¤¹¤¬¡¢°ìÌ¿Îã¤ÇÊ£¿ô²ó¤Î¥á¥â¥ê¥¢¥¯¥»¥¹¤ò¹Ô¤¦¤È¤¤¤¦¤Î¤Ï¹¥¤Þ¤·¤¯¤Ê¤¤¤Ç¤·¤ç¤¦(¥Ñ¥¤¥×¥é¥¤¥ó¤Î˸¤²¤Ë¤Ê¤ë¡©)¡£
68·Ï¤Ï¡¢1Ì¿Îá¤Ç½èÍý¤·¤Þ¤¹¡£(^^;)MC68000¤Î¾ì¹ç¤Ï¡¢8+n(»ØÄꤷ¤¿¥ì¥¸¥¹¥¿¤Î¿ô)x4¥¯¥í¥Ã¥¯¤«¤«¤ê¤Þ¤¹¡£