home *** CD-ROM | disk | FTP | other *** search
/ Jason Aller Floppy Collection / 181.img / TASM-101.ZIP / CHAPXMPL.ARC / IDLEXMPL.ASM < prev    next >
Assembly Source File  |  1989-05-02  |  2KB  |  69 lines

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