Documentos de Académico
Documentos de Profesional
Documentos de Cultura
Use the .LIS and .MAP file provided on the last 3 pages of this test to answer the following
questions:
[15 marks]
a.
What value is stored in the byte of memory at memory location 0x1023. Express your
answer in hexadecimal.
0x3C
b.
What value is stored in the byte of memory at memory location 0x122A. Express your
answer in hexadecimal.
0x66
c.
If you wanted to stop the program at line 54 in subroutine InStr, which address would
you use to set the breakpoint? (This equivalent to asking at what address would the
machine code for this line be loaded into memory). Express your answer in
hexadecimal.
0x000A + 0x1214 = 0x121E
d.
Assuming that this program is run in Supervisor mode and that the SSP starts out with a
value of 00007EA8, immediately following the JSR at line 45 of the main program
(isdemo.a68):
i.
What would be the value in the SSP? Express your answer in hexadecimal.
0x0000 7EA4
ii.
What would be the value in memory at the addresses given by the SSP? Express
your answer as a long word value, in hexadecimal.
0x0000 103E
est
2.
Use the register contents and the partial dump of memory provided below to answer the
questions which follow.
[15 marks]
|D 00002020 00002024 00002028 0000202C 00002030 00002034 00002038 0000203C
|A 00002000 00002008 0000200C 00002010 00002014 00002018 0000201C
|USP=00007700 SSP=00007F00
SR=2700 Tr=0 S=1 Int=7 X=0 N=0 Z=0 V=0 C=0
+--------------------------------------------------------------------------|--------------------------- Memory at 00002000 ---------------------------0 1 2 3 4 5 6 7 8 9 A B C D E F
0 2 4 6 8 A C E
00002000 12 23 34 45 56 67 78 89 9A AB BC CD DE EF F0 01 /..A............./
00002010 13 24 35 46 57 68 79 8A 9B AC BD CE DF E0 F1 02 /................/
00002020 14 25 36 47 58 69 7A 8B 9C AD BE CF D0 E1 F2 03 /................/
00002030 15 26 37 48 59 6A 7B 8C 9D AE BF C0 D1 E2 F3 04 /................/
a.
b.
c.
d.
e.
3.
Code a subroutine/function which implements the following C program function:
[15 marks]
long int test2a ( long int num1, long int num2)
{ long int val;
if ( num1 > num2)
{ val = -99;
}
else
{ val = num1 - num2;
}
return val;
}
Assume that the argument values for num1 and num2 have been passed on the stack, and that
the return value is to be in D0.
Upon return from this function no data or address register other than D0 should contain a
different value than it con
| LINK not required according to question
.EQU NUM1,4
.EQU NUM2,8
.GLOBAL
test2a
MOVE.L
CMP.L
BLE
MOVE.L
BRA
|
|
test2a:
NotGreaterThan:
SUB.L
endif:
(NUM1,SP),D0
(NUM2,SP),D0
NotGreaterThan
#-99, D0
endif
4,sp
8,sp
(NUM2,SP),D0
RTS
est
page 1
19
20 0046 456E 7465
20
7220 6120
20
6C69 6E65
20
206F 6620
20
7465 7874
21
.TEXT
1
msgPrompt:.asciz "Enter a line of text: "
23 005d 00
24
25 0000 0000 0000
.DATA
.SET
buffer:
.space
28
29
30
31
32
33
33
34
35
35
36
36
37
37
38
39
39
40
41
41
42
42
43
44
44
45
45
46
46
47
48
BUFF_SIZE,256
BUFF_SIZE,0
.TEXT
0
.GLOBAL start
0000 41FA 0044
0004 4EB9 0000
0000
start:
LEA
JSR
msgPrompt,A0
PrintMsg
LEA
buffer,A0
JSR
InStr
JSR
NewLine
001c 4EB9
0000
0022 123C
0026 4EB9
0000
002c 4EB9
0000
0000
JSR
StrLen
0008
0000
MOVE.B
JSR
#8,D1
OutHex
0000
JSR
NewLine
LEA
buffer,A0
JSR
PrintMsg
JSR
NewLine
0044 4E75
RTS
page 1
est
47
48
49
50
51
52
53
53
54
55
56
57
58
59
60
60
61
61
62
63
63
64
64
65
66
67
68
68
69
70
71
72
73
0000
.SET
BS,0x08
| Backspace code
.TEXT 0
.GLOBAL InStr
InStr:
MOVEM.L
A0/D0,-(SP)
_instrRepeat:
JSR
ConsoleIn
000D
003E
0008
002A
0004
FFE4
0000
CMP.B
BEQ
CMP
BNE
CMPA.L
BEQ
SUBA.L
#CR,D0
_instrDone
#BS,D0
_instrInsert
4(SP),A0
_instrRepeat
#1,A0
0000
JSR
CursorLeft
0020
0000
MOVE.B #0x20,D0
JSR
ConsoleOut
0000
JSR
FFC4
0042 10C0
0044 4EB9 0000
0000
004a 6000 FFB8
004e 10BC 0000
0052 4CDF 0101
0056 4E75
BRA
_instrRepeat
_instrInsert:
MOVE.B D0,(A0)+
JSR
ConsoleOut
BRA
_instrRepeat
_instrDone:
MOVE.B #0,(A0)
MOVEM.L
(SP)+,A0/D0
RTS
page 1
2
3
7
8
9
10
11
12
13
14
15
16
17
CursorLeft
.TITLE
.PSIZE
0000 2F08
0002 9080
0004
0008
000c
000e
0C18 0000
6700 0008
5280
6000 FFF4
0012 205F
0014 4E75
.GLOBAL
MOVE.L
SUB.L
eachChar:
CMP.B
BEQ
ADD.L
BRA
doneStrLen:
MOVE.L
RTS
StrLen:
"String Length"
35,80
StrLen
A0,-(SP)
D0,D0
#0,(A0)+
doneStrLen
#1,D0
eachChar
(SP)+,A0
| exit from program
est
Origin
0x00000000
Length
0xffffffff
Attributes
.text
*fill*
.text
.text
*fill*
.data
*(.data)
.data
0x00001000
0x300
0x00001000
0x00001000
0x0000105e
0x00001060
0x00001104
0x000011ca
0x000011b8
0x00001074
0x000010d2
0x000011dc
0x00001060
0x00001196
0x000011fc
0x000011fc
0x00001212
0x00001214
0x00001214
0x0000126c
0x000012c4
0x00001298
0x0000126c
0x000012ae
0x00001282
0x000012da
0x000012f0
0x000012ee
0x5e isdemo.o
start
0x2
0x19c ..\lib\bdblib.o
InHex
ConsoleOut
ConsoleIn
NewLine
AsciiToHex
ConsoleEcho
PrintMsg
OutHex
0x16 strlen.o
StrLen
0x2
0x58 instr.o
InStr
0x82 scrnctrl.o
ClrScrn
CursorLeft
CursorUp
CursorRight
CursorDown
ClrEOL
. = ALIGN (0x4)
0x2
0x00002000
0x100
0x00002000
0x00002100
0x100 isdemo.o
edata = .
est
OUTPUT(isdemo.hex srec)
est