Andes Workshop
http://forum.andestech.com/

Behavior of BSP400 to Handle 16-bit and 32-bit Instructions
http://forum.andestech.com/viewtopic.php?f=16&t=909
Page 1 of 1

Author:  HuJin [ Thu Jan 08, 2015 12:33 pm ]
Post subject:  Behavior of BSP400 to Handle 16-bit and 32-bit Instructions

AndeStar is 16-bit/32-bit mixable ISA from when it's born. Most of 16-bit instructions are a frequently-used subset of 32-bit instructions.
In BSP v4.0.0, we transfer 32-bit instruction to 16-bit in order to reduce code size, but for performance considerations, function and branch target's first instrucntions should be a 32-bit one because CPU fecth a 32-bit instruciton every time from memory. If function's first instructions is a 16-bit, it takes CPU one more cycle to do a function call or branch.

Follow is the behavior of BSP400 to handle this:
1. If the compiler option is "-O0" or "-Os", the compiler will generate 16-bit as far as possible including the first instruction of function and branch target.
2. For other compiler optimization option, the compiler will generate 16-bit as far as possilbe exlcuding the first instruction of function and branch target.
3. There are two pseudo-ops “.off_16bit” and “.restore_16bit” which user can use to preserve 32-bit instructions or not.
In Page 30 of document “Andes_Programming_Guide_for_ISA_V3_PG010_V1.0.pdf”, user can find the following explanation:
Attachment:
sample3.jpg
sample3.jpg [ 11.87 KiB | Viewed 13833 times ]

There is a example code for these two pesudo-ops:
Attachment:
sample1.png
sample1.png [ 3.24 KiB | Viewed 13833 times ]

The result is:
Attachment:
sample2.png
sample2.png [ 6.3 KiB | Viewed 13833 times ]

Please find the related demo project in attached file.
Attachment:
demo-int.zip [202.83 KiB]
Downloaded 1309 times

Page 1 of 1 All times are UTC + 8 hours [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/