tutorial on all the things in the source

Started by xellos, October 12, 2009, 05:42:26 PM

Previous topic - Next topic

xellos

does anyone know an tut on most of the asm stuff not only the basics?

for example i got this program



        .model small

        .stack 512

        .data

NPrompt db 'Enter Your Name: ',24h
NHello  db 'Hello, ',24h
CrLf    db 0Dh,0Ah,24h
NBuffer db 127,0,128 dup(0)

        .code

_main   proc

;set the DS register

        mov     ax,@data          ;data segment
        mov     ds,ax

;display the prompt message

        mov     dx,offset NPrompt
        mov     ah,9
        int     21h

;read buffered input

        mov     dx,offset NBuffer
        mov     ah,0Ah
        int     21h

;display a carriage return/line feed

        mov     dx,offset CrLf
        mov     ah,9
        int     21h

;terminate the input string

        mov     bh,0
        mov     bl,NBuffer+1
        mov byte ptr NBuffer[bx+2],24h

;display the 'Hello' message

        mov     dx,offset NHello
        mov     ah,9
        int     21h

;display their input

        mov     dx,offset NBuffer+2
        mov     ah,9
        int     21h

;display a carriage return/line feed

        mov     dx,offset CrLf
        mov     ah,9
        int     21h

;terminate

        mov     ax,4C00h          ;terminate - exit code = 0
        INT     21h               ;DOS call

_main   endp

        end     _main



what does this line do?
mov byte ptr NBuffer[bx+2],24h

why is  the 24h?

most important of all i realy want to learn asm 16bit but cant find any good tuts

Neil

Instead of 24h you could use "$" (24h) which is the string terminator that tells the function displaying it that it has reached the end.
Are you sure you want to learn 16 bit asm? It doesn't have any place in todays computing, 32 bit is far superior & easier to progam with.

xellos

yes but can you make console procs with it?
and are there any tuts

dedndave

well - Neil is part right - lol
32-bit API is a lot more involved than DOS INT 21h
but, it is well worth the extra effort to learn it

        mov     bh,0
        mov     bl,NBuffer+1
        mov byte ptr NBuffer[bx+2],24h

DOS INT 21h, function 0Ah returns the length of the input string in the second byte of the buffer
we add that to the offset of the buffer, plus 2 more to skip over the size and length bytes, to find the end of the string
DOS INT 21h string output functions usually require a 24h terminator
as Neil said, it is the "$" character, also 36 decimal
in DOS, file names require a zero-byte terminator instead
in 32-bit code, the $ terminator was done away with and nearly all strings are terminated with a zero-byte

dedndave

hi xellos - i am not too sure about good 16-bit tutorials
i am sure there are many out there - just that i never bookmarked them - lol
one thing for sure, if you want to write 16-bit code, Ralf Brown's Interrupt List will be a big help...

http://www.cs.cmu.edu/~ralf/files.html