Answered Essay: Hi, below is my code that was written in IDE68K using C. So it coverted m

Hi, below is my code that was written in IDE68K using C. So it coverted my code to asm file(assembly) but my code is jumbled up. Can any fix it. It has no errors but it doesn’t display anything. The program is a basic calculator which adds, subtracts,divide, and division. The line that has semi colon in front of it is commented out.

; C:IDE68KEXAMPLESCALC.C – Compiled by CC68K Version 5.00 (c) 1991-2005 Peter J. Fondse
; #define ACIAC 0x8001
; #define ACIAD 0x8003
; #define RDRF 1
; #define TDRE 2
; #define MSG0 “Single Digit Result Additionnr”
; #define MSG1 “Enter First Number: ”
; #define MSG2 “Enter Second Number: ”
; #define MSG3 “Please choose a valid option(1-5)”
; #define MSG4 “Goodbye!”
; #define CR 0x0D
; #define LF 0x0A
; #define Menu “Please choose an option ”
; #define Menu2 “1: Add, 2: Subtract, 3: Multiply, 4: Divide 5:Exit ”
; //Protocols
; unsigned char getchar(void);
; void sendchar(unsigned char c);
; void sendmsg(unsigned int msga);
; void newline(void);
; void main()
; {

_main:
movem.l D2/D3/D4/D5/D6/D7/A2/A3/A4,-(A7)
lea _newline.L,A2
lea _sendchar.L,A3
trap #15
* lea _getchar.L,A4
; unsigned char result;
; unsigned char test = 1;
moveq #1,D7
; unsigned char options;
; unsigned char x,y,z;
; while(test == 1)
main_1:
cmp.b #1,D7
bne main_3
; {
; sendmsg(&Menu2);
* pea calc_1
jsr _sendmsg
addq.w #4,A7
; options = getchar()-48;
jsr (A4)
sub.b #48,D0
move.b D0,D6
; if (options == 1)
cmp.b #1,D6
bne main_4
; {
newline
jsr (A2)
; x =getchar();
jsr (A4)
move.b D0,D3
sendchar
and.l #255,D3
move.l D3,-(A7)
jsr (A3)
addq.w #4,A7
jsr (A2)
trap #15
; y = getchar();
jsr (A4)
move.b D0,D2
trap #15
; sendchar(y);
and.l #255,D2
move.l D2,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; x=x-48;
sub.b #48,D3
; y=y-48;
sub.b #48,D2
; z = x+y;
move.b D3,D0
add.b D2,D0
move.b D0,D5
trap #15
; result = z +48;
move.b D5,D0
add.b #48,D0
move.b D0,D4
trap #15
; newline();
jsr (A2)
; sendchar(result);
and.l #255,D4
move.l D4,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
bra main_12
main_4:
; }
; else if (options == 2)
cmp.b #2,D6
bne main_6
; {
; newline();
jsr (A2)
; x =getchar();
jsr (A4)
move.b D0,D3
trap #15
; sendchar(x);
and.l #255,D3
move.l D3,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
; y = getchar();
jsr (A4)
move.b D0,D2
trap #15
; sendchar(y);
and.l #255,D2
move.l D2,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; x=x-48;
sub.b #48,D3
; y=y-48;
sub.b #48,D2
; z = x-y;
move.b D3,D0
sub.b D2,D0
move.b D0,D5
; result = z + 48;
move.b D5,D0
add.b #48,D0
move.b D0,D4
trap #15
; newline();
jsr (A2)
; sendchar(result);
and.l #255,D4
move.l D4,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
bra main_12
main_6:
; }
; else if (options == 3)
cmp.b #3,D6
bne main_8
; {
; newline();
jsr (A2)
; x =getchar();
jsr (A4)
move.b D0,D3
trap #15
; sendchar(x);
and.l #255,D3
move.l D3,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
; y = getchar();
jsr (A4)
move.b D0,D2
trap #15
; sendchar(y);
and.l #255,D2
move.l D2,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; x=x-48;
sub.b #48,D3
; y=y-48;
sub.b #48,D2
; z = x*y;
move.b D3,D0
and.w #255,D0
and.w #255,D2
mulu.w D2,D0
move.b D0,D5
; result = z + 48;
move.b D5,D0
add.b #48,D0
move.b D0,D4
trap #15
; newline();
jsr (A2)
; sendchar(result);
and.l #255,D4
move.l D4,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
bra main_12
main_8:
; }
; else if (options == 4)
cmp.b #4,D6
bne main_10
; {
; newline();
jsr (A2)
; x =getchar();
jsr (A4)
move.b D0,D3
trap #15
; sendchar(x);
and.l #255,D3
move.l D3,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
; y = getchar();
jsr (A4)
move.b D0,D2
; sendchar(y);
and.l #255,D2
move.l D2,-(A7)
jsr (A3)
addq.w #4,A7
; x=x-48;
sub.b #48,D3
; y=y-48;
sub.b #48,D2
; z = x/y;
move.b D3,D0
and.l #65535,D0
divu.w D2,D0
move.b D0,D5
; result = z+48;
move.b D5,D0
add.b #48,D0
move.b D0,D4
; newline();
jsr (A2)
; sendchar(result);
and.l #255,D4
move.l D4,-(A7)
jsr (A3)
addq.w #4,A7
; newline();
jsr (A2)
bra.s main_12
main_10:
; }
; else if(options == 5)
cmp.b #5,D6
bne.s main_12
; {
; test = 0;
moveq #0,D7
main_12:
bra main_1
main_3:
; }
; }
; sendmsg(&MSG4);
*pea @calc_2.L
jsr _sendmsg
addq.w #4,A7
; newline();
jsr (A2)
movem.l (A7)+,D2/D3/D4/D5/D6/D7/A2/A3/A4
rts
; }
; //Subroutine to get a character typed into Hyperterminal
; unsigned char getchar()
; {trap #15:
link A6,#-8
move.l D2,-(A7)
; unsigned char temp = 0;
clr.b D2
; unsigned char * const C = (unsigned char *) ACIAC;
move.l #32769,-8(A6)
; unsigned char * const D = (unsigned char *) ACIAD;
move.l #32771,-4(A6)
; while (temp == 0) {temp = *C & RDRF;}
getchar_1:
tst.b D2
bne.s getchar_3
move.l -8(A6),A0
move.b (A0),D0
and.b #1,D0
move.b D0,D2
bra getchar_1
getchar_3:
; temp = *D;
move.l -4(A6),A0
move.b (A0),D2
; return temp;
move.b D2,D0
move.l (A7)+,D2
unlk A6
rts
; }
; //Subroutine to send a character to Hyperterminal
; void sendchar(unsigned char asciiout)
; {
_sendchar
_sendchar:
link A6,#-4
movem.l D2/D3/D4,-(A7)
; unsigned char temp = 0;
clr.b D2
; unsigned char dummyread = 0;
clr.b -1(A6)
; unsigned char * const C = (unsigned char *) ACIAC;
move.l #32769,D3
; unsigned char * const D = (unsigned char *) ACIAD;
move.l #32771,D4
; temp = *C & RDRF;
move.l D3,A0
move.b (A0),D0
and.b #1,D0
move.b D0,D2
; while (temp != 0)
sendchar_1:
tst.b D2
beq.s sendchar_3
; {
; dummyread = *D;
move.l D4,A0
move.b (A0),-1(A6)
; temp = *C & RDRF;
move.l D3,A0
move.b (A0),D0
and.b #1,D0
move.b D0,D2
bra sendchar_1
sendchar_3:
; }
; while (temp == 0) {temp = *C & TDRE;}
sendchar_4:
tst.b D2
bne.s sendchar_6
move.l D3,A0
move.b (A0),D0
and.b #2,D0
move.b D0,D2
bra sendchar_4
sendchar_6:
; *D = asciiout;
move.l D4,A0
move.b 11(A6),(A0)
movem.l (A7)+,D2/D3/D4
unlk A6
rts
; }
; //Subroutine to send a message string to Hyperterminal
; void sendmsg(unsigned int msg)
; {
_sendmsg
_sendmsg:
link A6,#0
movem.l D2/D3,-(A7)
; unsigned char * strptr = (unsigned char *) msg;
move.l 8(A6),D3
; unsigned char ASCII = *strptr;
move.l D3,A0
move.b (A0),D2
; while (ASCII != 0)
sendmsg_1:
tst.b D2
beq.s sendmsg_3
; {
; sendchar(ASCII);
and.l #255,D2
move.l D2,-(A7)
jsr _sendchar
addq.w #4,A7
; strptr = strptr + 1;
addq.l #1,D3
; ASCII = *strptr;
move.l D3,A0
move.b (A0),D2
bra sendmsg_1
sendmsg_3:
movem.l (A7)+,D2/D3
unlk A6
rts
; }
; }
; //Subroutine to start a new line in Hyperterminal
; void newline()
;

_newline
_newline:
; sendchar(LF);
pea 10
jsr _sendchar
addq.w #4,A7
trap #15
pea 13
jsr _sendchar
addq.w #4,A7
rts
; }section const

dc.b 49,58,32,65,100,100,44,32,50,58,32,83,117,98
dc.b 116,114,97,99,116,44,32,51,58,32,77,117,108
dc.b 116,105,112,108,121,44,32,52,58,32,68,105,118
dc.b 105,100,101,32,53,58,69,120,105,116,32,0
dc.b 71,111,111,100,98,121,101,33,0

Expert Answer

 

#define ACIAC 0x8001
; #define ACIAD 0x8003
; #define RDRF 1
; #define TDRE 2
; #define MSG0 “Single Digit Result Additionnr”
; #define MSG1 “Enter First Number: ”
; #define MSG2 “Enter Second Number: ”
; #define MSG3 “Please choose a valid option(1-5)”
; #define MSG4 “Goodbye!”
; #define CR 0x0D
; #define LF 0x0A
; #define Menu “Please choose an option ”
; #define Menu2 “1: Add, 2: Subtract, 3: Multiply, 4: Divide 5:Exit ”
; //Protocols
; unsigned char getchar(void);
; void sendchar(unsigned char c);
; void sendmsg(unsigned int msga);
; void newline(void);
; void main()
; {

_main:
movem.l D2/D3/D4/D5/D6/D7/A2/A3/A4,-(A7)
lea _newline.L,A2
lea _sendchar.L,A3
trap #15
* lea _getchar.L,A4
; unsigned char result;
; unsigned char test = 1;
moveq #1,D7
; unsigned char options;
; unsigned char x,y,z;
; while(test == 1)
main_1:
cmp.b #1,D7
bne main_3
; {
; sendmsg(&Menu2);
* pea calc_1
jsr _sendmsg
addq.w #4,A7
; options = getchar()-48;
jsr (A4)
sub.b #48,D0
move.b D0,D6
; if (options == 1)
cmp.b #1,D6
bne main_4
; {
newline
jsr (A2)
; x =getchar();
jsr (A4)
move.b D0,D3
sendchar
and.l #255,D3
move.l D3,-(A7)
jsr (A3)
addq.w #4,A7
jsr (A2)
trap #15
; y = getchar();
jsr (A4)
move.b D0,D2
trap #15
; sendchar(y);
and.l #255,D2
move.l D2,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; x=x-48;
sub.b #48,D3
; y=y-48;
sub.b #48,D2
; z = x+y;
move.b D3,D0
add.b D2,D0
move.b D0,D5
trap #15
; result = z +48;
move.b D5,D0
add.b #48,D0
move.b D0,D4
trap #15
; newline();
jsr (A2)
; sendchar(result);
and.l #255,D4
move.l D4,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
bra main_12
main_4:
; }
; else if (options == 2)
cmp.b #2,D6
bne main_6
; {
; newline();
jsr (A2)
; x =getchar();
jsr (A4)
move.b D0,D3
trap #15
; sendchar(x);
and.l #255,D3
move.l D3,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
; y = getchar();
jsr (A4)
move.b D0,D2
trap #15
; sendchar(y);
and.l #255,D2
move.l D2,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; x=x-48;
sub.b #48,D3
; y=y-48;
sub.b #48,D2
; z = x-y;
move.b D3,D0
sub.b D2,D0
move.b D0,D5
; result = z + 48;
move.b D5,D0
add.b #48,D0
move.b D0,D4
trap #15
; newline();
jsr (A2)
; sendchar(result);
and.l #255,D4
move.l D4,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
bra main_12
main_6:
; }
; else if (options == 3)
cmp.b #3,D6
bne main_8
; {
; newline();
jsr (A2)
; x =getchar();
jsr (A4)
move.b D0,D3
trap #15
; sendchar(x);
and.l #255,D3
move.l D3,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
; y = getchar();
jsr (A4)
move.b D0,D2
trap #15
; sendchar(y);
and.l #255,D2
move.l D2,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; x=x-48;
sub.b #48,D3
; y=y-48;
sub.b #48,D2
; z = x*y;
move.b D3,D0
and.w #255,D0
and.w #255,D2
mulu.w D2,D0
move.b D0,D5
; result = z + 48;
move.b D5,D0
add.b #48,D0
move.b D0,D4
trap #15
; newline();
jsr (A2)
; sendchar(result);
and.l #255,D4
move.l D4,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
bra main_12
main_8:
; }
; else if (options == 4)
cmp.b #4,D6
bne main_10
; {
; newline();
jsr (A2)
; x =getchar();
jsr (A4)
move.b D0,D3
trap #15
; sendchar(x);
and.l #255,D3
move.l D3,-(A7)
jsr (A3)
addq.w #4,A7
trap #15
; newline();
jsr (A2)
; y = getchar();
jsr (A4)
move.b D0,D2
; sendchar(y);
and.l #255,D2
move.l D2,-(A7)
jsr (A3)
addq.w #4,A7
; x=x-48;
sub.b #48,D3
; y=y-48;
sub.b #48,D2
; z = x/y;
move.b D3,D0
and.l #65535,D0
divu.w D2,D0
move.b D0,D5
; result = z+48;
move.b D5,D0
add.b #48,D0
move.b D0,D4
; newline();
jsr (A2)
; sendchar(result);
and.l #255,D4
move.l D4,-(A7)
jsr (A3)
addq.w #4,A7
; newline();
jsr (A2)
bra.s main_12
main_10:
; }
; else if(options == 5)
cmp.b #5,D6
bne.s main_12
; {
; test = 0;
moveq #0,D7
main_12:
bra main_1
main_3:
; }
; }
; sendmsg(&MSG4);
*pea @calc_2.L
jsr _sendmsg
addq.w #4,A7
; newline();
jsr (A2)
movem.l (A7)+,D2/D3/D4/D5/D6/D7/A2/A3/A4
rts
; }
; //Subroutine to get a character typed into Hyperterminal
; unsigned char getchar()
; {trap #15:
link A6,#-8
move.l D2,-(A7)
; unsigned char temp = 0;
clr.b D2
; unsigned char * const C = (unsigned char *) ACIAC;
move.l #32769,-8(A6)
; unsigned char * const D = (unsigned char *) ACIAD;
move.l #32771,-4(A6)
; while (temp == 0) {temp = *C & RDRF;}
getchar_1:
tst.b D2
bne.s getchar_3
move.l -8(A6),A0
move.b (A0),D0
and.b #1,D0
move.b D0,D2
bra getchar_1
getchar_3:
; temp = *D;
move.l -4(A6),A0
move.b (A0),D2
; return temp;
move.b D2,D0
move.l (A7)+,D2
unlk A6
rts
; }
; //Subroutine to send a character to Hyperterminal
; void sendchar(unsigned char asciiout)
; {
_sendchar
_sendchar:
link A6,#-4
movem.l D2/D3/D4,-(A7)
; unsigned char temp = 0;
clr.b D2
; unsigned char dummyread = 0;
clr.b -1(A6)
; unsigned char * const C = (unsigned char *) ACIAC;
move.l #32769,D3
; unsigned char * const D = (unsigned char *) ACIAD;
move.l #32771,D4
; temp = *C & RDRF;
move.l D3,A0
move.b (A0),D0
and.b #1,D0
move.b D0,D2
; while (temp != 0)
sendchar_1:
tst.b D2
beq.s sendchar_3
; {
; dummyread = *D;
move.l D4,A0
move.b (A0),-1(A6)
; temp = *C & RDRF;
move.l D3,A0
move.b (A0),D0
and.b #1,D0
move.b D0,D2
bra sendchar_1
sendchar_3:
; }
; while (temp == 0) {temp = *C & TDRE;}
sendchar_4:
tst.b D2
bne.s sendchar_6
move.l D3,A0
move.b (A0),D0
and.b #2,D0
move.b D0,D2
bra sendchar_4
sendchar_6:
; *D = asciiout;
move.l D4,A0
move.b 11(A6),(A0)
movem.l (A7)+,D2/D3/D4
unlk A6
rts
; }
; //Subroutine to send a message string to Hyperterminal
; void sendmsg(unsigned int msg)
; {
_sendmsg
_sendmsg:
link A6,#0
movem.l D2/D3,-(A7)
; unsigned char * strptr = (unsigned char *) msg;
move.l 8(A6),D3
; unsigned char ASCII = *strptr;
move.l D3,A0
move.b (A0),D2
; while (ASCII != 0)
sendmsg_1:
tst.b D2
beq.s sendmsg_3
; {
; sendchar(ASCII);
and.l #255,D2
move.l D2,-(A7)
jsr _sendchar
addq.w #4,A7
; strptr = strptr + 1;
addq.l #1,D3
; ASCII = *strptr;
move.l D3,A0
move.b (A0),D2
bra sendmsg_1
sendmsg_3:
movem.l (A7)+,D2/D3
unlk A6
rts
; }
; }
; //Subroutine to start a new line in Hyperterminal
; void newline()
;

_newline
_newline:
; sendchar(LF);
pea 10
jsr _sendchar
addq.w #4,A7
trap #15
pea 13
jsr _sendchar
addq.w #4,A7
rts
; }section const

dc.b 49,58,32,65,100,100,44,32,50,58,32,83,117,98
dc.b 116,114,97,99,116,44,32,51,58,32,77,117,108
dc.b 116,105,112,108,121,44,32,52,58,32,68,105,118
dc.b 105,100,101,32,53,58,69,120,105,116,32,0
dc.b 71,111,111,100,98,121,101,33,0

Buy Essay
Calculate your paper price
Pages (550 words)
Approximate price: -

Help Me Write My Essay - Reasons:

Best Online Essay Writing Service

We strive to give our customers the best online essay writing experience. We Make sure essays are submitted on time and all the instructions are followed.

Our Writers are Experienced and Professional

Our essay writing service is founded on professional writers who are on stand by to help you any time.

Free Revision Fo all Essays

Sometimes you may require our writers to add on a point to make your essay as customised as possible, we will give you unlimited times to do this. And we will do it for free.

Timely Essay(s)

We understand the frustrations that comes with late essays and our writers are extra careful to not violate this term. Our support team is always engauging our writers to help you have your essay ahead of time.

Customised Essays &100% Confidential

Our Online writing Service has zero torelance for plagiarised papers. We have plagiarism checking tool that generate plagiarism reports just to make sure you are satisfied.

24/7 Customer Support

Our agents are ready to help you around the clock. Please feel free to reach out and enquire about anything.

Try it now!

Calculate the price of your order

Total price:
$0.00

How it works?

Follow these simple steps to get your paper done

Place your order

Fill in the order form and provide all details of your assignment.

Proceed with the payment

Choose the payment system that suits you most.

Receive the final file

Once your paper is ready, we will email it to you.

HOW OUR ONLINE ESSAY WRITING SERVICE WORKS

Let us write that nagging essay.

STEP 1

Submit Your Essay/Homework Instructions

By clicking on the "PLACE ORDER" button, tell us your requires. Be precise for an accurate customised essay. You may also upload any reading materials where applicable.

STEP 2

Pick A & Writer

Our ordering form will provide you with a list of writers and their feedbacks. At step 2, its time select a writer. Our online agents are on stand by to help you just in case.

STEP 3

Editing (OUR PART)

At this stage, our editor will go through your essay and make sure your writer did meet all the instructions.

STEP 4

Receive your Paper

After Editing, your paper will be sent to you via email.

× How can I help you?