{"id":5552,"date":"2014-03-31T01:39:49","date_gmt":"2014-03-31T01:39:49","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2014\/03\/31\/is-there-a-way-to-define-parametrized-variables-with-dup-in-x86-assembly-collection-of-common-programming-errors\/"},"modified":"2014-03-31T01:39:49","modified_gmt":"2014-03-31T01:39:49","slug":"is-there-a-way-to-define-parametrized-variables-with-dup-in-x86-assembly-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2014\/03\/31\/is-there-a-way-to-define-parametrized-variables-with-dup-in-x86-assembly-collection-of-common-programming-errors\/","title":{"rendered":"Is there a way to define parametrized variables with DUP in x86 assembly?-Collection of common programming errors"},"content":{"rendered":"<p>Using x86 assembly, I need to define an array filled with incrementing values. Currently, I define it as an empty array and fill it at runtime by looping through it and setting a value I increment on each step. This looks something like this;<\/p>\n<pre><code>myArray DB 10 DUP (0)\n...\nxor ax, ax\nxor bx, bx\nmov cx, 10\ninitArray:\n  mov myArray[bx], ax\n  inc bx\n  add ax, 43\nloop initArray\n<\/code><\/pre>\n<p>The increment value and the size of the array are both known before runtime, so I could do it by defining the values directly in the code, like this&#8230;<\/p>\n<pre><code>myArray DB 0, 43, 86, 129, ...\n<\/code><\/pre>\n<p>&#8230;but that would take a while, especially with long arrays.<\/p>\n<p>Now for the question; I was wondering if there&#8217;s a way to create such an array in assembly, like parametrized macros in C? An equivalent to &#8220;#define myArray(x) (x*43)&#8221; if you will.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Using x86 assembly, I need to define an array filled with incrementing values. Currently, I define it as an empty array and fill it at runtime by looping through it and setting a value I increment on each step. This looks something like this; myArray DB 10 DUP (0) &#8230; xor ax, ax xor bx, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-5552","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5552","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=5552"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/5552\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=5552"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=5552"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=5552"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}