Advertisement
Guest User

Menu xu ly chuoi

a guest
May 27th, 2015
298
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. ; Input: string, Ouput: upper(input)
  2. ; Author: hungdh
  3.  
  4. data segment
  5.     ; add your data here!
  6.     MsgMenu   db 0Ah,0Dh,"Menu: $"
  7.     Msg1   db 0Ah,0Dh,"1. Nhap chuoi.$"  
  8.     Msg2   db 0Ah,0Dh,"2. Hien thi chuoi hoa.$"
  9.     Msg3   db 0Ah,0Dh,"3. Hien thi chuoi thuong.$"
  10.     Msg4   db 0Ah,0Dh,"3. Hien thi chuoi dao nguoc.$"
  11.     MsgExit   db 0Ah,0Dh,"4. Exit(E).$"
  12.     MsgChoice db 0Ah,0Dh,"Ban chon: $"    
  13.     MsgWrong  db 0Ah,0Dh,"Nhap sai. Vui long nhap lai!$"  
  14.     MsgResult db 0Ah,0Dh,"Ket qua: $"  
  15.  
  16.     strInput 100,0,100 dup('$')
  17. ends
  18.  
  19. stack segment
  20.     dw   128  dup(0)
  21. ends
  22.  
  23. code segment
  24. start:
  25. ; set segment registers:
  26.     mov ax, data
  27.     mov ds, ax
  28.     mov es, ax
  29.  
  30.     ; add your code here  
  31. begin:  
  32.     MOV AH, 09h
  33.     LEA DX, MsgMenu
  34.     INT 21h
  35.     LEA DX, Msg1
  36.     INT 21h
  37.     LEA DX, Msg2
  38.     INT 21h
  39.     LEA DX, Msg3
  40.     INT 21h
  41.     LEA DX, Msg4
  42.     INT 21h
  43.     LEA DX, MsgExit
  44.     INT 21h
  45.     LEA DX, MsgChoice
  46.     INT 21h
  47.    
  48.     MOV AH, 01h
  49.     INT 21h
  50.    
  51.     CMP AL, '1'  
  52.     JNZ th2
  53.     ; Nhap chuoi
  54.     LEA DX, strInput
  55.     MOV AH, 0Ah
  56.     INT 21h
  57.     JMP begin ; Hien thi lai menu
  58. th2:
  59.     CMP AL, '2'
  60.     JNZ th3    
  61.     ;Hien thi Ket qua:
  62.     LEA DX, MsgResult
  63.     MOV AH, 09h
  64.     INT 21h
  65.     ; Hien thi chu hoa
  66.     XOR CX, CX
  67.     LEA BX, MsgInput
  68.     INC BX        
  69.     MOV CL, BYTE PTR [BX]
  70.     MOV AH,02h
  71. for1:      
  72.     INC BX
  73.     MOV DL, BYTE PTR [BX]
  74.     CMP DL, 'a'
  75.     JL tiep ; Neu ki tu nhap >= a thi moi - 20
  76.     SUB DL, 20h
  77. tiep:
  78.     INT 21h
  79.     LOOP for1
  80.     JMP begin
  81.  
  82. th3:
  83.     CMP AL, '3'
  84.     JNZ th4
  85.     ;Hien thi Ket qua:
  86.     LEA DX, MsgResult
  87.     MOV AH, 09h
  88.     INT 21h
  89.     ; Hien thi chu thuong
  90.     XOR CX, CX
  91.     LEA BX, MsgInput
  92.     INC BX        
  93.     MOV CL, BYTE PTR [BX]
  94.     MOV AH,02h
  95. for2:      
  96.     INC BX
  97.     MOV DL, BYTE PTR [BX]
  98.     CMP DL, 'a'
  99.     JL tiep2 ; Neu ki tu nhap < a thi moi + 20
  100.     ADD DL, 20h
  101. tiep2:
  102.     INT 21h
  103.     LOOP for1
  104.     JMP begin
  105.  
  106.    ; In chuoi nguoc
  107. th4:
  108.     CMP AL, '4'
  109.     JNZ th5
  110.      ;Hien thi Ket qua:
  111.     LEA DX, MsgResult
  112.     MOV AH, 09h
  113.     INT 21h
  114.     ; Hien thi chuoi nguoc
  115.     XOR CX, CX
  116.     LEA BX, MsgInput
  117.     INC BX        
  118.     MOV CL, BYTE PTR [BX]
  119.     ADD BX, CL
  120.     MOV AH, 02h
  121. for3:
  122.     MOV DL, BYTE PTR [BX]
  123.     INT 21h
  124.     DEC BX
  125.     LOOP for3
  126.     JMP begin
  127.     ; Exit
  128. th5:
  129.     CMP AL, '5'
  130.     JNZ th6
  131.     JMP thoat
  132. th6:
  133.     MOV AH, 09h
  134.     LEA DX, MsgWrong
  135.     INT 21h
  136.     JMP begin
  137. thoat:    
  138.     mov ax, 4c00h ; exit to operating system.
  139.     int 21h    
  140. ends
  141.  
  142. end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement