How to call a procedure and print it?

Viewed 44

Hello before everthing I am new to assembly and trying to understand it. I have a procedure for tasm and I'm trying to make a system call and print a output from this procedure but i can't find how to make a system call.

    .MODEL small   
        .DATA
        ;The string to be printed  
        STRING DB '047119047', '$'



        .CODE

;   Purpose:
;       Calculates the check digit for a ten digit ISBN, converts that
;       digit to its ASCII representation and returns that answer.
;
;   Entry:
;
;      isbn = a nine digit ASCII string containing the ISBN
;             (with or without the check digit which is not used here)
;
;   Register usage within the routine:
;
;        AL = current ISBN digit
;        AH = sum of digits so far
;        BX = start pointer into ISBN for each outer loop
;        CX = digit counter (inner loop)
;        DX = start value for digit counter
;        SI = points to current ISBN digit
;
;   Exit:
;
;        AX = ASCII representation of calculated check digit
;
;   Trashed:
;       none
;
;***************************************************************************/


isbncheck proc C isbn:ptr byte
        push    bx
        push    cx
        push    dx
        push    si
        mov     bx,[isbn]               ;
        mov     dx,9                    ; number of digits in raw ISBN
        xor     ax,ax                   ; clear out our total
        cld                             ; count up
@@bigloop:                              ;
        mov     si,bx                   ; point to a digit in the ISBN
        mov     cx,dx                   ; get digit count in CX
@@AddEmUp:                              ;
        lodsb                           ; fetch digit into AL
        and     al,0fh                  ; convert from ASCII
        add     ah,al                   ; add it to our total in AH
        loop    @@AddEmUp               ; do all digits
        inc     bx                      ; and advance the digit pointer
        dec     dx                      ; now decrement digit count
        jnz     @@bigloop               ;   keep going if digits left
        mov     al,ah                   ; move sum into al
        xor     ah,ah                   ; clear out high half
        mov     cl,11                   ; we'll be doing a mod 11 operation
        div     cl                      ; ah = sum mod 11
        mov     al,ah                   ; move calculated check digit to AL
        xor     ah,ah                   ; clear out high half
        or      al,30h                  ; convert to ASCII digit
        cmp     al,3Ah                  ;
        jnz     NotTen                  ;
        mov     al,'X'                  ;
NotTen:                                 ;
        pop     si
        pop     dx
        pop     cx
        pop     bx
        ret                             ; return
isbncheck endp

        END

I hope you guys can help me.If my question is not clear please tell me.So i can explain it more clear.

1 Answers

I'm trying to make a system call and print a output from this procedure

;The string to be printed  
STRING DB '047119047', '$'

Since I can see that the string is '$' terminated, I'll show you how to do it in the DOS environment:

mov dx, offset STRING
mov ah, 09h             ; DOS.PrintString
int 21h

This will output those 9 digits (not including the '$' character that only served as a terminator) on the screen starting from where the cursor was. Hereafter the cursor will be beyond the last character.

Alternatively, you can use a loop. This would allow you to not have to use that '$' terminator (mandatory on function 09h):

    mov si, offset STRING
    mov dl, [si]
More:
    mov ah, 02h       ; DOS.PrintChar
    int 21h
    inc si
    mov dl, [si]
    cmp dl, '$'
    jne More
Related