搜索此博客

2012年9月5日星期三

Jump to uncertain (run-time determined) address in assembly language

Sometimes I want program to jump to uncertain (run-time determined) address like function pointer does in C language. For example, a function table. If the chip supports "jsr" with register indirect addressing, like H8, it will be as simple as
    jsr   @er0
But on the core I am using called "Flex RISC", 8bit, performs as peripheral device in an ARM based SoC, thers is only one "jsr" instruction which using immediate addressing. Branch instructions (brXX) and jmp instruction do the same.
At last I found there is another instruction changes PC pointer, "rts". It pop PC point from stack. So here is the way out:
    ...
variable SomeAddr keeps SomeFunc's sddress
    ld     a1, SomeAddr
    ld     a2, SomeAddr + 1
    jsr    CallByAddr
    ...

SomeFunc:
    ...
    rts          ; this "rts" will exactly returns from the "jsr".

CallByAddr:
    psh    a2
    psh    a1
    rts          ; this "rts" will pop a2a1 to PC that makes SomeFunc called.

Android App 开除相册

Android自带相册会把机器里所有包含图片视频的文件夹都收录进去,除非那个文件夹包含“.nomedia”——一个隐藏文件。我的Nexus S就是这样,XOOM如果刷成美版也会。
这个“开除相册”就是把不希望相册自动收录的文件夹从相册中开除出去。

半成品,连个图标都还没有呢。
ListView上用的是SimpleAdpter,重写麻烦。重载了getView方法,这是ListView向Adpter要View(list item)时调的。我把序号写进那个View的tag里了。这样check/uncheck的时候好让CheckBox知道更新Map里哪个数据。
Check/uncheck的响应函数在SimpleAdpter.ViewBinder里,ViewBinder负责把Map里的数据反映到list item上。重载ViewBinder的setViewValue方法,这里能找到CheckBox对象,改它的Listener。