i have an issue converting a C code to MARIE assembly language.. actually i have homework due this friday.. i tried to solve the problem ( i should write a MARIE program) but i couldn't so i started writing it in C here it is:
enter code heredo {
enter code herescanf("%d",&num); enter code hereif (num <0) enter code herebreak ;
enter code herecount++; enter code heresum+=num;
enter code hereif(num>large)
enter code herelarge=num; enter code here}while (num>0);
enter code hereprintf("%d\n",count); enter code hereprintf("%d\n",sum); enter code hereprintf("%d\n",large); ` the problem is obvious i should ask the user to enter a positive number(loop) once he hit a negative number the program must ends and calculate three things: 1- how many numbers he entered( excluding the negative one). 2- sum of all numbers. 3- largest number.
all i know about MARIE is how the commands work( input,output,skipcond...,halt,store,load..etc) please help me i'm really desperately lost ..i appreciate any help in this here is what i came up with::
enter code hereloop, input enter code herestore num enter code hereskipcond 800 enter code herejump loop
enter code herecount, output enter code heresum , output enter code herelargest , output enter code herehalt enter code herenum , dec 0 enter code herecount , dec 0 enter code heresum , dec 0
thanks!
Aucun commentaire:
Enregistrer un commentaire