I need to Write a program in Easy68K to fulfill the following functions: a) Read
ID: 3604729 • Letter: I
Question
I need to Write a program in Easy68K to fulfill the following functions: a) Read in two numbers from keyboard with instructions, one for index, one for the size of the array; b) Display the (index % size)th number in the initialized array [2 3 8 1 6 5 4].
I believe I have done this correctly, but my program lacks OUTPUT after I input the two numbers, any idea what is wrong with my program?
I need to Write a program in Easy68K to fulfill the following functions: a) Read in two numbers from keyboard with instructions, one for index, one for the size of the array; b) Display the (index % size)th number in the initialized array [2 3 8 1 6 5 4].
I believe I have done this correctly, but my program lacks OUTPUT after I input the two numbers, any idea what is wrong with my program?
START: lea array1,A0 for D2 = #0 to #1 do.s lea prompt,A1 move.b #13,D0 trap #15 move.b #4,D0 trap #15 move.l D1,(A0,D2) endf lea result,A1 move.b #13,D0 trap #15 for D2 = #0 to #2 do.s move.l (A0,D2),D1 move.b #3,D0 trap #15 lea crlf,A1 move.b #14,D0 trap #15 endf MOVE.B #9,D0 TRAP #15 array1 ds.l 2 2 prompt dc.b 'Enter the number: ',0 result dc.b 'The entered numbers are: ',0 crlf dc.b $d,$a,0 END START
Explanation / Answer
ORG $1000
START: ; first instruction of program
LEA MESSAGE1,A1 *Loads message into address register A1
MOVE.B #14,D0 *Moves number 14 into data regiter D0
TRAP #15 *Displays Message
string move.b #5,d0
trap #15
cmp.l #0,d1
beq print
move.b d1,(a6)+
bra string
LEA MESSAGE2,A1 *Loads message into address register A1
MOVE.B #14,D0 *Moves number 14 into data regiter D0
TRAP #15 *Displays Message
print
move.b (a6)+,d1
move.b #4,d0
trap #15
cmp.l #0,d1
bra print
MOVE.B #9,D0
TRAP #15 ; halt simulator
message1 dc.b 'enter your string: ',0
message2 dc.b 'string you hav entered is: ',0
cr dc.b 0
END START ; last line of source
example 2:
==========
ORG $1000
START: ; first instruction of program
LEA MESSAGE1,A1 *Loads message into address register A1
MOVE.B #14,D0 *Moves number 14 into data regiter D0
TRAP #15 *Displays Message
LEA BUFFER,A1 ; Where to store input string
MOVE.B #2,D0 ; Read string
TRAP #15
LEA MESSAGE2,A1 *Loads message into address register A1
MOVE.B #14,D0 *Moves number 14 into data regiter D0
TRAP #15 *Displays Message
LEA BUFFER,A1 ; String to display
MOVE.B #13,D0 ; Display string with newline
TRAP #15
MOVE.B #9,D0
TRAP #15 ; halt simulator
message1 dc.b 'enter your string: ',0
message2 dc.b 'string you have entered is: ',0
ds.w 0 ; force even address
buffer ds.b 80 ; input string storage
END START ; last line of source
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.