Skip to content

Instantly share code, notes, and snippets.

@1UC1F3R616
Last active February 17, 2020 14:20
Show Gist options
  • Save 1UC1F3R616/4fd7bd3fd0233aa75e3b3c2b7b57caf3 to your computer and use it in GitHub Desktop.
Save 1UC1F3R616/4fd7bd3fd0233aa75e3b3c2b7b57caf3 to your computer and use it in GitHub Desktop.

To get Time

MOV DL,':'    ; To Print : in DOS
MOV AH,02H
INT 21H

;Seconds Part
Seconds:
MOV AH,2CH    ; To get System Time
INT 21H
MOV AL,DH     ; Seconds is in DH
AAM
MOV BX,AX
CALL DISP


;To terminate the Program

MOV AH,4CH     ; To Terminate the Program
INT 21H

;Display Part
DISP PROC
MOV DL,BH      ; Since the values are in BX, BH Part
ADD DL,30H     ; ASCII Adjustment
MOV AH,02H     ; To Print in DOS
INT 21H
MOV DL,BL      ; BL Part 

To check palindrome (18BCE0557 - Kushal)

.MODEL SMALL 
.STACK 100H 
.DATA 
  
; The string to be printed 
STRING DB 'kushhsuk', '$' ; string is given here
STRING1 DB 'String is palindrome', '$'
STRING2 DB 'String is not palindrome', '$'
  
.CODE 
MAIN PROC FAR 
 MOV AX, @DATA 
 MOV DS, AX 
  
 ; check if the string is; 
 ;palindrome or not 
 CALL Palindrome 
  
 ;interrupt to exit
 MOV AH, 4CH 
 INT 21H 
 MAIN ENDP 
 Palindrome PROC 
  
 ; load the starting address 
 ; of the string 
 MOV SI,OFFSET STRING 
  
 ; traverse to the end of; 
 ;the string 
 LOOP1 : 
    MOV AX, [SI] 
    CMP AL, '$'
    JE LABEL1 
    INC SI 
    JMP LOOP1 
  
 ;load the starting address; 
 ;of the string 
 LABEL1 : 
    MOV DI,OFFSET STRING 
    DEC SI 
  
    ; check if the string is plaindrome; 
    ;or not 
    LOOP2 : 
     CMP SI, DI 
     JL OUTPUT1 
     MOV AX,[SI] 
     MOV BX, [DI] 
     CMP AL, BL 
     JNE OUTPUT2 
  
    DEC SI 
    INC DI 
    JMP LOOP2 
  
 OUTPUT1: 
    ;load address of the string 
    LEA DX,STRING1 
  
    ; output the string; 
    ;loaded in dx 
    MOV AH, 09H 
    INT 21H 
    RET 
  
 OUTPUT2: 
    ;load address of the string 
    LEA DX,STRING2 
  
    ; output the string 
    ; loaded in dx 
    MOV AH,09H 
    INT 21H 
    RET 
  
Palindrome ENDP 
END MAIN 

Reversing a String (18BCE0557 KUSHAL | DA4 MICRO LAB)

.MODEL SMALL  
.STACK 100H  
.DATA  
  
; The string to be printed  
STRING DB 'Sometimes I do my DA on my own but very rarely', '$'
  
.CODE  
MAIN PROC FAR  
MOV AX,@DATA  
MOV DS,AX  
  
; call reverse function  
CALL REVERSE  
  
; load address of the string  
LEA DX,STRING  
  
; output the string 
; loaded in dx  
MOV AH, 09H  
INT 21H  
  
; interrupt to exit
MOV AH, 4CH 
INT 21H  
  
MAIN ENDP  
REVERSE PROC 
    ; load the offset of 
    ; the string  
    MOV SI, OFFSET STRING  
  
    ; count of characters of the;  
    ;string  
    MOV CX, 0H  
  
    LOOP1: 
    ; compare if this is;  
    ;the last character  
    MOV AX, [SI]  
    CMP AL, '$'
    JE LABEL1  
  
    ; else push it in the;  
    ;stack  
    PUSH [SI]  
  
    ; increment the pointer;  
    ;and count  
    INC SI  
    INC CX  
  
    JMP LOOP1  
  
    LABEL1: 
    ; again load the starting;  
    ;address of the string  
    MOV SI, OFFSET STRING  
  
        LOOP2:  
        ;if count not equal to zero  
        CMP CX,0  
        JE EXIT  
  
        ; pop the top of stack  
        POP DX  
  
        ; make dh, 0  
        XOR DH, DH  
  
        ; put the character of the;  
        ;reversed string  
        MOV [SI], DX  
  
        ; increment si and;  
        ;decrement count  
        INC SI  
        DEC CX  
  
        JMP LOOP2  
  
                  
    EXIT: 
    ; add $ to the end of string  
    MOV [SI],'$ '
    RET  
          
REVERSE ENDP  
END MAIN

Finding vowels in a string

 .MODEL SMALL
.STACK 64
.DATA
MAXLEN Db 100
            ACTCHAR Db ?
            STR DB 100 DUP('$')
            VL DB "AEIOUaeiou",'$'
            STR1 DB "NO. OF VOWELS IS ",'$'
.CODE
            MAIN PROC FAR
            MOV AX,@DATA
            MOV DS, AX
            MOV CX, 00
            MOV DI, 00
            MOV AX, 00
            LEA DX, MAXLEN
            MOV AH, 0AH
            INT 21H
            MOV CH, 00H
            MOV CL, ACTCHAR
            MOV DX, 00
L2:       MOV SI, 000BH
L1:       MOV AL, VL [SI]
            CMP AL, STR [DI]
            JNZ L3

            INC DH
            CMP DH, 0AH
            JB L3
            MOV DH, 00
            INC DL
L3:       SUB SI, 01
            JNZ L1
            INC DI
            LOOP L2

            MOV BX, DX
            MOV AH, 02H
            MOV DL, 0AH
            INT 21H
            MOV DL, 0DH
            INT 21H
            LEA DX, STR1
            MOV AH, 09H
            INT 21H

            MOV DX, bX
            ADD DL, 30H
            MOV AH, 02H
            INT 21H

            ADD DH, 30H
            MOV DL, DH
            MOV AH, 02H
            INT 21H
            MOV AX, 4C00H
            INT 21H
MAIN ENDP
END MAIN
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment