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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:07:03+00:00 2026-06-06T14:07:03+00:00

I have been attempting to debug my program, but it always seems to get

  • 0

I have been attempting to debug my program, but it always seems to get caught up when I call my function. I get an error saying

“Unhandled exception at 0x0018fed8 in windows32.exe: 0xC0000005:
Access violation.”

I tried researching and what I gathered is that it is a stack error. Is there any other possibilities?

    .586
.MODEL FLAT
INCLUDE io.h
.STACK 4096     

.DATA           ; reserve storage for data
number1         WORD        ?
anArray         WORD        100 DUP (?)
count           WORD        ?
search          WORD        ?
prompt1         BYTE        "Enter a number or -1 to quit.", 0
prompt2         BYTE        "Enter a number to search for", 0
prompt3         BYTE        "Search for another number Y/N",0
inString        BYTE        40 DUP (?)
searchString    BYTE        16 DUP (?)
outMsgLabel     BYTE        "Search Result", 0
frontOut1       BYTE        6 DUP (?)
outMsg1         BYTE        " is element"
rearOut1        BYTE        6 DUP (?),0
frontOut2       BYTE        6 DUP (?)
outMsg2         BYTE        " is not in array",0

EXTERN          function1:PROC

.CODE           ; start of main program code
_MainProc       PROC
                lea         ebx, anArray
                mov         cx, count
moveThrough:    input       prompt1, inString, 40   ; read ASCII characters
                atow        inString                ; convert to integer
                cmp         ax,0                    ; check for -1
                jl          next
                mov         [ebx], eax              ; store in memory
                add         ebx,2                   ; move to next location in array
                inc         ecx
                cmp         ecx,50                  ; check to make sure array isn't over 50
                je          next
                jmp         moveThrough             ; jump to add more numbers


next:           lea         ebx, anArray            ; get address of array
                mov         count, cx
                input       prompt2, inString, 40   ; prompt for number to search for
                atow        inString
                mov         dx,ax
                mov         cx,count                ; prep cx to be the counter
                lea         eax, anArray
                push        eax
                push        edx
                push        ecx
                call        function1
                add         esp,6
                cmp         eax,0
                je          notThere
                jmp         equalTo

notThere:       wtoa        frontOut2, search
                output      outMsgLabel,frontOut2   ; output message
                jmp         searchAgain

equalTo:        wtoa        frontOut1, search
                wtoa        rearOut1, ax
                output      outMsgLabel,frontOut1   ; output message
                mov         cx,count
                jmp         searchAgain



searchAgain:    input       prompt3, searchString, 16 ; prompt for search again input
                cmp         searchString,"n"          ; check for n
                je          end1
                cmp         searchString,"N"          ; check forN
                je          end1
                jmp         next

end1:


                mov         eax, 0                  ; exit with return code 0
                ret
_MainProc       ENDP
                END                                 ; end of source code

.586
.MODEL FLAT
.CODE

;void function1(int count, int search, int array[])
;outputs whether the search is in the array
function1       PROC
                push        ebp         
                mov         ebp,esp
                push        ebx
                push        ecx
                push        edx
                push        esi
                mov         ecx,[ebp]
                mov         edx,[ebp+2]
                mov         esi,[ebp+4]

arraySearch:    mov         ax, dx                      
                cmp         [esi],ax                ; check if number is in array
                je          equalTo                 
                add         ebx,2                   ; move to next number in array
                loop        arraySearch             ; loop back to top

notThere:       pop         esi
                pop         edx
                pop         ecx
                pop         ebx
                mov         ax,0
                ret

equalTo:        pop         esi
                pop         edx
                pop         ecx
                pop         ebx
                inc         cx
                mov         ax,cx
                ret

                ret
function1       ENDP

END
  • 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-06T14:07:05+00:00Added an answer on June 6, 2026 at 2:07 pm
    1. Why are you adding 6 to esp after your call to function1? This is 32bit Assembly and the stack is DWORD aligned, you pushed 3 32bit registers so you should be adding 12 to esp after your call to function1.

    2. In function1, you set up a stack frame with:

      push ebp

      mov ebp, esp

    Where do you pop ebp and restore the stack pointer? These 2 errors will mess your program up big time!

    Oh, and that being said, the parameters to your function start at [ebp + 8] and for each parameter add 4 to that offset.
    1st param = [ebp + 8]
    2nd = [ebp + 12]
    3rd = [ebp + 16]
    etc…

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

Sidebar

Related Questions

I have been attempting to get log4net logging any info or error into my
I have been attempting to get log4net logging in my asp.net web application with
I've been attempting to debug this all morning but can't seem to find the
I have been attempting to use an android.preference.DialogPreference inflated from XML, but the documentation
i have been attempting to pass an object into a function that belongs to
I have been attempting to write a program that will determine if a number
I have been attempting to get the MySQL Embedded Library working in my C#
I have been attempting to dive into RSpec 2 but its auto generated controller
I have been attempting to have a object that I can use across multiple
I have been attempting to enhance my GUI system written in Java to use

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.