0

I got stuck on this assignment: Write a program in object code that will convert a 3-bit binary number to a decimal number. For example, if input is 101, output should be 5; if input is 011, output should be 3. This is my code so far:

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

Can someone help me and guide me how to do this, keep in mind that I just started with pep8 2 weeks ago. Thank you

Zero Piraeus
  • 56,143
  • 27
  • 150
  • 160
Zile
  • 21
  • 1
  • 9

1 Answers1

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

This code is written for only 3 bits binary values

toquart
  • 394
  • 2
  • 8