4 Replies - 445 Views - Last Post: 23 October 2013 - 10:19 PM

#1 lamentofking  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 167
  • Joined: 03-July 13

Determine the object code and predict the output

Posted 22 October 2013 - 02:02 PM

This question operates under the Pep/8 instruction set (I decided to include this because I know how assembly languages are not created equal):

Determine the object code and predict the output of the following assembly language programs:

(a)

DECO 'm' , i
CHARO '\n' , i
DECO "mm", i
CHARO '\n', i
CHARO 0x0026, i
STOP
.END




(B)/>

DECO 'Q', i
CHARO '\n', i
DECO 0xFFC3, i
CHARO '\n', i
CHARO 0x007D, i
STOP
.END


I'd like to start with (a) first and perhaps once I understand that I can do (B).

For (a) the answer is (minus the object code):

[u]Output[/u]
109
28013
&


I know where 109 and & come from but how did the program output 28013? I can only think that it came from the line DECO "mm", i but I don't see how to get the correct output.

Is This A Good Question/Topic? 0
  • +

Replies To: Determine the object code and predict the output

#2 turboscrew  Icon User is offline

  • D.I.C Addict

Reputation: 100
  • View blog
  • Posts: 615
  • Joined: 03-April 12

Re: Determine the object code and predict the output

Posted 22 October 2013 - 09:40 PM

View Postlamentofking, on 23 October 2013 - 12:02 AM, said:

This question operates under the Pep/8 instruction set (I decided to include this because I know how assembly languages are not created equal):

Determine the object code and predict the output of the following assembly language programs:

(a)

DECO 'm' , i
CHARO '\n' , i
DECO "mm", i
CHARO '\n', i
CHARO 0x0026, i
STOP
.END




(B)/>/>

DECO 'Q', i
CHARO '\n', i
DECO 0xFFC3, i
CHARO '\n', i
CHARO 0x007D, i
STOP
.END


I'd like to start with (a) first and perhaps once I understand that I can do (B)/>.

For (a) the answer is (minus the object code):

[u]Output[/u]
109
28013
&


I know where 109 and & come from but how did the program output 28013? I can only think that it came from the line DECO "mm", i but I don't see how to get the correct output.


Yes. The ASCII code of 'm' is hex 6D = dec 109.
"mm" = hex 6D6D = dec 28013.
Was This Post Helpful? 0
  • +
  • -

#3 turboscrew  Icon User is offline

  • D.I.C Addict

Reputation: 100
  • View blog
  • Posts: 615
  • Joined: 03-April 12

Re: Determine the object code and predict the output

Posted 23 October 2013 - 01:24 AM

pep/8 as well as LC-3 are a bit hard, because there is very little documentation in the net, and I don't have any intentions to buy those books, for which they were invented.

LMC is a bit better in that respect.

I don't really get what you are supposed to do ("Determine the object code"), but:
Here:
0101 0aaa CHARO

This was listed under "The unimplemented opcode instructions"
DECO! Decimal output trap

This post has been edited by turboscrew: 23 October 2013 - 01:32 AM

Was This Post Helpful? 0
  • +
  • -

#4 lamentofking  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 167
  • Joined: 03-July 13

Re: Determine the object code and predict the output

Posted 23 October 2013 - 04:48 PM

View Postturboscrew, on 22 October 2013 - 09:40 PM, said:

View Postlamentofking, on 23 October 2013 - 12:02 AM, said:

This question operates under the Pep/8 instruction set (I decided to include this because I know how assembly languages are not created equal):

Determine the object code and predict the output of the following assembly language programs:

(a)

DECO 'm' , i
CHARO '\n' , i
DECO "mm", i
CHARO '\n', i
CHARO 0x0026, i
STOP
.END




(B)/>/>/>

DECO 'Q', i
CHARO '\n', i
DECO 0xFFC3, i
CHARO '\n', i
CHARO 0x007D, i
STOP
.END


I'd like to start with (a) first and perhaps once I understand that I can do (B)/>/>.

For (a) the answer is (minus the object code):

[u]Output[/u]
109
28013
&


I know where 109 and & come from but how did the program output 28013? I can only think that it came from the line DECO "mm", i but I don't see how to get the correct output.


Yes. The ASCII code of 'm' is hex 6D = dec 109.
"mm" = hex 6D6D = dec 28013.
Oh. My ASCII chart doesn't go that far. I was thinking ASCII mm meant the hex value of m * the hex value of m .
Was This Post Helpful? 0
  • +
  • -

#5 turboscrew  Icon User is offline

  • D.I.C Addict

Reputation: 100
  • View blog
  • Posts: 615
  • Joined: 03-April 12

Re: Determine the object code and predict the output

Posted 23 October 2013 - 10:19 PM

Just two ASCII codes (bytes) of 'm' one after another (string) seen as 2-byte integer.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1