avkiev Исследователь Признанный телефонист С нами с: 20.09.2002 Плодовитость: 2088
Рейтинг
Подано 355 (329/26) голосов
|
Программирование под ARM. Технические вопросы
|
Идем дальше. Выкладываю исходник патча "Динамический оператор", желающие могут попробовать собрать проект и попытаться его скомпилировать. Специально выкладываю только исходник, а не весь проект - для повторения прошлого урока
Это уже большой, серьезный патч, можно попробовать с ним поразбираться.
[code]$ARM9E
$genonly
Vrezka equ 16B1D9Ch
Patch equ 0800100h
$INCLUDE (..\S65_50.inc)
AddImm macro imm
mov r3, #imm
add r5, #2
strh r3, [r4,r5]
endm
AddReg macro reg
add r5, #2
strh reg, [r4,r5]
endm
; ---------------------------------------------------------------------------
; ---------------------------------------------------------------------------
org Patch
Format: db 34h, 06h, 09h, 08h, 0BAh, 0CDh, 0DEh, 0Fh
db 34h, 06h, 09h, 08h, 0BAh, 0CDh, 0DEh, 0Fh
db 34h, 06h, 09h, 08h, 0BAh, 0CDh, 0DEh, 0Fh
db 34h, 06h, 09h, 08h, 0BAh, 0CDh, 0DEh, 0Fh
db 10h,4,11h,4,12h,4,31h,0
dd 0, 0, 0, 0, 0, 0
db "Dyn. provider v8"
db "©avkiev 24.06.05"
; ---------------------------------------------------------------------------
Entry: PUSH {r0,r1,r4,r5,r7,LR}
; r4-buffer, r5-counter, r6-format, r7-rama
bl GetProfile-q1
add r0, #1
cmp r0, #7
pop {r0,r1}
push {r0,r1}
bne DoPatch
bl GetProvider-q1
b expatch
DoPatch: ldr r4, [r0]
mov r5, #0
LoadReg 7, aRama
LoadReg 0, aIsScreenSaver
blx r0
lsl r6, r0, #1
LoadReg 0, aIsUnlocked
blx r0
add r6, #1
sub r6, r0
lsl r6, #3
ldr r0, [r7, #10h]
add r0, #1
mov r1, #7
and r0, r1
str r0, [r7, #10h]
LoadReg 3, aFormat
add r6, r3
ldrb r6, [r6, r0]
mov r0, r7 ; Date
mov r1, r7
add r1, #8 ; Time
LoadReg 3, aGetDateTime
blx r3
; mov r6, #0x08 ; ==============
ProcessR6: cmp r6, #16
bcc nibble2
lsr r3, r6, #4
bl ProcessR3
AddImm " "
nibble2: mov r3, #0Fh
and r3, r6
bl ProcessR3
lsr r5, #1
strh r5, [r4]
expatch: pop {r0,r1,r4,r5,r7,PC}
; ---------------------------------------------------------------------------
ProcessR3: push {r3, LR}
mov r0, r7
bl GetWeek - q1
pop {r3}
lsl r3, #1
add PC, r3
fun0: pop {PC}
; ---------------------------------------------------------------------------
b fun0
b fun1
b fun2
b fun3
b fun4
b fun5
b fun6
b fun7
b fun8
b fun9
b funA
b funB
b funC
b funD
b funE
b funF
; ---------------------------------------------------------------------------
fun1: LoadReg 0, aFormat ; Uni-string
add r0, #20h
b AddUni+2
; ---------------------------------------------------------------------------
fun2: LoadReg 0, aFiledp ; Filename
mov r2, #0
b AddTMO+2
; ---------------------------------------------------------------------------
fun3: ldrb r1, [r7, #8] ; Time 10:26
bl Add2Dig
AddImm ":"
ldrb r1, [r7, #9]
b Add2Dig+2
; ---------------------------------------------------------------------------
fun4: bl AddDay ; Date 11.02.2005
AddImm "."
ldrb r1, [r7, #4]
bl Add2Dig
mov r3, #"."
b AddYear
; ---------------------------------------------------------------------------
fun5: ldrb r1, [r7, #4] ; Date 02/11/2005
bl Add2Dig
AddImm "/"
bl AddDay
mov r3, #"/"
b AddYear
; ---------------------------------------------------------------------------
fun6: LoadReg 1, aMonthShort ; Date We, 11 Feb 2005
add r1, #13
bl AddMes
AddImm ","
AddImm " "
bl AddDay
AddImm " "
ldrb r0, [r7, #4]
LoadReg 1, aMonthShort
bl AddMes
mov r3, #" "
AddYear: add r5, #2
strh r3, [r4,r5]
ldrh r1, [r7]
b Add4Dig+2
; ---------------------------------------------------------------------------
fun7: ldrb r0, [r7, #4] ; Date February, 10
mvi r1, 118Bh
bl AddMes
mov r3, #","
strh r3, [r4,r5]
AddImm " "
ldrb r1, [r7, #5]
b Add2Dig+2
; ---------------------------------------------------------------------------
; db 0xD6, 0xE2, 0xD7, 0xD8, 0xD9, 0xDA, 0xD5, 0
;fun8: mov r1, PC ; Понедел.
; sub r1, #12
; ldrb r0, [r1, r0]
; b r1_400
; mov r0, r7
; str r4, [r0]
fun8: pop {r0}
pop {r0,r1,r4,r5,r7}
pop {r2}
mov lr, r2
LoadReg 2, aMiniGPS
bx r2
; ---------------------------------------------------------------------------
fun9: add r0, #1 ; Понедельник
cmp r0, #7
bne r1_400
mov r0, #0
r1_400: mov r1, #4
lsl r1, #8
b AddMes+2
; ---------------------------------------------------------------------------
funA: mov r0, #0 ; 3,812 = 25%
mov r1, #9
LoadReg 2, aGetAkku
blx r2
add r5, #2
bl Add4Dig0
sub r5, #6
bl InsComma
add r5, #6
mov r3, #" "
strh r3, [r4,r5]
AddImm "="
funA_2: LoadReg 1, aRamCap
AddImm " "
ldrh r1, [r1]
cmp r1, #100
bcc less100
AddImm "1"
mov r1, #0
less100: bl Add2Dig
AddImm "%"
pop {PC}
; ---------------------------------------------------------------------------
funB: mov r0, #1 ; 25,7'C
mov r1, #3
LoadReg 2, aGetAkku
blx r2
mvi r1, 2730
sub r0, r1
mov r1, #0
lsl r2, r1, #24
asr r1, r2, #24
add r0, r1
bpl plus
AddImm "-"
neg r0, r0
plus: bl Add4Dig0
sub r5, #4
bl InsComma
bl InsComma
AddImm 0xB0
AddImm "C"
pop {PC}
; ---------------------------------------------------------------------------
funC: mov r0, r7
add r0, #14h
add r1, r4, r5 ; UMC
str r1, [r0]
ldrh r2, [r1]
push {r2}
bl GetProvider-q1
pop {r2}
ldrh r1, [r4, r5]
strh r2, [r4, r5]
lsl r1, #1
add r5, r1
pop {PC}
; ---------------------------------------------------------------------------
funD: ; -65 dB
mov r3, #"-" ; 900
LoadReg 0, aRamNetCH
ldrh r1, [r0]
cmp r1, #0xFF
bcc n1800
mov r3, #"=" ; 1800
n1800: add r5, #2
strh r3, [r4,r5]
ldrb r1, [r0, #6]
cmp r1, #100
bcc NetLess100
AddImm "1"
sub r1, #100
NetLess100: bl Add2Dig
AddImm " "
AddImm "d"
AddImm "B"
pop {PC}
; ---------------------------------------------------------------------------
funE: LoadReg 0, aRamNetCH ; 804:01589-9110
ldrh r1, [r0]
bl Add4Dig
mov r0, #20h
sub r1, r5, #6
strh r0, [r4, r1]
AddImm ":"
funE_2: LoadReg 0, aRamNetCH
add r0, #2
bl Add5Dig
AddImm "-"
LoadReg 0, aRamNetCH
ldrh r1, [r0, #4]
b Add4Dig+2
; ---------------------------------------------------------------------------
funF: sub SP, #40
LoadReg 0, aRamNetCH
ldrh r2, [r0, #4]
ldrh r3, [r0, #2]
str r2, [SP]
add r0, SP, #4
LoadReg 1, aFiledp
add r1, #18h
CallARM sprintf
add r0, SP, #4
mov r2, #4
bl AddTMO
add SP, #40
bpl exTMO
pop {r6}
mov r6, #08h
b ProcessR6
; ---------------------------------------------------------------------------
; Subroutine
; ---------------------------------------------------------------------------
AddTMO: push {LR}
mov r1, r7
add r1, #18h
push {r2}
bl OpenReadCloseFile - q1
pop {r2}
bmi exTMO
ldr r0, [r7, #18h]
ldrh r1, [r0]
lsl r1, #1
add r0, #2
mov r3, #0
strh r3, [r0, r1]
add r0, r2
bl AddUni
ldr r0, [r7, #18h]
bl mFree_high - q1
mov r0, #0
exTMO: pop {PC}
; ---------------------------------------------------------------------------
AddUni: push {LR}
ldrh r3, [r0]
add r0, #2
add r5, #2
strh r3, [r4,r5]
cmp r3, #0
bne AddUni+2
sub r5, #2
pop {PC}
; ---------------------------------------------------------------------------
AddMes: push {LR}
add r0, r1 ; r0+r1 - Mes
mov r1, r7
add r1, #18h
LoadReg 3, aGetLP
blx r3
mov r0, r7
add r0, #18h
mod0: mov r1, #0 ; AddUniFromSiem
newmod: lsl r2, r1, #4
nextchs: ldrb r3, [r0]
add r0, #1
cmp r3, #0
beq byeAUFS
cmp r3, #0xA4
beq byeAUFS
cmp r3, #95h
beq mod0
mov r1, #8h
cmp r3, #96h
beq newmod
mov r1, #10h
cmp r3, #97h
beq newmod
mov r1, #38h
cmp r3, #9Ah
beq newmod
mov r1, #40h
cmp r3, #9Bh
beq newmod
add r3, r2
add r5, #2
strh r3, [r4,r5]
b nextchs
byeAUFS: pop {PC}
; ---------------------------------------------------------------------------
AddDay: ldrb r1, [r7, #5]
Add2Dig: push {LR}
mov r0, #10
CallARM DivR1byR0
add r0, #30h
AddReg r0
add r1, #30h
AddReg r1
pop {PC}
; ---------------------------------------------------------------------------
Add4Dig0: mov r1, r0
Add4Dig: push {LR}
mov r0, #100
CallARM DivR1byR0
push {r1}
mov r1, r0
bl Add2Dig
pop {r1}
b Add2Dig+2
; ---------------------------------------------------------------------------
Add5Dig: push {LR} ; r0 - address
ldrh r1, [r0]
mvi r0, 10000
CallARM DivR1byR0
add r0, #30h
AddReg r0
b Add4Dig+2
; ---------------------------------------------------------------------------
InsComma: push {LR}
ldrh r0, [r4,r5]
mov r1, #","
strh r1, [r4, r5]
sub r5, #2
strh r0, [r4, r5]
add r5, #4
pop {PC}
; ---------------------------------------------------------------------------
Align4
aGetDateTime:dd GetDateTime
aGetAkku: dd GetAkku
aGetLP: dd GetLP
aIsUnlocked:dd IsUnLocked
aIsScreenSaver: dd IsScreenSaver
aRamCap: dd RamCap
aRamNetCH: dd RamNetCH
aMonthShort:dd 1297h
aFormat: dd q0+Format
aFiledp: dd q0+Filedp
aMiniGPS: dd q1+0x0801506
Filedp: db "0:\Misc\DynProvider.tmo",0
Filegps: db "0:\Misc\gps\%i\%i-%i.tmo"
aRama: dd Rama
; ---------------------------------------------------------------------------
org Vrezka
dd q1+Entry
; ---------------------------------------------------------------------------
END
[/code]
|