Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ; Input: string, Ouput: upper(input)
- ; Author: hungdh
- data segment
- ; add your data here!
- MsgMenu db 0Ah,0Dh,"Menu: $"
- Msg1 db 0Ah,0Dh,"1. Nhap chuoi.$"
- Msg2 db 0Ah,0Dh,"2. Hien thi chuoi hoa.$"
- Msg3 db 0Ah,0Dh,"3. Hien thi chuoi thuong.$"
- Msg4 db 0Ah,0Dh,"3. Hien thi chuoi dao nguoc.$"
- MsgExit db 0Ah,0Dh,"4. Exit(E).$"
- MsgChoice db 0Ah,0Dh,"Ban chon: $"
- MsgWrong db 0Ah,0Dh,"Nhap sai. Vui long nhap lai!$"
- MsgResult db 0Ah,0Dh,"Ket qua: $"
- strInput 100,0,100 dup('$')
- ends
- stack segment
- dw 128 dup(0)
- ends
- code segment
- start:
- ; set segment registers:
- mov ax, data
- mov ds, ax
- mov es, ax
- ; add your code here
- begin:
- MOV AH, 09h
- LEA DX, MsgMenu
- INT 21h
- LEA DX, Msg1
- INT 21h
- LEA DX, Msg2
- INT 21h
- LEA DX, Msg3
- INT 21h
- LEA DX, Msg4
- INT 21h
- LEA DX, MsgExit
- INT 21h
- LEA DX, MsgChoice
- INT 21h
- MOV AH, 01h
- INT 21h
- CMP AL, '1'
- JNZ th2
- ; Nhap chuoi
- LEA DX, strInput
- MOV AH, 0Ah
- INT 21h
- JMP begin ; Hien thi lai menu
- th2:
- CMP AL, '2'
- JNZ th3
- ;Hien thi Ket qua:
- LEA DX, MsgResult
- MOV AH, 09h
- INT 21h
- ; Hien thi chu hoa
- XOR CX, CX
- LEA BX, MsgInput
- INC BX
- MOV CL, BYTE PTR [BX]
- MOV AH,02h
- for1:
- INC BX
- MOV DL, BYTE PTR [BX]
- CMP DL, 'a'
- JL tiep ; Neu ki tu nhap >= a thi moi - 20
- SUB DL, 20h
- tiep:
- INT 21h
- LOOP for1
- JMP begin
- th3:
- CMP AL, '3'
- JNZ th4
- ;Hien thi Ket qua:
- LEA DX, MsgResult
- MOV AH, 09h
- INT 21h
- ; Hien thi chu thuong
- XOR CX, CX
- LEA BX, MsgInput
- INC BX
- MOV CL, BYTE PTR [BX]
- MOV AH,02h
- for2:
- INC BX
- MOV DL, BYTE PTR [BX]
- CMP DL, 'a'
- JL tiep2 ; Neu ki tu nhap < a thi moi + 20
- ADD DL, 20h
- tiep2:
- INT 21h
- LOOP for1
- JMP begin
- ; In chuoi nguoc
- th4:
- CMP AL, '4'
- JNZ th5
- ;Hien thi Ket qua:
- LEA DX, MsgResult
- MOV AH, 09h
- INT 21h
- ; Hien thi chuoi nguoc
- XOR CX, CX
- LEA BX, MsgInput
- INC BX
- MOV CL, BYTE PTR [BX]
- ADD BX, CL
- MOV AH, 02h
- for3:
- MOV DL, BYTE PTR [BX]
- INT 21h
- DEC BX
- LOOP for3
- JMP begin
- ; Exit
- th5:
- CMP AL, '5'
- JNZ th6
- JMP thoat
- th6:
- MOV AH, 09h
- LEA DX, MsgWrong
- INT 21h
- JMP begin
- thoat:
- mov ax, 4c00h ; exit to operating system.
- int 21h
- ends
- end start ; set entry point and stop the assembler.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement