Im trying to use printf in my assembley code in model large, and i get a fixup overflow, what do i need to change in this code to make it work?
.MODEL LARGE
.STACK 100h
.DATA
int DW "%d"
.CODE
.386
extrn _printf:far
PUBLIC _stack_protection
_stack_protection PROC FAR
push bp
mov bp,sp
push es
mov ax,10
push ax
push word ptr int
call _printf
add sp,4
pop es
pop bp
ret
_stack_protection ENDP
END
You need to change this:
to this:
Because
printf()expects normal, NUL-terminated C strings, because C strings consist of bytes, not words and becauseintis likely a reserved word (at least it is in TASM).You also need to change this:
to this:
Because in the large memory model all pointers are far, that is, consist of a segment and an offset.
So, this is what I end up with…
Asm file:
C file:
I then compile the program (with Turbo C++ 1.01 and TASM 3.2):
And run it: