程序示例
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.section .text
.align 2
.global main
main:
push {lr}
ldr r0, =.LC0
mov r1, #10
mov r2, #20
mov r3, #30
@r1 = r1 * r2 + r3
mla r1, r1, r2, r3
bl printf
mov r0, #0
pop {pc}
程序示例
.section .rodata
.align 2
.LC0:
.string "val = %d %d\n"
.section .text
.align 2
.global main
main:
push {lr}
ldr r0, =.LC0
mov r3, #3
mov r4, #5
umull r1, r2, r3, r4
bl printf
mov r0, #0
pop {pc}
程序示例
.section .rodata
.align 2
.LC0:
.string "val = %d %d\n"
.section .text
.align 2
.global main
main:
push {lr}
ldr r0, =.LC0
mov r1, #1
mov r2, #0
mov r3, #3
mov r4, #5
umlal r1, r2, r3, r4
bl printf
mov r0, #0
pop {pc}
.section .rodata
.align 2
.LC0:
.string "val = %d %d\n"
.section .text
.align 2
.global main
main:
push {lr}
ldr r0, =.LC0
mov r1, #1
mov r2, #0
mov r3, #3
mov r4, #5
smull r1, r2, r3, r4
bl printf
mov r0, #0
pop {pc}
程序示例
.section .rodata
.align 2
.LC0:
.string "val = %d %d\n"
.section .text
.align 2
.global main
main:
push {lr}
ldr r0, =.LC0
mov r1, #1
mov r2, #0
mov r3, #3
mov r4, #5
smlal r1, r2, r3, r4
bl printf
mov r0, #0
pop {pc}
程序示例:
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.section .text
.align 2
.global main
main:
push {lr}
ldr r0, =.LC0
mov r1, #2
mvn r2, #0
mov r3, #10
mov r4, #20
@会设置C位
add r1, r1, r2
adc r1, r3, r4
bl printf
mov r0, #0
pop {pc}
程序示例
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.section .text
.align 2
.global main
main:
push {lr}
ldr r0, =.LC0
mov r3, #10
mov r4, #20
adc r1, r3, r4
bl printf
mov r0, #0
pop {pc}
程序示例
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.section .text
.align 2
.global main
main:
push {lr}
ldr r0, =.LC0
mov r1, #0
msr cpsr, r1
mov r3, #10
mov r4, #20
adc r1, r3, r4
bl printf
mov r0, #0
pop {pc}
程序示例
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.section .text
.align 2
.global main
main:
push {lr}
ldr r0, =.LC0
mov r1, #0
msr cpsr, r1
mov r1, #-1
mov r2, #3
adds r1, r1, r2
mov r3, #10
mov r4, #20
adc r1, r3, r4
bl printf
mov r0, #0
pop {pc}
程序示例
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.LC1:
.string "cpsr = %p\n"
.section .text
.align 2
.global main
main:
push {lr}
mrs r1, cpsr
mvn r1, #0
msr cpsr, r1
ldr r0, =.LC1
mrs r1, cpsr
bl printf
mov r3, #10
mov r4, #20
sbc r1, r4, r3
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
程序示例
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.LC1:
.string "cpsr = %p\n"
.section .text
.align 2
.global main
main:
push {lr}
ldr r0, =.LC1
mrs r1, cpsr
bl printf
mov r3, #10
mov r4, #20
adc r1, r3, r4
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
程序示例
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.LC1:
.string "cpsr = %p\n"
.section .text
.align 2
.global main
main:
push {lr}
ldr r0, =.LC1
mrs r1, cpsr
bic r1, r1, #(1 << 29)
msr cpsr, r1
mov r3, #10
mov r4, #20
adc r1, r3, r4
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
程序示例
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.LC1:
.string "cpsr = %p\n"
.section .text
.align 2
.global main
main:
push {lr}
mrs r1, cpsr
mvn r1, #0
msr cpsr, r1
ldr r0, =.LC1
mrs r1, cpsr
bl printf
mov r3, #10
mov r4, #20
adc r1, r3, r4
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
程序示例
@r1 = 100*230-(236&(1<<7))+(157|(1<<17))-(123^456);
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.section .text
.align 2
.global main
main:
push {lr}
@100 * 230
mov r3, #100
mov r4, #230
mul r1, r3, r4
mov r2, #236
and r2, r2, #(1 << 7)
sub r1, r1, r2
mov r2, #157
orr r2, r2, #(1 << 17)
add r1, r1, r2
mov r2, #123
mov r3, #456
eor r2, r2, r3
sub r1, r1, r2
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
程序示例
@ r1 = 255 把r1的第4位清0,第15位置一;
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.section .text
.align 2
.global main
main:
push {lr}
mov r2, #0xff
bic r2, r2, #(1 << 4)
orr r1, r2, #(1 << 15)
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
程序示例
@r1 = 255 只把r1的第4位和第7位清0;
.section .rodata
.align 2
.LC0:
.string "val = %d\n"
.section .text
.align 2
.global main
main:
push {lr}
mov r2, #0xff
bic r1, r2, #(1 << 4 | 1 << 7)
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
程序示例
@ r1 = 0x3456 把r1的第4到第10位清0,其他位不变;
.section .rodata
.align 2
.LC0:
.string "val = %p\n"
.section .text
.align 2
.global main
main:
push {lr}
mov r2, #0x3400
add r2, r2, #0x56
bic r1, r2, #(0x7f << 4)
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
程序示例
@r1 = 0x3456 把r1的第4到第10位置1,其他位不变;
.section .rodata
.align 2
.LC0:
.string "val = %p\n"
.section .text
.align 2
.global main
main:
push {lr}
mov r2, #0x3400
add r2, r2, #0x56
orr r1, r2, #(0x7f << 4)
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
程序示例
@r1 = 0x3456 把r1的第4到第10位设成0b1001110,其他位不变;
.section .rodata
.align 2
.LC0:
.string "val = %p\n"
.section .text
.align 2
.global main
main:
push {lr}
mov r2, #0x3400
add r2, r2, #0x56
bic r1, r2, #(0x7f << 4)
orr r1, r1, #(0b1001110 << 4)
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
程序示例
@r1 = 0x3456 把r1的第4到第10位取反,其他位不变;
.section .rodata
.align 2
.LC0:
.string "val = %p\n"
.section .text
.align 2
.global main
main:
push {lr}
mov r2, #0x3400
add r2, r2, #0x56
eor r1, r2, #(0x7f << 4)
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
@r1 = 0x3456 取出r1的第4到第10位的值;
.section .rodata
.align 2
.LC0:
.string "val = %p\n"
.section .text
.align 2
.global main
main:
push {lr}
mov r2, #0x3400
add r2, r2, #0x56
and r1, r2, #(0x7f << 4)
mov r1, r1, LSR #4
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
@ r1 = 0x3458把r1中最后的1清除,其他位保持不变;
.section .rodata
.align 2
.LC0:
.string "val = %p\n"
.section .text
.align 2
.global main
main:
push {lr}
mov r2, #0x3400
add r2, r2, #0x58
sub r3, r2, #1
and r1, r2, r3
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}
@r1 = 0x3458 把r1中倒数二个的1清除,其他位保持不变;
.section .rodata
.align 2
.LC0:
.string "val = %p\n"
.section .text
.align 2
.global main
main:
push {lr}
mov r2, #0x3400
add r2, r2, #0x58
sub r3, r2, #1
and r1, r2, r3
sub r2, r1, #1
and r1, r1, r2
ldr r0, =.LC0
bl printf
mov r0, #0
pop {pc}