Predict the output of the program in Figure 5.13 if the dot commands are changed
ID: 3810074 • Letter: P
Question
Predict the output of the program in Figure 5.13 if the dot commands are changed to
.WORD 0xFFC7 ;First
.BYTE 0x00 ;Second
.BYTE 'H' ;Third .
WORD 873 ;Fourth
FIGURE 513 A nonsense program to illustrate the interpretation of bit patterns. Branch around data 0000 120009 BR 0x0009 0003 FFFE First WORD 0xFFFE 0005 00 BYTE 0x00 Second Third 0006 55 BYTE 'U' Fourth 0007 0470 WORD 1136 0009 390003 DECO 0x0003, d Interpret First as dec 000C D0000A LDBA ,i 000F F1FC16 STBA 0xFC16, d 0x0005, d Interpret Second and Third as dec 0012 390 005 DECO 0015 F1 16 STBA. 0xFC16, d . 0018 DO 000A LDBA 001B 410005 HEXO 0x0005, d Interpret Second and Third as hex ', i 001E DO 000A LDBA. 0021 F1FC16 STBA. 0xFC16, d 0024 D100006 LDBA 0x0006, d Interpret Third as char 0027 F1FC16 STBA. 0xFC16, d 0x0008, d 002 A D10008 LDBA Interpret Fourth as char 002D F1FC16 STBA 0xFC 16, d 0030 00 STOP 0031 END Output 85 0055 UpExplanation / Answer
1.
DECO 0x0003,d ;Interpret First as decimal
Here First is generated as a hexidecimal value with .WORD 0xFFC7;First
but it is interpreted as a decimal number with instruction
DECO 0x0003,d ;Interpret First as decimal
So convert FFC7 to Decimal.
After converting, the decimal value will be -199.
So the output here is -199
2.
DECO always outputs the decimal value of two consecutive bytes.
Here the decimal output instruction
DECO 0x0005,d ;Interpret Second and Third as decimal
will start from 0x0005 and the value there is 00 and the value at
instruction 0x0006 is 55.
So DECO interprets the bits at address 0005 and 0006 (because it considers 2 consecutive bytes)
as a decimal number and outputs 85
(0055) in Hexadecimal = 85 in decimal.
So the output here is 85.
3.
The instruction HEXO 0x0005, d ; Interpret Second and Third as Hex
will interpret the value stored starting from 0x0005 and access 2 bytes similar to the DECO
instruction and output the value as Hexadecimal.
The value obtained is 0055 and since it is already in Hexadecimal, it is displayed.
So the output here is 55.
4.
The instruction LDBA 0x0006,d ;Interpret Third as character
interprets the bits at address 0006 as a character.
The character at 0x0006 is H.
So the output here is H.
5.
The instruction LDBA 0x0008,d ;Interpret Fourth as character
outputs a letter. Lets see which letter.
The fourth value is a decimal value = 873.
Now this value converted to Hexadecimal is 369.
The bits at memory location 0008 are 69 (hex), which are the bits for the ASCII character i.
So, the output here is i.
------------
Final output is
-199
85
55
Hi
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.