- #1
sandy.bridge
- 798
- 1
Homework Statement
Hey guys. I am just learning machine code for Cortex-M. There are a few exercises within the textbook, however, I am not entirely sure if I am doing them correctly. If you could possible look over my work to see if there are any mistakes, I would greatly appreciate it! They are supposed to be relatively simple, however, I am still not entirely sure.
Each line represents a specific set of machine code. I will provide the code adjacent in brackets.
R0----R1----R2
0x45-----------(MOV R0, #0x45)
0x45 0x02------(MOV R1, #0x02)
0x45 0x02 0x47 (ADD R2, R0, R1)
0x45 0x02 0x43 (SUB R2, R0, R1)
0x45 0x02 0x43 (SUBS R2, R0, R1)
0x45 0x02 0x05 (AND R2, R0, #0x01)
0x45 0x02 0x05 (ORR R0, R0, #0x01)
0x0F 0x02 0x05 (MOV R0, #0x0F)
0x0F 0x0F 0x05 (MOV R1, #0x0F)
0x0F 0x0F 0x05 (CMP R1, R0)
0x0F 0x0F 0x00 (SUBS R2, R0, R1)
The other part had to do with with flags. We are given A and B, two 8-bit numbers, where R = A + B. We have to determine what R would equal, and what the values of the flag registers would be (NZVC).
A---------- B---------- R---------- NZVC
10--------100---------110-------- 0000
0x40------0xA2--------0xC0-------0000
0xC3------0x6F--------0x32-------0001
100-- ----(-100)-------0---------- 0100
110-------146---------0---------- 0101
50---------206-------- 0---------- 0101