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 8033671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T01:46:13+00:00 2026-06-05T01:46:13+00:00

I wonder how do I have to pass pointer argument to procedure? I have

  • 0

I wonder how do I have to pass pointer argument to procedure?

I have to create function who have 2 arguments:

  1. words array
  2. array’s size

The function gets array that the array’s size and sum the column.

That’s what I’ve coded:

.MODEL  Small
.STACK  64

; +===============================+
; |             DATA              |
; +===============================+

.DATA 
array1      dw  1,2,3,4
array1size  dw  4
result      dw  ?
address     dw  ?
; print
TMP     dw  0 ; general temporary variable ..
.code

addNumbers proc
;   reset result
    lea di,result
;   use stack
    mov bp,sp
;   get num array
    mov bx,[bp+2]
;   get num of numbers
    mov cx,[bp+4]
; making additiontion
adding:
    add [di],bx
    inc bx; go to the next bx
loop adding
    ret 2
endp

; start
start:
    mov ax,@DATA
    mov ds,ax
; set strings
    push array1size
    push offset array1
    call addNumbers
; print
    mov dx:ax,result
    call printNumber
    mov ah,4ch
    mov al,0
    int 21H
end start

the problem – it’s adding to result the offset pointer (here is cs:0000,cs:0001,cs:0002,cs:0003) and not the offset value (here is: 1,2,3,4).

Because of this, result will be 6 and not 10.

could someone help me?

  • 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-05T01:46:15+00:00Added an answer on June 5, 2026 at 1:46 am
    INC BX
    

    will of course add 1 (byte) to the pointer in BX. If you need to move one WORD, you have to add the size of the word. Say that is 2 bytes, then you need

    ADD BX, 2
    

    instead of the INC.

    Your other problem is that you don’t add the values pointed-to, [BX], but the pointers themselves BX. You might use a spare register, like AX to compute the sum.

        MOV  AX,0
    adding:
        ADD  AX,[BX]
        ADD  BX,2
        LOOP adding
        MOV  [result],AX
    
        RET  4
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I wonder how to create an application that would be capable to have only
For TDD you have to Create a test that fail Do the simplest thing
I wonder how to pass data back to AppDelegate. Let's say I have this
Say I have a tcl script and I want to pass some arguments to
§3.10 section 9 says non-class rvalues always have cv-unqualified types. That made me wonder...
I would like to pass some (dll or not) function pointers as arguments to
I've been using debug() more often now, but sometimes I wonder which functions have
I have a sample application and wonder if anyone can shine a light on
I have an APK for test and I wonder if is possible to know
I have drawn a rectangle with canvas and I wonder if there is any

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.