Problem

Table 1 gives the machine-language code for an imaginary machine language. Using this lang...

Table 1 gives the machine-language code for an imaginary machine language. Using this language, what will the action of the machine language program in Table 2 be?

Notice how few commands need to be defined (here. only 27) to have a working machine language that can do many things.

This small exercise in direct machine language is time-consuming enough to show how useful compilers are.

TABLE 1 An artificial machine language for Exercise. The first column is the alphanumeric label of the command, the second column is the hexadecimal code for the command, and the extra columns are for addresses or data used in executing the command. "aaa" represents an address in hexadecimal, and "ddd" represents data in hexadecimal.

HALT

000

 

stop execution

JUMP

001

aaa

jump to address aaa

JUMP IND

002

aaa

jump to address held in aaa

READ1

003

aaa

read data from address aaa into data register 1

READ1 IND

004

aaa

read data from address held in aaa to data register 1

WRITE1

005

aaa

write data register 1 to address aaa

WRITE1 IND

006

aaa

write data register 1 to address held in aaa

lNC1

007

 

increment data register 1

DEC1

008

 

decrement data register 1

IFZERO1

009

aaa

if data register 1 is 0, jump to address aaa

IF NEG1

00A

aaa

if data register 1 is negative, jump to address aaa

DATA1

00B

ddd

write data ddd directly to data register 1

READ2

00C

aaa

read data from address aaa into data register 2

READ2 IND

00D

aaa

read data from address held in aaa to data register 2

WRITE2

00E

aaa

write data register 2 to address aaa

WRITE2 IND

00F

aaa

write data register 2 la address held in aaa

lNC2

010

 

increment data register 2

DEC2

011

 

decrement data register 2

IF ZER02

012

aaa

data register 2 is 0, jump to address aaa

IF NEG2

013

aaa

data register 2 is negative, jump to address aaa

DATA2

014

ddd

write data ddd directly to data register 2

ADD

015

 

add data registers 1 and 2; write the result to data register 2

NEG2

016

 

change the sign (high bit) of data register 2 to negative

READ1 STACK

017

 

read top stack address to register 1

WRITE1 STACK

018

 

write register 1 to top of stack

READ2 STACK

019

 

read top stack address to register

WRITE2 STACK

0lA

 

write register 2 to top of stack

TABLE 2 Machine-language program using the definitions of Table 1 for Exercise. The first column is the address in memory, and the second column is data held at that address. The program always starts at the default address 000.

000

00B

001

00B

002

014

003

020

004

00E

005

030

006

006

007

030

008

010

009

00E

00A

030

00B

008

00C

008

00D

009

00E

013

00F

00A

010

013

01l

001

012

006

013

000

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 8
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT