Last active
February 14, 2023 20:58
-
-
Save sudormrfbin/89b1d5e5a98ceae73ebae67a1643857e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data segment | |
| opr1 db 0ah, 0dh, "Enter first number: $" | |
| opr2 db 0ah, 0dh, "Enter second number: $" | |
| result db 0ah, 0dh, "Result is: $" | |
| num dw ? | |
| num1 dw ? | |
| num2 dw ? | |
| num3 dw ? | |
| sum dw ? | |
| display macro msg | |
| mov dx, offset msg | |
| mov ah, 09h ; display string | |
| int 21h | |
| endm | |
| read macro num | |
| local L1, exit | |
| mov ah, 01h | |
| int 21h | |
| mov ah, 00h | |
| sub ax, 0030h | |
| mov num, ax | |
| L1:mov ah, 01h ; read char | |
| int 21h | |
| cmp al, 0dh | |
| je exit | |
| mov ah, 00h | |
| sub ax, 0030h | |
| mov num1, ax | |
| mov ax, num | |
| mov bx, 000ah | |
| mul bx | |
| add ax, num1 | |
| mov num, ax | |
| jmp L1 | |
| exit:nop | |
| endm | |
| print macro num | |
| local L2, L3 | |
| mov cx, 0000h | |
| mov bx, 000ah | |
| mov ax, num | |
| L2:mov dx, 0000h | |
| div bx | |
| push dx | |
| inc cx | |
| cmp ax, 0000h | |
| jne L2 | |
| L3:pop dx | |
| add dx, 0030h | |
| mov ah, 02h ; print char | |
| int 21h | |
| loop L3 | |
| endm | |
| data ends | |
| code segment | |
| assume cs:code,ds:data | |
| start: | |
| mov ax, data | |
| mov ds, ax | |
| display opr1 | |
| read num2 | |
| mov cx, num2 | |
| display opr2 | |
| read num3 | |
| mov bx, num3 | |
| add cx, bx | |
| mov sum, cx | |
| display result | |
| print sum | |
| mov ah, 4ch | |
| int 21h | |
| mov ah, 01h ; wait for char to hold screen | |
| int 21h | |
| code ends | |
| end start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| data segment | |
| entr db 0ah, 0dh, "Enter string: $" | |
| is_pal db 0ah, 0dh, "Palindrome$" | |
| notpal db 0ah, 0dh, "Not Palindrome$" | |
| donemg db 0ah, 0dh, "Done$" | |
| w db 09h dup(?) | |
| data ends | |
| code segment | |
| assume cs:code,ds:data | |
| start:mov ax, data | |
| mov ds, ax | |
| mov si, offset w | |
| mov di, offset w | |
| lea dx, entr | |
| mov ah, 09h | |
| int 21h | |
| mov cl, 00h | |
| scan:mov ah, 01h | |
| int 21h | |
| cmp al, 0dh | |
| jz ended | |
| mov [si], al | |
| inc cl | |
| inc si | |
| jmp scan | |
| ended:dec si | |
| chk:mov bl, [di] | |
| cmp [si], bl | |
| jnz npal | |
| inc di | |
| dec si | |
| loop chk | |
| lea dx, is_pal | |
| mov ah, 09h | |
| int 21h | |
| jmp done | |
| npal:lea dx, notpal | |
| mov ah, 09h | |
| int 21h | |
| done:mov ah, 4ch | |
| int 21h | |
| code ends | |
| end start | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment