当时写了好多手机汇编,怀念当初玩6688的时候
有激情啊,来一首当年和果果的合唱
[hjp3]hjptype=song&player=6&sw1=http://www.guoguoer.cn/mp3/奔跑.mp3&autoplay=false&width=380&height=90[/hjp3]
$Segmented
$Mod167
;Work Time!
;其实自己对这个精确倒计时+生物钟显示能否完成还不敢肯定,转变是否开始,就看现在,证明自己能做点东西!
;一定不能半途而废!!!
;现在是星期日的晚上10点,比较顺利,要完成了。总天数已经算准确了。
;昨天晚上熬夜,终于按自己的计划,没有把工作拖到第二天,昨天的运气也比较好,好来好日子要来临了。
;现在是进行一些精简代码工作,和规范化,加上倒计时。
;为了加倒计时进去,使手机无法启动,备份工作没有做好,现在恢复成以前的系统试试
;代码已经不好看出错误的地方,代码应该没的错的。这是怎么了,只有系统有错有解
;已经全部完成,是查表的一个地方有错,现在倒计时和生物钟都运行正确。
;0x363B68:06F00C00 DABF608B
Flash_Address EQU 0A00000h
;memcpy EQU 0xC783DC
;Some Function
DrawImageByIndex EQU 0xB3DF04
;Some Var
Day EQU 25E0H ;0D:25E0
Month EQU 25E2H
Year EQU 25E4H
;Flag
Botton EQU 3E2BH;34,这是按键,用于检测是否处于待机状态
day1 EQU 3Ec6H;自定义变量从3E30开始
month1 EQU 3Ec8H
year1 EQU 3EcaH
day2 EQU 3EccH
month2 EQU 3EceH
year2 EQU 3Ed0H
result EQU 3Ed2H
;result2 EQU 3Ed4H
;result3 EQU 3Ed6H
;result4 EQU 3Ed8H
;Some Address
PatchBegin EQU 0x1F8B60
patch section code word AT PatchBegin
main proc far
MOV [-R0],R1
MOV [-R0],R2
MOV [-R0],R3
MOV [-R0],R4
MOV [-R0],R5
MOV [-R0],R6
MOV [-R0],R7
MOV [-R0],R8
MOV [-R0],R9
MOV [-R0],R10
MOV [-R0],R11
MOV [-R0],R12
MOV [-R0],R13
MOV [-R0],R14
;判断应用程序
extp #0EH,#1
mov r8,3A42H
jnb r8.3,Exit ;读应用程序选项,未选择退出:以9号功能
extp #34H,#1 ;检测是否待机
movb rl4,Botton
jmpr cc_z,Exit
;调用计算日期的子程序count
call count
Exit:
MOV R14,[R0+]
MOV R13,[R0+]
MOV R12,[R0+]
MOV R11,[R0+]
MOV R10,[R0+]
MOV R9,[R0+]
MOV R8,[R0+]
MOV R7,[R0+]
MOV R6,[R0+]
MOV R5,[R0+]
MOV R4,[R0+]
MOV R3,[R0+]
MOV R2,[R0+]
MOV R1,[R0+]
;补原指令
add r0, #0Ch
rets
main endp
count proc near
;以下是倒计时的代码(以2005.1.15自考为例),去掉注释就可以用了。:
;日期1(当前日期):
; extp #0DH,#3
; mov r1,Day ;获取当前日期
; mov r2,Month
; mov r3,Year
;日期2(考试日期):
; mov r4,#0fH ;15日
; mov r5,#01H ;1月
; mov r6,#07D5H ;2005年
; extp #34H,#3H
; mov day1,r1 ;将2个日期都写入内存中
; mov month1,r2
; mov year1,r3
; extp #34H,#03H
; mov day2,r4
; mov month2,r5
; mov year2,r6
;调算中间的闰年数rencount 返回值r1
; call rencount
;调中间的天数(N*365)midday 返回值r2
; call midday
;调算两头的天数heday 返回值r3
; call heday
; mov r12,#3dh
; mov r13,#45h
;
; call disp
; mov r12,#3dh ;此处为在日期前加一个“ZK”字样
; mov r13,#45h
; mov r14,#15ch
; calls seg(DrawImageByIndex),sof(DrawImageByIndex);
;<<<<<<<<生物钟>>>>>>>>>>>>>>>>>>>>>>
;日期1(出生日期):
mov r1,#1234H ;9日
mov r2,#5678H ;12月
mov r3,#07BcH ;1980年
;日期2(当前日期):
extp #0DH,#3h
mov r4,Day ;获取当前日期
mov r5,Month
mov r6,Year
extp #34H,#3H
mov day1,r1 ;将2个日期都写入内存中
mov month1,r2
mov year1,r3
extp #34H,#03H
mov day2,r4
mov month2,r5
mov year2,r6
;调算中间的闰年数rencount 返回值r1
call rencount
;调中间的天数(N*365)midday 返回值r2
call midday
;调算两头的天数heday 返回值r3
call heday
;读出结果
;开始显示
mov r12,#01H ;坐标
mov r13,#30H
extp #34H,#01H;将天数读进r4
mov r4,result
mov r3,#21H ;33
;调算余数&结果 divr2(r3为周期)
call divr2
MOV [-R0],R1
call bdatacount
call disp
MOV R1,[R0+]
;显示正负号图标
mov r12,#01H ;坐标
mov r13,#30H
mov r14,#154H ;i+
cmp r1,#11H
jmpr cc_ult,iif
mov r14,#155H;i-
iif:
calls seg(DrawImageByIndex),sof(DrawImageByIndex);
mov r12,#23H ;坐标
mov r13,#30H
extp #34H,#01H;将天数读进r4
mov r4,result
mov r3,#17H ;23
;调算余数&结果 divr2(r3为周期)
call divr2
MOV [-R0],R1
add r1,#21h
call bdatacount
call disp
MOV R1,[R0+]
mov r12,#23H ;坐标
mov r13,#30H
mov r14,#156H ;p+
cmp r1,#0cH
jmpr cc_ult,pf
mov r14,#157H;p-
pf:
calls seg(DrawImageByIndex),sof(DrawImageByIndex);
mov r12,#47H ;坐标
mov r13,#30H
extp #34H,#01H;将天数读进r4
mov r4,result
mov r3,#1cH ;28
;调算余数&结果 divr2(r3为周期)
call divr2
MOV [-R0],R1
add r1,#38h
call bdatacount
call disp
MOV R1,[R0+]
mov r12,#47H ;坐标
mov r13,#30H
mov r14,#158H ;e+
cmp r1,#0eH
jmpr cc_ult,ef
mov r14,#159H;e-
ef:
calls seg(DrawImageByIndex),sof(DrawImageByIndex);
ret
count endp
bdatacount proc near
shl r1,#1H
extp #pag(bdata+Flash_Address),#3h
mov r2, #pof(bdata+Flash_Address)
add r2,r1
mov r1,[r2]
ret
bdatacount endp
divr2 proc near
mov mdl,r4
divu r3
mov r1,mdh
ret
divr2 endp
rencount proc near
extp #34H,#2H
mov r1,year1 ;读出2个年
mov r2,year2
;做4-mod(year1,4)
mov mdl,r1 ;mod year1,4
mov r3,#04H;
divu r3
mov r3,mdh ;mdh为余数 4-mod(year1,4)
mov r4,#4H
sub r4,r3 ;结果存在r4
;做year1=year1+N
add r1,r4 ;r1=>新的year1
;做year2=year2-N if N=0 then N=4
mov mdl,r2 ;mod year2,4
mov r3,#04H;
divu r3
mov r3,mdh
jmpr cc_nz,go1 ;如果r3为0,则置为4
mov r3,#4H
go1:
sub r2,r3 ;r2=>新的year2
;判断y1>y2的情况,置闰年数为0,否则正常做(y2-y1)/4
cmp r1,r2
jmpr cc_ult,go2 ;如果r1<r2正常,执行go2
mov r1,#0H;不正常的情况,闰年为0
jmpr cc_uc,go3
go2:
sub r2,r1
mov mdl,r2
mov r3,#04H
divu r3
mov r1,mdl
add r1,#1H
go3:
extp #34H,#1 ;结果写入内存
mov result,r1
ret
rencount endp
midday proc near
extp #34H,#2H
mov r1,year1 ;读出2个年
mov r2,year2
sub r2,r1
sub r2,#1H ;r2为中间年数
mov r3,#16DH ;乘以365,得中间天数
mulu r2,r3
mov r2,MDL
extp #34H,#1H
mov r1,result
add r1,r2
extp #34H,#1 ;结果写入内存
mov result,r1
;mov result2,r1 ;此处正确
ret
midday endp
heday proc near
extp #34H,#3H
mov r1,month2 ;读出最后那年2个月,日
mov r2,day2
mov r3,year2
call tday ;计算当年已经过了多少天.r1返回
;extp #34H,#1 ;结果写入内存
;mov result3,r1 ;此处正确
extp #34H,#1H
mov r2,result
add r2,r1
extp #34H,#1 ;结果写入内存
mov result,r2
; extp #34H,#1 ;结果写入内存
; mov result2,r2
;计算出生那年还剩多少天
extp #34H,#3H
mov r1,month1 ;读出出生那年2个月,日
mov r2,day1
mov r3,year1
call tday ;此处计算的是出生那年已经过了多少天r1
mov r5,#16dH ;r5为被减数365
mov mdl,r3
mov r4,#04H;除数4
divu r4
mov r4,mdh
jmpr cc_nz,birthdaynext
add r5,#1H
birthdaynext:
sub r5,r1
mov r2,r5
;extp #34H,#1 ;结果写入内存
;mov result4,r2 ;此处
extp #34H,#1H
mov r1,result
add r1,r2
;extp #34H,#1 ;结果写入内存
;mov result2,r2
extp #34H,#1 ;结果写入内存
mov result,r1
ret
heday endp
tday proc near
;r1为月数,r4为返回天数
mov r4,r1
sub r4,#1H
shl r4,#1H
extp #pag(ydata+Flash_Address),#3h
mov r5, #pof(ydata+Flash_Address)
add r5,r4
mov r4,[r5]
;shl r1,#1H
;extp #pag(bdata+Flash_Address),#3h
;mov r2, #pof(bdata+Flash_Address)
;add r2,r1
;mov r1,[r2]
cmp r1,#3H
jmpr cc_ult,no2 ;如果为3月以后,就检测是否是闰年,如果是r4天数+1
mov mdl,r3
mov r6,#04H;除数4
divu r6
mov r6,mdh
jmpr cc_nz,no2
add r4,#1H
no2:
add r4,r2;加上日数
mov r1,r4;返回r1
ret
tday endp
disp proc near
call dispcount
MOV R14,[R0+] ;调用5位显示
call draw
MOV R14,[R0+]
call draw
MOV R14,[R0+]
call draw
MOV R14,[R0+]
call draw
MOV R14,[R0+]
call draw
ret
disp endp
dispcount proc near ; (r1为参数,堆栈为返回值)
mov mdl,r1
mov r3,#2710H;除数10000
divu r3
mov r4,mdl
mov mdl,mdh
mov r3,#3E8H;除数1000
divu r3
mov r5,mdl
mov mdl,mdh
mov r3,#64H;除数100
divu r3
mov r6,mdl
mov mdl,mdh
mov r3,#0AH;除数10
divu r3
mov r7,mdl
mov r8,mdh
MOV [-R0],R8
MOV [-R0],R7
MOV [-R0],R6
MOV [-R0],R5
MOV [-R0],R4
ret
dispcount endp
draw proc near
MOV [-R0],R12
MOV [-R0],R13
add r14, #20Dh
calls seg(DrawImageByIndex),sof(DrawImageByIndex);
MOV R13,[R0+]
MOV R12,[R0+]
add r12,#6H
ret
draw endp
bdata:
dw 0h,13h,25h,36h,45h,51h,58h,61h,64h,63h,5eh,57h,4ch,3eh,2eh,1ch,9h
dw 0ah,1ch,2eh,3eh,4ch,57h,5fh,63h,64h,61h,5bh,51h,45h,36h,25h,13h
dw 0h,1bh,34h,49h,59h,62h,64h,5eh,52h,3fh,28h,0eh
dw 0eh,28h,3fh,52h,5eh,64h,62h,59h,49h,34h,1bh
dw 0h,16h,2bh,3eh,4eh,5ah,61h,64h,61h,5ah,4eh,3eh,2bh,16h
dw 0h,16h,2bh,3eh,4eh,5ah,62h,64h,61h,5ah,4eh,3eh,2bh,16h
ydata:
dw 0h,1fh,3bh,5ah,78h,97h,0b5h,0d4h,0f3h,111h,130h,14eh
patch ends
End