0

I'm new to assembler and has a task to write a program that creates pascal triangle, when i get a number N that indicates the depth of the triangle. the question defines to do that by a two-dimension array.

output for example:

1 0 0 0
1 1 0 0
1 2 1 0

etc.

I'm allowed to use only memory that's indicated in the question and use registers. my question is: how can i access the previous cells to calculte the current cell, without losing the current location?

Thank you very much!

  • 1
    If your items are sequential in memory, then (starting with the 3rd row) you can access `p-N` and `p-N-1` for the two elements to sum up (`p` is pointer to current item, scale offset by item size). – Jester Dec 02 '14 at 22:45
  • In order to access adress of "p-N", is should use adressing mode 67? and if so, how can i calculate the EA? using @(r7-r4-1), r1 doesn't work for me. – user3698757 Dec 03 '14 at 11:08
  • 1
    You will need to perform the subtraction separately into a scratch register. – Jester Dec 03 '14 at 13:03
  • x86 (and generic arch-independent indexing math) duplicate: [algorithm of addressing a triangle matrices memory using assembly](https://stackoverflow.com/q/49165711) – Peter Cordes Jul 01 '18 at 02:44

0 Answers0