forked from forth32/qtools
-
Notifications
You must be signed in to change notification settings - Fork 0
/
cmd_05_write_patched.asm
executable file
·34 lines (31 loc) · 1.75 KB
/
cmd_05_write_patched.asm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
; =============== S U B R O U T I N E =======================================
; Функция записи слова в память по указанному адресу.
; Фрмат вызова:
;
; 05 00 a0 a0 a2 a3 d0 d1 d2 d3
;
; a0-a3 - адрес, от младшего байта к старшему
; d0-d3 - слово для записи, от младшего байта к старшему
;
; Ответ загрузчика:
;
; 7e 06 06 кс кс 7e
cmd_05_write_patched ; DATA XREF: seg001:2A011900o
PUSH {R4,LR}
ADD.W R1, R0, #8 ; R1 теперь показывает на байт +4 от начала
; командного буфера
LDR R0, [R1] ; R0= адрес из командного буфера (+4)
LDR R1, [R1,#4] ; R1= данные для записи (+8)
STR R1, [R0] ; Записываем слово в память
LDR R0, =cmd_reply_code ; Адрес ответнго буфера
MOVS R2, #6 ; код ответа - 6
STRB R2, [R0,#(cmd_reply_code - 0x2A0132DC)] ; Записываем ответ в байт 0
STRB R2, [R0,#(cmd_reply_data0 - 0x2A0132DC)] ; и в байт 1 командного буфера
LDR R0, =cmd_processor_data ; Структура данных командного обработчика
MOVS R4, #2 ; длина ответного пакета
STRH R4, [R0,#(pkt_data_len - 0x2A0118BC)]
BL Prepare_reply_buf ; фрмируем ответный буфер - вписываем контрольную
; сумму и обрамление ответа
BL Send_reply_buf ; отсылаем ответный буфер хосту через USB
POP {R4,PC}
; End of function cmd_05_write_patched