admin管理员组文章数量:1429953
Tricky question about a a project in machine code, effectively Assembly code without labels. We are trying to find the length of a list that will change each time. The problem is, without labels, we can't change the PC offset dynamically to step back the correct amount in the memory to start iterating through the list. I'll provide the code below:
0011 0000 0000 0000 ; Starting memory location
0000 0000 0100 0011 ; List items, also below
0000 0000 0110 1110
0000 0000 0110 1011
0000 0000 0110 1101
0000 0000 0100 1111
0000 0000 0101 1110
0000 0000 0110 0011
0000 0000 0000 0000
1110011111110111 ; LEA R3, #-10
0101010010100000 ; AND R2, R2, #0
0110001011000000 ; LDR, R1, R3, #0
0000010000000110 ; BRz, #-7
0001001001000010 ; ADD R1, R1, R2
0001000001100000 ; ADD R0, R1, #0
1111000000100001 ; OUT
0001010010100001 ; ADD R2, R2, #1
0001011011100001 ; ADD R3, R3, #1
0000101111111000 ; BRnp #-8
1111000000100101 ; Halt
This code should take a list and:
- Initialize index to zero
For each data value:
- Add index to the value
- Output the resulting sum as an ASCII character
- Increment index
- Repeat for the next data value until the terminating value is reached
- Halt the program
This works, the problem is, on the line BRz #-7
we need the #-7
to change dynamically based on the size of the list initally loaded in. Any thoughts, ideas, or solutions are greatly appreciated!
本文标签: How can I make a dynamically changing list size variable in machine code (Assembly)Stack Overflow
版权声明:本文标题:How can I make a dynamically changing list size variable in machine code? (Assembly) - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745546984a2662748.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论