0

Trying to figure out how to properly call a subroutine that has multiple parameters, multiple times in x86 assembly. Any help is appreciated! Using the Irvine libraries for this one. The first portion of code is what I was attempting but it doesn't seem to work, at least not the way it should:

push OFFSET r1
push OFFSET c0
push OFFSET b0
push OFFSET a0
push 0
call quadratic ;(0,a0,b0,c0,r1)

and the second portion of code seems to be correct:

quadratic   PROC
; calculation of the roots of a parabola
; Receives from stack
;   flag = type of root (0=positive, 1=negative) [integer, value parameter]
;   a$, b$, c$ = parabola parameters [REAL reference parameters]
; Returns
;   Specified root [REAL8 reference parameter]
PARAMS  = 3*TYPE DWORD ; number of temporaries plus return address
FLAG = PARAMS+0
A$ = PARAMS+4
B$ = PARAMS+8
C$ = PARAMS+12
RESULT = PARAMS+16

If more of the code is needed to determine the proper way of calling the subroutine just let me know. Thanks again!

Jack
  • 1
  • 3
    You haven't shown us how you access the arguments inside the subroutine. – Michael Nov 01 '14 at 07:13
  • 1
    Which assembler do you use? In case of FASM take a look e.g. at http://stackoverflow.com/a/14641353/2626313 – xmojmr Nov 01 '14 at 07:18
  • 1
    Also 'it doesn't seem to work' - what? Does it crash inside the function, crash on return or return successfully but with incorrect result? – Martin James Nov 01 '14 at 08:38

1 Answers1

0

Apparently I was too tired last night when programming and didn't realize my test input was poorly selected. All is well with my code! Sorry for the inconvenience! For reference, this was MASM.

Jack
  • 1
  • In that case the question does not seem to be useful to anyone and should be deleted (by you) before it attracts negative votes – xmojmr Nov 03 '14 at 08:55