assembly - How to spot MARIE errors? -
after assembling current file in marie. if i'm prompted error, how can spot line error directed at?
also i'm working on assignment requires me input length , width user , output perimeter or area. far here have :
org 100
input length //take input length
store length //store length in location length1
output length //show value of length
input width //take input width
store width //store location width
output width //show input width
load width
subt width 1 //(subtract 1 w until 0)
store width
load a
add length // add l area
store a
skipcond 00d //(skip when width hits 0)
jump 007 //
output area
halt
a, dec 0
b, dec 0
c, dec 0
end
i wrote in java make more clear understand
//find either perimeter or area of rectangle import java.util.scanner; public class perimeterorarea{ public static void main(string[] args){ int length, width; int perimeter, area; string ch; char character; scanner in = new scanner(system.in); system.out.println("please enter length of rectangle: "); length = in.nextint(); system.out.println("please enter width of rectangle: "); width = in.nextint(); area = length*width; perimeter = 2*(length + width); system.out.println("please enter p find perimeter of rectangle or find area of rectangle"); ch = in.next(); character = ch.charat(0); if(character == 'p') system.out.println("the value of perimeter : " + perimeter); if(character == 'a') system.out.println("the value of area : " + area); } }
6 errors persist in marie code. please help.
when assemble file, there should error message @ bottom of editor if exist. if so, open assembly listing , line has current error displayed on line error at. not give specific number if read through it, mark errors are.
as errors, specify width variable @ top not define @ bottom. since you're loading them input, set 0 did a, b, , c.
also, when inputting/outputting, not need specify variable. "input" "store width." output prints ac, must load whichever variable need, "output."
Comments
Post a Comment