Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

code to input values to an array

hey ppl
i need the code,help to input values into an array, ne ideas how i do it
n how do print the aray as well?
thnx in advance
tyron

Comments

  • emu8086emu8086 Posts: 125Member
    [code]

    ; Coding by Alexander Popov, December 2002
    ; Compiled and checked on emu8086
    ; (8086 assembler and microprocessor emulator)
    ; http://www.geocities.com/emu8086/

    ; This sample just inputs 5 numbers into an array,
    ; and prints them out...

    #make_com#

    ORG 100h

    jmp start

    array dw 0,0,0,0,0
    size dw 5 ; array size

    start:

    ; get 5 values from the user:
    CALL PTHIS
    db "Enter 5 values", 13,10,0

    MOV AX, 0
    MOV BX, 0 ; array pointer
    next_num:

    CALL SCAN_NUM
    MOV array[BX], CX

    ; new line:
    PUTC 13
    PUTC 10

    ADD BX, 2 ; next word.
    INC AX
    CMP AX, size
    JB next_num

    ; print out all 5 values:

    CALL PTHIS
    db "You have entered:", 13,10,0

    MOV CX, size
    MOV BX, 0 ; array pointer
    next_prnt:

    MOV AX, array[BX]
    CALL PRINT_NUM

    ; make space:
    PUTC ' '

    ADD BX, 2 ; next word.
    LOOP next_prnt

    mov ah, 4ch
    int 21h


    ; Here is a procedure that
    ; gets the multi-digit SIGNED number from the keyboard,
    ; and stores the result in CX register:
    SCAN_NUM PROC NEAR
    PUSH DX
    PUSH AX
    PUSH SI

    MOV CX, 0

    ; reset flag:
    MOV CS:make_minus, 0

    next_digit:

    ; get char from keyboard
    ; into AL:
    MOV AH, 00h
    INT 16h
    ; and print it:
    MOV AH, 0Eh
    INT 10h

    ; check for MINUS:
    CMP AL, '-'
    JE set_minus

    ; check for ENTER key:
    CMP AL, 13 ; carriage return?
    JNE not_cr
    JMP stop_input
    not_cr:


    CMP AL, 8 ; 'BACKSPACE' pressed?
    JNE backspace_checked
    MOV DX, 0 ; remove last digit by
    MOV AX, CX ; division:
    DIV CS:ten ; AX = DX:AX / 10 (DX-rem).
    MOV CX, AX
    PUTC ' ' ; clear position.
    PUTC 8 ; backspace again.
    JMP next_digit
    backspace_checked:


    ; allow only digits:
    CMP AL, '0'
    JAE ok_AE_0
    JMP remove_not_digit
    ok_AE_0:
    CMP AL, '9'
    JBE ok_digit
    remove_not_digit:
    PUTC 8 ; backspace.
    PUTC ' ' ; clear last entered not digit.
    PUTC 8 ; backspace again.
    JMP next_digit ; wait for next input.
    ok_digit:


    ; multiply CX by 10 (first time the result is zero)
    PUSH AX
    MOV AX, CX
    MUL CS:ten ; DX:AX = AX*10
    MOV CX, AX
    POP AX

    ; check if the number is too big
    ; (result should be 16 bits)
    CMP DX, 0
    JNE too_big

    ; convert from ASCII code:
    SUB AL, 30h

    ; add AL to CX:
    MOV AH, 0
    MOV DX, CX ; backup, in case the result will be too big.
    ADD CX, AX
    JC too_big2 ; jump if the number is too big.

    JMP next_digit

    set_minus:
    MOV CS:make_minus, 1
    JMP next_digit

    too_big2:
    MOV CX, DX ; restore the backuped value before add.
    MOV DX, 0 ; DX was zero before backup!
    too_big:
    MOV AX, CX
    DIV CS:ten ; reverse last DX:AX = AX*10, make AX = DX:AX / 10
    MOV CX, AX
    PUTC 8 ; backspace.
    PUTC ' ' ; clear last entered digit.
    PUTC 8 ; backspace again.
    JMP next_digit ; wait for Enter/Backspace.


    stop_input:
    ; check flag:
    CMP CS:make_minus, 0
    JE not_minus
    NEG CX
    not_minus:

    POP SI
    POP AX
    POP DX
    RET
    make_minus DB ? ; used as a flag.
    ten DW 10 ; used as multiplier.
    SCAN_NUM ENDP

    ; this macro prints a
    ; char in AL and advances
    ; the current cursor
    ; position:
    PUTC MACRO char
    PUSH AX
    MOV AL, char
    MOV AH, 0Eh
    INT 10h
    POP AX
    ENDM

    ; a procedure that prints number in AX,
    ; used with PRINT_NUM_UNS to print signed numbers:
    PRINT_NUM_UNS PROC NEAR
    PUSH AX
    PUSH BX
    PUSH CX
    PUSH DX

    ; flag to prevent printing zeros before number:
    MOV CX, 1

    ; (result of "/ 10000" is always less or equal to 9).
    MOV BX, 10000 ; 2710h - divider.

    ; AX is zero?
    CMP AX, 0
    JZ print_zero

    begin_print:

    ; check divider (if zero go to end_print):
    CMP BX,0
    JZ end_print

    ; avoid printing zeros before number:
    CMP CX, 0
    JE calc
    ; if AX<BX then result of DIV will be zero:
    CMP AX, BX
    JB skip
    calc:
    MOV CX, 0 ; set flag.

    MOV DX, 0
    DIV BX ; AX = DX:AX / BX (DX=remainder).

    ; print last digit
    ; AH is always ZERO, so it's ignored
    ADD AL, 30h ; convert to ASCII code.
    PUTC AL


    MOV AX, DX ; get remainder from last div.

    skip:
    ; calculate BX=BX/10
    PUSH AX
    MOV DX, 0
    MOV AX, BX
    DIV CS:ten10 ; AX = DX:AX / 10 (DX=remainder).
    MOV BX, AX
    POP AX

    JMP begin_print

    print_zero:
    PUTC '0'

    end_print:

    POP DX
    POP CX
    POP BX
    POP AX
    RET
    ten10 DW 10 ; used as divider.
    PRINT_NUM_UNS ENDP


    ; a procedure that prints out an unsigned
    ; number in AX (not just a single digit)
    ; allowed values from 0 to 65535 (0FFFFh)
    PRINT_NUM PROC NEAR
    PUSH DX
    PUSH AX

    CMP AX, 0
    JNZ not_zero

    PUTC '0'
    JMP printed

    not_zero:
    ; the check SIGN of AX,
    ; make absolute if it's negative:
    CMP AX, 0
    JNS positive
    NEG AX

    PUTC '-'

    positive:
    CALL PRINT_NUM_UNS
    printed:
    POP AX
    POP DX
    RET
    PRINT_NUM ENDP


    ;***************************************************************
    ; This procedure is used to print a null terminated
    ; string at current cursor position.
    ; The ZERO TERMINATED string should be defined just after
    ; the CALL. For example:
    ;
    ; CALL PTHIS
    ; db 'Hello World!', 0
    ;
    ; Address of string is stored in the Stack as return address.
    ; Procedure updates value in the Stack to make return
    ; after string definition.
    PTHIS PROC NEAR

    MOV CS:temp1, SI ; re-store SI register.

    POP SI ; get return address (IP).

    PUSH AX ; store AX register.

    next_char:
    MOV AL, CS:[SI]
    INC SI ; next byte.
    CMP AL, 0
    JZ printedq
    MOV AH, 0Eh ; teletype function.
    INT 10h
    JMP next_char ; loop.
    printedq:

    POP AX ; re-store AX register.

    ; SI should point to next command after
    ; the CALL instruction and string definition:
    PUSH SI ; save new return address into the Stack.

    MOV SI, CS:temp1 ; re-store SI register.

    RET
    temp1 DW ? ; variable to store original value of SI register.
    PTHIS ENDP

    END

    ; Coding by Alexander Popov
    ; http://www.geocities.com/emu8086/

    [/code]

  • tyron123tyron123 Posts: 68Member
    thansk yo
    but i finished the program ages ago, with a little extra thinking from my side! :) thnx again!
    i wanted to delete this post, but i guess that was not possible so i had to leave it. thnx again!



    : [code]
    :
    : ; Coding by Alexander Popov, December 2002
    : ; Compiled and checked on emu8086
    : ; (8086 assembler and microprocessor emulator)
    : ; http://www.geocities.com/emu8086/
    :
    : ; This sample just inputs 5 numbers into an array,
    : ; and prints them out...
    :
    : #make_com#
    :
    : ORG 100h
    :
    : jmp start
    :
    : array dw 0,0,0,0,0
    : size dw 5 ; array size
    :
    : start:
    :
    : ; get 5 values from the user:
    : CALL PTHIS
    : db "Enter 5 values", 13,10,0
    :
    : MOV AX, 0
    : MOV BX, 0 ; array pointer
    : next_num:
    :
    : CALL SCAN_NUM
    : MOV array[BX], CX
    :
    : ; new line:
    : PUTC 13
    : PUTC 10
    :
    : ADD BX, 2 ; next word.
    : INC AX
    : CMP AX, size
    : JB next_num
    :
    : ; print out all 5 values:
    :
    : CALL PTHIS
    : db "You have entered:", 13,10,0
    :
    : MOV CX, size
    : MOV BX, 0 ; array pointer
    : next_prnt:
    :
    : MOV AX, array[BX]
    : CALL PRINT_NUM
    :
    : ; make space:
    : PUTC ' '
    :
    : ADD BX, 2 ; next word.
    : LOOP next_prnt
    :
    : mov ah, 4ch
    : int 21h
    :
    :
    : ; Here is a procedure that
    : ; gets the multi-digit SIGNED number from the keyboard,
    : ; and stores the result in CX register:
    : SCAN_NUM PROC NEAR
    : PUSH DX
    : PUSH AX
    : PUSH SI
    :
    : MOV CX, 0
    :
    : ; reset flag:
    : MOV CS:make_minus, 0
    :
    : next_digit:
    :
    : ; get char from keyboard
    : ; into AL:
    : MOV AH, 00h
    : INT 16h
    : ; and print it:
    : MOV AH, 0Eh
    : INT 10h
    :
    : ; check for MINUS:
    : CMP AL, '-'
    : JE set_minus
    :
    : ; check for ENTER key:
    : CMP AL, 13 ; carriage return?
    : JNE not_cr
    : JMP stop_input
    : not_cr:
    :
    :
    : CMP AL, 8 ; 'BACKSPACE' pressed?
    : JNE backspace_checked
    : MOV DX, 0 ; remove last digit by
    : MOV AX, CX ; division:
    : DIV CS:ten ; AX = DX:AX / 10 (DX-rem).
    : MOV CX, AX
    : PUTC ' ' ; clear position.
    : PUTC 8 ; backspace again.
    : JMP next_digit
    : backspace_checked:
    :
    :
    : ; allow only digits:
    : CMP AL, '0'
    : JAE ok_AE_0
    : JMP remove_not_digit
    : ok_AE_0:
    : CMP AL, '9'
    : JBE ok_digit
    : remove_not_digit:
    : PUTC 8 ; backspace.
    : PUTC ' ' ; clear last entered not digit.
    : PUTC 8 ; backspace again.
    : JMP next_digit ; wait for next input.
    : ok_digit:
    :
    :
    : ; multiply CX by 10 (first time the result is zero)
    : PUSH AX
    : MOV AX, CX
    : MUL CS:ten ; DX:AX = AX*10
    : MOV CX, AX
    : POP AX
    :
    : ; check if the number is too big
    : ; (result should be 16 bits)
    : CMP DX, 0
    : JNE too_big
    :
    : ; convert from ASCII code:
    : SUB AL, 30h
    :
    : ; add AL to CX:
    : MOV AH, 0
    : MOV DX, CX ; backup, in case the result will be too big.
    : ADD CX, AX
    : JC too_big2 ; jump if the number is too big.
    :
    : JMP next_digit
    :
    : set_minus:
    : MOV CS:make_minus, 1
    : JMP next_digit
    :
    : too_big2:
    : MOV CX, DX ; restore the backuped value before add.
    : MOV DX, 0 ; DX was zero before backup!
    : too_big:
    : MOV AX, CX
    : DIV CS:ten ; reverse last DX:AX = AX*10, make AX = DX:AX / 10
    : MOV CX, AX
    : PUTC 8 ; backspace.
    : PUTC ' ' ; clear last entered digit.
    : PUTC 8 ; backspace again.
    : JMP next_digit ; wait for Enter/Backspace.
    :
    :
    : stop_input:
    : ; check flag:
    : CMP CS:make_minus, 0
    : JE not_minus
    : NEG CX
    : not_minus:
    :
    : POP SI
    : POP AX
    : POP DX
    : RET
    : make_minus DB ? ; used as a flag.
    : ten DW 10 ; used as multiplier.
    : SCAN_NUM ENDP
    :
    : ; this macro prints a
    : ; char in AL and advances
    : ; the current cursor
    : ; position:
    : PUTC MACRO char
    : PUSH AX
    : MOV AL, char
    : MOV AH, 0Eh
    : INT 10h
    : POP AX
    : ENDM
    :
    : ; a procedure that prints number in AX,
    : ; used with PRINT_NUM_UNS to print signed numbers:
    : PRINT_NUM_UNS PROC NEAR
    : PUSH AX
    : PUSH BX
    : PUSH CX
    : PUSH DX
    :
    : ; flag to prevent printing zeros before number:
    : MOV CX, 1
    :
    : ; (result of "/ 10000" is always less or equal to 9).
    : MOV BX, 10000 ; 2710h - divider.
    :
    : ; AX is zero?
    : CMP AX, 0
    : JZ print_zero
    :
    : begin_print:
    :
    : ; check divider (if zero go to end_print):
    : CMP BX,0
    : JZ end_print
    :
    : ; avoid printing zeros before number:
    : CMP CX, 0
    : JE calc
    : ; if AX<BX then result of DIV will be zero:
    : CMP AX, BX
    : JB skip
    : calc:
    : MOV CX, 0 ; set flag.
    :
    : MOV DX, 0
    : DIV BX ; AX = DX:AX / BX (DX=remainder).
    :
    : ; print last digit
    : ; AH is always ZERO, so it's ignored
    : ADD AL, 30h ; convert to ASCII code.
    : PUTC AL
    :
    :
    : MOV AX, DX ; get remainder from last div.
    :
    : skip:
    : ; calculate BX=BX/10
    : PUSH AX
    : MOV DX, 0
    : MOV AX, BX
    : DIV CS:ten10 ; AX = DX:AX / 10 (DX=remainder).
    : MOV BX, AX
    : POP AX
    :
    : JMP begin_print
    :
    : print_zero:
    : PUTC '0'
    :
    : end_print:
    :
    : POP DX
    : POP CX
    : POP BX
    : POP AX
    : RET
    : ten10 DW 10 ; used as divider.
    : PRINT_NUM_UNS ENDP
    :
    :
    : ; a procedure that prints out an unsigned
    : ; number in AX (not just a single digit)
    : ; allowed values from 0 to 65535 (0FFFFh)
    : PRINT_NUM PROC NEAR
    : PUSH DX
    : PUSH AX
    :
    : CMP AX, 0
    : JNZ not_zero
    :
    : PUTC '0'
    : JMP printed
    :
    : not_zero:
    : ; the check SIGN of AX,
    : ; make absolute if it's negative:
    : CMP AX, 0
    : JNS positive
    : NEG AX
    :
    : PUTC '-'
    :
    : positive:
    : CALL PRINT_NUM_UNS
    : printed:
    : POP AX
    : POP DX
    : RET
    : PRINT_NUM ENDP
    :
    :
    : ;***************************************************************
    : ; This procedure is used to print a null terminated
    : ; string at current cursor position.
    : ; The ZERO TERMINATED string should be defined just after
    : ; the CALL. For example:
    : ;
    : ; CALL PTHIS
    : ; db 'Hello World!', 0
    : ;
    : ; Address of string is stored in the Stack as return address.
    : ; Procedure updates value in the Stack to make return
    : ; after string definition.
    : PTHIS PROC NEAR
    :
    : MOV CS:temp1, SI ; re-store SI register.
    :
    : POP SI ; get return address (IP).
    :
    : PUSH AX ; store AX register.
    :
    : next_char:
    : MOV AL, CS:[SI]
    : INC SI ; next byte.
    : CMP AL, 0
    : JZ printedq
    : MOV AH, 0Eh ; teletype function.
    : INT 10h
    : JMP next_char ; loop.
    : printedq:
    :
    : POP AX ; re-store AX register.
    :
    : ; SI should point to next command after
    : ; the CALL instruction and string definition:
    : PUSH SI ; save new return address into the Stack.
    :
    : MOV SI, CS:temp1 ; re-store SI register.
    :
    : RET
    : temp1 DW ? ; variable to store original value of SI register.
    : PTHIS ENDP
    :
    : END
    :
    : ; Coding by Alexander Popov
    : ; http://www.geocities.com/emu8086/
    :
    : [/code]
    :
    :

  • non0non0 Posts: 5Member
    : [code]
    :
    : ; Coding by Alexander Popov, December 2002
    : ; Compiled and checked on emu8086
    : ; (8086 assembler and microprocessor emulator)
    : ; http://www.geocities.com/emu8086/
    :
    : ; This sample just inputs 5 numbers into an array,
    : ; and prints them out...
    :
    : #make_com#
    :
    : ORG 100h
    :
    : jmp start
    :
    : array dw 0,0,0,0,0
    : size dw 5 ; array size
    :
    : start:
    :
    : ; get 5 values from the user:
    : CALL PTHIS
    : db "Enter 5 values", 13,10,0
    :
    : MOV AX, 0
    : MOV BX, 0 ; array pointer
    : next_num:
    :
    : CALL SCAN_NUM
    : MOV array[BX], CX
    :
    : ; new line:
    : PUTC 13
    : PUTC 10
    :
    : ADD BX, 2 ; next word.
    : INC AX
    : CMP AX, size
    : JB next_num
    :
    : ; print out all 5 values:
    :
    : CALL PTHIS
    : db "You have entered:", 13,10,0
    :
    : MOV CX, size
    : MOV BX, 0 ; array pointer
    : next_prnt:
    :
    : MOV AX, array[BX]
    : CALL PRINT_NUM
    :
    : ; make space:
    : PUTC ' '
    :
    : ADD BX, 2 ; next word.
    : LOOP next_prnt
    :
    : mov ah, 4ch
    : int 21h
    :
    :
    : ; Here is a procedure that
    : ; gets the multi-digit SIGNED number from the keyboard,
    : ; and stores the result in CX register:
    : SCAN_NUM PROC NEAR
    : PUSH DX
    : PUSH AX
    : PUSH SI
    :
    : MOV CX, 0
    :
    : ; reset flag:
    : MOV CS:make_minus, 0
    :
    : next_digit:
    :
    : ; get char from keyboard
    : ; into AL:
    : MOV AH, 00h
    : INT 16h
    : ; and print it:
    : MOV AH, 0Eh
    : INT 10h
    :
    : ; check for MINUS:
    : CMP AL, '-'
    : JE set_minus
    :
    : ; check for ENTER key:
    : CMP AL, 13 ; carriage return?
    : JNE not_cr
    : JMP stop_input
    : not_cr:
    :
    :
    : CMP AL, 8 ; 'BACKSPACE' pressed?
    : JNE backspace_checked
    : MOV DX, 0 ; remove last digit by
    : MOV AX, CX ; division:
    : DIV CS:ten ; AX = DX:AX / 10 (DX-rem).
    : MOV CX, AX
    : PUTC ' ' ; clear position.
    : PUTC 8 ; backspace again.
    : JMP next_digit
    : backspace_checked:
    :
    :
    : ; allow only digits:
    : CMP AL, '0'
    : JAE ok_AE_0
    : JMP remove_not_digit
    : ok_AE_0:
    : CMP AL, '9'
    : JBE ok_digit
    : remove_not_digit:
    : PUTC 8 ; backspace.
    : PUTC ' ' ; clear last entered not digit.
    : PUTC 8 ; backspace again.
    : JMP next_digit ; wait for next input.
    : ok_digit:
    :
    :
    : ; multiply CX by 10 (first time the result is zero)
    : PUSH AX
    : MOV AX, CX
    : MUL CS:ten ; DX:AX = AX*10
    : MOV CX, AX
    : POP AX
    :
    : ; check if the number is too big
    : ; (result should be 16 bits)
    : CMP DX, 0
    : JNE too_big
    :
    : ; convert from ASCII code:
    : SUB AL, 30h
    :
    : ; add AL to CX:
    : MOV AH, 0
    : MOV DX, CX ; backup, in case the result will be too big.
    : ADD CX, AX
    : JC too_big2 ; jump if the number is too big.
    :
    : JMP next_digit
    :
    : set_minus:
    : MOV CS:make_minus, 1
    : JMP next_digit
    :
    : too_big2:
    : MOV CX, DX ; restore the backuped value before add.
    : MOV DX, 0 ; DX was zero before backup!
    : too_big:
    : MOV AX, CX
    : DIV CS:ten ; reverse last DX:AX = AX*10, make AX = DX:AX / 10
    : MOV CX, AX
    : PUTC 8 ; backspace.
    : PUTC ' ' ; clear last entered digit.
    : PUTC 8 ; backspace again.
    : JMP next_digit ; wait for Enter/Backspace.
    :
    :
    : stop_input:
    : ; check flag:
    : CMP CS:make_minus, 0
    : JE not_minus
    : NEG CX
    : not_minus:
    :
    : POP SI
    : POP AX
    : POP DX
    : RET
    : make_minus DB ? ; used as a flag.
    : ten DW 10 ; used as multiplier.
    : SCAN_NUM ENDP
    :
    : ; this macro prints a
    : ; char in AL and advances
    : ; the current cursor
    : ; position:
    : PUTC MACRO char
    : PUSH AX
    : MOV AL, char
    : MOV AH, 0Eh
    : INT 10h
    : POP AX
    : ENDM
    :
    : ; a procedure that prints number in AX,
    : ; used with PRINT_NUM_UNS to print signed numbers:
    : PRINT_NUM_UNS PROC NEAR
    : PUSH AX
    : PUSH BX
    : PUSH CX
    : PUSH DX
    :
    : ; flag to prevent printing zeros before number:
    : MOV CX, 1
    :
    : ; (result of "/ 10000" is always less or equal to 9).
    : MOV BX, 10000 ; 2710h - divider.
    :
    : ; AX is zero?
    : CMP AX, 0
    : JZ print_zero
    :
    : begin_print:
    :
    : ; check divider (if zero go to end_print):
    : CMP BX,0
    : JZ end_print
    :
    : ; avoid printing zeros before number:
    : CMP CX, 0
    : JE calc
    : ; if AX<BX then result of DIV will be zero:
    : CMP AX, BX
    : JB skip
    : calc:
    : MOV CX, 0 ; set flag.
    :
    : MOV DX, 0
    : DIV BX ; AX = DX:AX / BX (DX=remainder).
    :
    : ; print last digit
    : ; AH is always ZERO, so it's ignored
    : ADD AL, 30h ; convert to ASCII code.
    : PUTC AL
    :
    :
    : MOV AX, DX ; get remainder from last div.
    :
    : skip:
    : ; calculate BX=BX/10
    : PUSH AX
    : MOV DX, 0
    : MOV AX, BX
    : DIV CS:ten10 ; AX = DX:AX / 10 (DX=remainder).
    : MOV BX, AX
    : POP AX
    :
    : JMP begin_print
    :
    : print_zero:
    : PUTC '0'
    :
    : end_print:
    :
    : POP DX
    : POP CX
    : POP BX
    : POP AX
    : RET
    : ten10 DW 10 ; used as divider.
    : PRINT_NUM_UNS ENDP
    :
    :
    : ; a procedure that prints out an unsigned
    : ; number in AX (not just a single digit)
    : ; allowed values from 0 to 65535 (0FFFFh)
    : PRINT_NUM PROC NEAR
    : PUSH DX
    : PUSH AX
    :
    : CMP AX, 0
    : JNZ not_zero
    :
    : PUTC '0'
    : JMP printed
    :
    : not_zero:
    : ; the check SIGN of AX,
    : ; make absolute if it's negative:
    : CMP AX, 0
    : JNS positive
    : NEG AX
    :
    : PUTC '-'
    :
    : positive:
    : CALL PRINT_NUM_UNS
    : printed:
    : POP AX
    : POP DX
    : RET
    : PRINT_NUM ENDP
    :
    :
    : ;***************************************************************
    : ; This procedure is used to print a null terminated
    : ; string at current cursor position.
    : ; The ZERO TERMINATED string should be defined just after
    : ; the CALL. For example:
    : ;
    : ; CALL PTHIS
    : ; db 'Hello World!', 0
    : ;
    : ; Address of string is stored in the Stack as return address.
    : ; Procedure updates value in the Stack to make return
    : ; after string definition.
    : PTHIS PROC NEAR
    :
    : MOV CS:temp1, SI ; re-store SI register.
    :
    : POP SI ; get return address (IP).
    :
    : PUSH AX ; store AX register.
    :
    : next_char:
    : MOV AL, CS:[SI]
    : INC SI ; next byte.
    : CMP AL, 0
    : JZ printedq
    : MOV AH, 0Eh ; teletype function.
    : INT 10h
    : JMP next_char ; loop.
    : printedq:
    :
    : POP AX ; re-store AX register.
    :
    : ; SI should point to next command after
    : ; the CALL instruction and string definition:
    : PUSH SI ; save new return address into the Stack.
    :
    : MOV SI, CS:temp1 ; re-store SI register.
    :
    : RET
    : temp1 DW ? ; variable to store original value of SI register.
    : PTHIS ENDP
    :
    : END
    :
    : ; Coding by Alexander Popov
    : ; http://www.geocities.com/emu8086/
    :
    : [/code]
    :
    :

    [size=4]thnx for the code[/size]
    [size=2]it helps me a lot[/size]
    [hr][red][size=4]n[b][/b]n0[/size][/red]
    [blue][size=2][b]ASM[/b] programmer stuDz[/size][/blue]
    :-o [red] am in need of [b]HELP[/b]...[/red]:-o
    [hr]

Sign In or Register to comment.