Advertisement
AVONnadozie

PROCEDURE TO DISPLAY CHARACTERS IN MEMORY

Mar 23rd, 2013
301
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ;********************************************************************************************************************
  2. ;*                       AUTHOR: ANUEBUNWA VICTOR OGECHUKWU                                                         *
  3. ;*                                                                                                                  *
  4. ;*                    PROCEDURE TO DISPLAY CHARACTERS IN MEMORY                                                     *
  5. ;* Procedure DISPLAY displays characters in memory starting from a given address till it encounters CARRIAGE-RETURN.*
  6. ;* ............................................HOW TO USE.......................................................... *
  7. ;* (1) Load the starting address of the memory into SI register.                                                    *
  8. ;* (2) Call DISPLAY.                                                                                                *
  9. ;********************************************************************************************************************
  10.  
  11. ;         SAMPLE PROGRAM
  12. .MODEL SMALL
  13. .STACK
  14. .DATA
  15.     AVON DB ?
  16. .CODE
  17. START:      MOV AX, @DATA
  18.             MOV DS, AX
  19.            
  20.             MOV AH, 3FH             ;Input string function
  21.             LEA DX, AVON
  22.             INT 21H
  23.            
  24.             LEA SI, AVON
  25.             CALL DISPLAY
  26.            
  27.             MOV AH, 4CH
  28.             INT 21H
  29.  
  30. ;;Procedure DISPLAY
  31. DISPLAY PROC
  32.             PUSH AX
  33.             PUSH DX
  34.             PUSH SI
  35.             PUSHF
  36.            
  37.             MOV AH, 02H
  38. DLOOP1:     MOV DL, [SI]            ;Moves character at current address to DL
  39.             CMP DL, 13
  40.             JE XDLOOP1              ;Exits loop if DL contains CARRIAGE-RETURN
  41.             INT 21H                 ;Else, displays character
  42.             INC SI                  ;Moves to next address
  43.             JMP DLOOP1              ;Continues loop
  44.            
  45. XDLOOP1:    POPF
  46.             POP SI
  47.             POP DX
  48.             POP AX
  49.             RET
  50. DISPLAY ENDP
  51. ;End of procedure DISPLAY
  52.    
  53. END START
  54. ;                               \|||/                                            
  55. ;          .-.________          (o o)                        ________.-.                    
  56. ;     ----/ \_)_______)  +-oooO--(_)---------------------+  (_______(_/ \----              
  57. ;        (    ()___)     | Get more Codes At:            |    (___()     )                  
  58. ;             ()__)      |                               |     (__()                        
  59. ;     ----\___()_)       | www.showmecodes.blogspot.com  |      (_()___/----                
  60. ;                        +-----------------------Ooo-----+                                  
  61. ;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement