home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c081_11 / 9.ddi / CHAPXMPL.ZIP / IDLEXMPL.ASM < prev    next >
Encoding:
Assembly Source File  |  1991-02-13  |  2.4 KB  |  75 lines

  1. ; Turbo Assembler    Copyright (c) 1988, 1991 By Borland International, Inc.
  2.  
  3. ; IDLEXMPL.ASM - Ideal mode example program to uppercase a line
  4.  
  5. ; From the Turbo Assembler Users Guide - Turbo Assembler Ideal Mode
  6.  
  7. ; File <idlexmpl.asm>
  8. ; Ideal mode example program to uppercase a line
  9.      IDEAL                                                    ;#1
  10.      %TITLE    "Example Ideal-Mode Program"                   ;#2
  11.      P286N                                                    ;#3
  12.  
  13. BufSize   =    128
  14.  
  15. MACRO dosint intnum                                           ;#4
  16.      mov  ah,intnum
  17.      int  21h
  18. ENDM
  19.  
  20. SEGMENT stk STACK                                             ;#5
  21.      db   100h DUP (?)
  22. ENDS                                                          ;#6
  23.  
  24. SEGMENT DATA WORD                                             ;#7
  25. inbuf     db   BufSize DUP (?)
  26. outbuf    db   BufSize DUP (?)
  27. ENDS DATA                                                     ;#8
  28.  
  29. GROUP DGROUP stk,DATA                                         ;#9
  30.  
  31. SEGMENT CODE WORD                                             ;#10
  32.       ASSUME   cs:CODE
  33. start:
  34.      mov  ax,DGROUP
  35.      mov  ds,ax
  36.      ASSUME    ds:DGROUP
  37.      mov  dx,OFFSET inbuf                                    ;#11
  38.      xor  bx,bx
  39.      call readline
  40.      mov  bx,ax
  41.      mov  [inbuf + bx],0                                     ;#12
  42.      push ax
  43.      call mungline
  44.      pop  cx
  45.      mov  dx,OFFSET outbuf                                   ;#13
  46.      mov  bx,1
  47.      dosint    40h
  48.      dosint    4ch
  49.  
  50. ;Read a line, called with dx => buffer, returns count in AX
  51. PROC readline near                                           ;#14
  52.      mov  cx,BufSize
  53.      dosint    3fh
  54.      and  ax,ax
  55.      ret
  56. ENDP                                                         ;#15
  57.  
  58. ;Convert line to uppercase
  59. PROC mungline NEAR                                           ;#16
  60.      mov  si,OFFSET inbuf                                    ;#17
  61.      mov  di,0
  62. @@uloop:
  63.      cmp  [BYTE si],0                                        ;#18
  64.      je   @@done
  65.      mov  al,[si]
  66.      and  al,not 'a' - 'A'
  67.      mov  [outbuf + di],al                                   ;#19
  68.      inc  si
  69.      inc  di
  70.      jmp  @@uloop
  71. @@done:   ret
  72. ENDP mungline                                                ;#20
  73. ENDS                                                         ;#21
  74.      END  start
  75.