我被困在这项任务上: 在目标代码中编写一个程序,将3位二进制数转换为十进制数。例如,如果输入为101,则输出应为5;如果输入为011,则输出应为3。 到目前为止,这是我的代码:
49 00 50 - Input char 1
49 00 51 - Input char 2
49 00 53 - Input char 3
c0 00 00 - 0 memory
d1 00 50 - Load char 1
80 00 48 - subtract 48 cose 0 is 48 in dec
1c - shift to left
1c - shift to left again cose 3rd position in binary is x4
e1 00 60 - store int 1
d1 00 51 - load char 2
80 00 48 - subtract 48 cose 0 is 48 in dec
1c - shift to left cose 2nd position in binary is x2
e1 00 62 - store int 2
d1 00 53 - load char 3
80 00 48 - subtract 48 cose 0 is 48 in dec
71 00 60 - add int 1
71 00 62 - add int 2
f1 00 64 - store char
51 00 64 - output character
00
zz
有人可以帮助我并指导我如何做到这一点,请记住我刚开始使用pep8 2周前。 谢谢
答案 0 :(得分:0)
04 00 06 00 00 00 49 00 03 D1 00 03 80 00 30 1C 1C E1 00 04 49 00 03 D1 00 03 80 00 30 1C 71 00 04 E1 00 04 49 00 03 D1 00 03 80 00 30 71 00 04 E1 00 04 39 00 04 00 zz
此代码仅针对3位二进制值
编写