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. that is what I have to do,this is what I have so far but its not working, Can someone point out what is wrong or what need to be changed

49 00 30
D1 00 30
1C
F1 00 33
51 00 33
zz

which cpu? with objectcode alone we can't get far, however:
3 bits means that the numbers can be maximum 7
000 = 0 , 111 = 7 (add one bit more results in 4 bits numbers
adding 30h (48 decimal) to 3 bits numbers give you the ASCII result:
"0" = 30h, "001" = 31h etc
that ascii code you can use to put on screen. (if that is what you mean) much more conversion there is not, unless the 3 bit numbers must be seen as an larger octal number (base 8) but that wasn't the question.
I hope it is clear otherwise send an example of your code.

I uploaded a pic of what I use, I use the instruction specefier then I convert it to hexadecimal and write the objecet code

``````try this.
I didnt provide spaces on where to store them.

49 00    // read 1st char
49 00    // read 2nd char
49 00    // read 3rd char
d1 00    // load 1st to accum
80 00 30 // subtract 30
1c       // multiple by 2
1c       // multi by 2
e1 00    // store <-1st
c0 00 00 // make accum 0
d1 00    // load 2nd char
80 00 30 // sub 30
1c       // multiply by 2
e1 00    // store <-2nd
c0 00 00 // accum to 0
80 00 30 // subtract 30
e1 00    // store <-3rd
c0 00 00 // accum to 0
e1 00    // save
39 00    // display
00
zz
``````
``````         BR main
``````

ans: .WORD 0x0000
num1: .BLOCK 2
num2: .BLOCK 2
num3: .BLOCK 2
main: LDA ans.d
DECI num2,d
DECI num3,d
SUBA num2,d
SUBA num2,d
SUBA num2,d
DECI num1,d
SUBA num1,d
SUBA num1,d
SUBA num1,d
STA ans,d
DECO sum,d
STOP
.END

Convert it into machine code

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.