Hi,
Hmmm ... very interesting , running with tcc -S i get
Code: Select all
ifndef ??version
?debug macro
endm
$comm macro name,dist,size,count
comm dist name:BYTE:count*size
endm
else
$comm macro name,dist,size,count
comm dist name[size]:BYTE:count
endm
endif
?debug S "main.c"
?debug C E9B6719E3A066D61696E2E63
?debug C E950719E3A11696E636C756465732F737464696E632E68
_TEXT segment byte public 'CODE'
_TEXT ends
DGROUP group _DATA,_BSS
assume cs:_TEXT,ds:DGROUP
_DATA segment word public 'DATA'
d@ label byte
d@w label word
_DATA ends
_BSS segment word public 'BSS'
b@ label byte
b@w label word
_BSS ends
_TEXT segment byte public 'CODE'
;
; void printString(char *ptr)
;
assume cs:_TEXT
_printString proc near
push bp
mov bp,sp
push si
;
; {
; int i;
; for(i=0;i<80;i++)
;
xor si,si
jmp short @1@146
@1@50:
;
; {
; if (ptr[i] != '\0')
;
mov bx,word ptr [bp+4]
cmp byte ptr [bx+si],0
je short @1@98
;
; {
; putc(ptr[i]);
;
mov bx,word ptr [bp+4]
mov al,byte ptr [bx+si]
cbw
push ax
call near ptr _putc
pop cx
;
; } else {
;
jmp short @1@122
@1@98:
;
; i = 80;
;
mov si,80
@1@122:
inc si
@1@146:
cmp si,80
jl short @1@50
;
; }
; }
; }
;
pop si
pop bp
ret
_printString endp
_TEXT ends
_DATA segment word public 'DATA'
db 104
db 101
db 108
db 108
db 111
db 0
_DATA ends
_TEXT segment byte public 'CODE'
;
; int main(void)
;
assume cs:_TEXT
_main proc near
push bp
mov bp,sp
sub sp,6
push ss
lea ax,word ptr [bp-6]
push ax
push ds
mov ax,offset DGROUP:d@+0
push ax
mov cx,6
call near ptr N_SCOPY@
;
; {
; /*Setting up a string this way (with the double quotes or
; array initialization will cause a linker error.*/
; char string[] = "hello";
;
; /*Setting up a string this way will work.*/
; /*char string[80];
; string[0] = 'h';
; string[1] = 'i';
; string[2] = '\0';*/
;
; /*Print a string.*/
; printString(string);
;
lea ax,word ptr [bp-6]
push ax
call near ptr _printString
pop cx
;
; pause();
;
call near ptr _pause
;
; return 0;
;
xor ax,ax
jmp short @2@50
@2@50:
;
; }
;
mov sp,bp
pop bp
ret
_main endp
?debug C E9
_TEXT ends
_DATA segment word public 'DATA'
s@ label byte
_DATA ends
_TEXT segment byte public 'CODE'
_TEXT ends
extrn _pause:near
extrn _putc:near
public _main
extrn N_SCOPY@:far
public _printString
end
Clearly N_SCOPY is a call generated by the compiler to some internal library function , not available in a kernel , I think there a is a compiler switch to make sure that no call to internal library functions happens, but I do not remember it now
., However use
Code: Select all
char *string = "Hello" ;
instead of
char string[] = "Hello";
for constant strings , this should fix the problem . I am a moron and I might be wrong , you may or may not take this seriously
Regards
Shrek