Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8910431
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:41:18+00:00 2026-06-15T03:41:18+00:00

This is the code: section .data v dw 4, 6, 8, 12 len equ

  • 0

This is the code:

section .data
v dw 4, 6, 8, 12
len equ 4
section .text
    global main
main:
    mov eax, 0 ;this is i
    mov ebx, 0 ;this is j
cycle:
    cmp eax, 2 ;i < len/2
    jge exit
    mov ebx, 0
    jmp inner_cycle
continue:
    inc eax
    jmp cycle
inner_cycle:
    cmp ebx, 2
    jge continue
    mov di, [v + eax * 2 * 2 + ebx * 2]
    inc ebx
    jmp inner_cycle
exit:
    push dword 0
    mov eax, 0
    sub esp, 4
    int 0x80

I’m using an array and scanning it as a matrix, this is the C translation of the above code

int m[4] = {1,2,3,4};
for(i = 0; i < 2; i++){
    for(j = 0; j < 2; j++){
        printf("%d\n", m[i*2 + j]);
    }
}

When I try to compile the assembly code I get this error:

DoubleForMatrix.asm:20: error: beroset-p-592-invalid effective address

which refers to this line

mov di, [v + eax * 2 * 2 + ebx * 2]

can someone explain me what is wrong with this line? I think that it’s because of the register dimensions, I tried with

mov edi, [v + eax * 2 * 2 + ebx * 2]

but I’ve got the same error.

This is assembly for Mac OS X, to make it work on another SO you have to change the exit syscall.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T03:41:19+00:00Added an answer on June 15, 2026 at 3:41 am

    You can’t use arbitrary expressions in assembler. Only a few addressingmodes are allowed.

    basically the most complex form is register/imm+register*scale with scale 1,2,4,8

    Of course constants (like 2*2) will probably be folded to 4, so that counts as a single scale with 4 (not as two multiplications)

    Your example tries to do two multiplies at once.

    Solution: insert an extra LEA instruction to calculate v+ebx*2 and use the result in the mov.

         lea regx , [v+ebx*2]
         mov edi, [eax*2*2+regx]
    

    where regx is a free register.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this x86 assembly code: section .data foo: mov ebx, [boo] mov [goo], ebx
I have this code: section .data Foos: mov ecx,7 mov edx,5 L: inc edx
Using this code: $('#ipadmenu section').attr('data-order', hash) I am settings the data-order attribute to the
Using this syntax: var position = array($('#ipadmenu > section').attr('data-order')); I cannot get my code
I'm wondering why this code section prints out the following: print request.user.has_perm('bug_tracking.is_developer'): + str(request.user.has_perm('bug_tracking.is_developer'))
This is the code section from inno setup.My intention is to make two Checkbox
I have this view (DetailsContainer, first class in code section of this question) with
I'm getting a javascript error. It has to do with this section of code:
I have a jquerymobile app, that has this header code @section header { @Html.ActionLink(Cancelar,
i have this assembly code in the .text segment, is it possible that i

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.