我正在尝试遍历整数数组,以将每个整数分为五个类别之一。我正在用arm汇编编写程序,到目前为止,这是我想到的要遍历数组然后使用整数的方法。
.data
str1: .asciz "Lost Generation: %d"
str2: .asciz "Greatest Generation: %d"
str3: .asciz "Baby Boomer Generation: %d"
str4: .asciz "Generation X: %d"
str5: .asciz "Generation Y: %d"
str6: .asciz "Generation Z: %d"
str7: .asciz "Not Applicable: %d"
ary: .word 100,40,5
.equ arysize,(. - ary)/4
.text
.global main
main: stmfd sp!,{lr}
mov r0,#0
read: cmp r0,arysize
beq end
ldr r1,=ary
add r2,r1,r2
ldr r1,[r2]
add r0,r0,#1
b lg
lg: cmp r1,#127
ble lg2
add r12,r12,#1
lg2: cmp r1,#102
blt gg
add r6,r6,#1
gg: cmp r1,#101
ble gg2
b @not applicable
gg2: cmp r1,#93
blt bb
add r7,r7,#1
end: ldmfd sp!,{lr}
mov pc,lr
我很好奇,好像我朝着正确的方向前进。我当前的计划是使用当前整数,例如第一个整数是100。我希望寄存器中有100,然后通过一系列比较将其进行比较,以查看将其放入哪个类别。谢谢!