   little asm question on functions...
  Hi, im trying to write a function in asm that write a line of code to the screen, it work well but im not sure if i can make it better. Here's the code i have so far:; ==============================================; Function to print some text on screen; ==============================================PrintText:pushamov cx, 0001h ; ???ShowNextCharJmp:mov al, cs:[si]    ; move the character to display into axinc si   ; inc si (the current char. index)or al, al; Test if this is a null characterjz AllCharsDisplayedJmp ; Are we done?xor bx, bx    ; Erase bxmov ah, 0Eh   ; "Teletype output" mode...int 10h  ;jmp ShowNextCharJmp; Jump for another characterAllCharsDisplayedJmp:   ; return to callerpoparetThen to call it i use this(and this is the part that annoy me):push si  ; Save simov si, OFFSET Disk1Msg ; Move our string buffer offset into sicall PrintText; Show the message, pop back sipop si   ; Restore siIs there anyway i can pass Disk1Msg without using the push/mov/pop si ???I though about that:; ==============================================; Function to print some text on screen; ==============================================PrintText:push bpmov bp, sppushamov si, [bp+4]; Take the buffer address value from the stackmov cx, 0001h ; ???ShowNextCharJmp:mov AL, CS:[SI]    ; move the character to display into axinc SI   ; inc si (the current char. index)or AL, AL; Test if this is a null characterjz AllCharsDisplayedJmp ; Are we done?xor bx, bx    ; Erase bxmov AH, 0Eh   ; "Teletype output" mode...int 10h  ;jmp ShowNextCharJmp; Jump for another characterAllCharsDisplayedJmp:   ; return to callerpopapop bpret...push OFFSET Disk1Msgcall PrintText; Show the message, pop back si;missing pop here... how can i pop this value from the function above? Maybe im taking this the wrong way... or maybe i should stick with the 1st version? im so confuse...I was also wondering how to return a value in assembly.Any help appreciated.   
  Your first example looks fine. That's how to do it; take a look here: http://en.wikipedia.org/wiki/Calling_conventionGenerally, the memory layout is this for a function:- last argument- ...- first argument- return address- local variables- ...Return address is a pointer to the code segment of what it was previously executing. You could 'pop' one less in your function and let the 'last argument' (eg. lowest on the stack, highest on the list above) be the return value. Then make sure to pop it after you called a function.Generally functions pop the parameters they get themselves. But there's many variations, the convention you use is particularly important when you want to call external functions fro the compiler for example.This will help: http://www.delorie.com/djgpp/doc/ug/asm/calling.html