-3

This assembly code takes an input, multiplies it by 35,and leaves result in the register. It's 17 bytes of memory, but how do I calculate that?

deci M,d

ldwa M,d

asla ;2m

asla ;4m

asla ;8m

asla ; 16m

adda M,d ; 17m

asla ; 34m

adda M,d ; 35m

2 Answers2

0

Every assembler I have ever seen has the ability to generate a listing that shows the how it allocates memory.

user3344003
  • 20,574
  • 3
  • 26
  • 62
0

Your question is not clear. You are probably have started learning assembly language and it can be confusing. Don't worry just go through couple of examples and you will learn it. You first declare a variable, perform all needed function and then store the variable, and you clearly are not doing it. btw you are using the accumulator and not x register.

asla, adda, etc. the a in adda stands for accumulator. if it were addx it would have been xregister.

anyway if you are asking how to know how much memory you gonna need just search and see how much memory decimals etc need and declare your variables accordingly or you can use the stack and heaps.

xGeo
  • 2,149
  • 2
  • 18
  • 39
  • I think the question is just asking how many code bytes the posted code assembles to. – Peter Cordes Oct 06 '17 at 20:02
  • What's the difference between the accumulator and xregister? They seem to be interchangeable and I've seen both used. – Snuggly Patch Nov 15 '17 at 04:09
  • they are almost identical. I think they have a tiny difference but I cant remember what. Generally speaking you need to registers to be able create indexes(lists, arrays etc) that's why we got two in pep. In other assembly languages there are more registers. For instance there are like 15 registers in arm which enable us to do programs without saving data in variables which makes the programs shorter. – Շի րակ Nov 16 '17 at 07:02