Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- .model small
- .data
- MyString db 28h dup (0) ;Designated array for String to be stored in
- MyChar db ?
- .stack 100h
- .code
- main:
- call Initsegs
- call ReadString
- mov DX, OFFSET MyString
- call Print
- call exit
- ;== PROCS Section ==
- PROC Initsegs
- push ax
- mov ax, @data
- mov ds,ax
- mov es,ax
- pop ax
- RET
- ENDP Initsegs
- PROC GetChar
- push AX
- mov AH, 1
- INT 21h
- mov MyChar, AL ;Save Char that was entered
- cmp MyChar, 13 ;See if its the Return key
- jnz dont_set ;If it isn't, do nothing more.
- stc ;Set Carry Flag
- dont_set:
- pop AX
- RET
- ENDP GetChar
- PROC ReadString
- push AX BX
- clc ;Clear the Carry Flag
- mov bx, OFFSET MyString
- redo:
- call GetChar
- jc done ;If the Carry Flag is set, String is finished.
- mov AL, MyChar ;Move the stored Char into AL
- mov [BX], AL ;Move Char into next available slot in array
- inc bx ;Move pointer to next slot
- jmp redo
- done:
- mov [BX], byte ptr '$' ;Append a $ to the end of array for use with Func. 9 of INT 21 API
- pop BX AX
- RET
- ENDP ReadString
- PROC Print
- push AX
- mov AH, 9
- INT 21h
- pop AX
- RET
- ENDP Print
- PROC Exit
- mov ah, 4ch
- INT 21H
- RET
- ENDP Exit
- end main
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement