ASM Assignment 1
ASM Assignment 1
ASM Assignment 1
PROG 1
.model small .stack 100h .data a dw 10 b dw 20 .code main proc mov ax,@data mov ds,ax mov ax,a mov bx,b add ax,bx mov ax,4c00h int 21h main endp end main
PROG 2
.model small .stack 100h .data str db 30 dup(?) str2 db "ENTER THE STRING TO BE DISPLAYED -",'$' .code get_string proc near
next:
lea di,str mov ah,01h int 21h cmp al,13 je str_end mov [di],al inc di jmp next
str_end: mov al,24h mov [di],al ret get_string endp print_string proc near mov bx,0h mov dx,str[bx] nextm: mov ah,02h int 21h inc bx cmp str[bx],24h je sr_end mov dx,str[bx] jmp nextm sr_end: print_string endp mov ax,4c00h int 21h
print1 proc near nexte1: mov mov mov int bx,0h dx,str2[bx] ah,02h 21h
inc bx cmp str2[bx],24h jne nexte1 call get_string ret print1 endp main proc
mov ax,@data mov ds,ax call print1 mov dx,10 mov ah,02h int 21h call print_string mov ax,4c00h int 21h main endp end main
PROG 3
.MODEL SMALL .STACK 100H .DATA STR1 DB "Enter The Name : ",'$' STR DB 0AH,0DH,'$' ARR DB 20 DUP(0) .CODE MAIN PROC MOV AX,@DATA MOV DS,AX LEA DX,STR1 MOV AX,0900H INT 21H MOV AX,24H PUSH AX LEA DI,ARR NEXT: MOV AH,01H INT 21H CMP AL,13 JE STR_END MOV [DI],AL MOV AH,0 PUSH AX INC DI JMP NEXT MOV AL,24H MOV [DI],AL
STR_END:
LEA DX,STR MOV AX,0900H INT 21H LOOP1: POP DX CMP DX,36 JE TER MOV AX,0200H INT 21H JMP LOOP1
TER:
PROG 4
.MODEL SMALL .STACK 100H .DATA DIGIT DW 0 H DW 0 STR1 DB "Enter the Integer to be converted : ",'$' .CODE MAIN PROC MOV AX,@DATA MOV DS,AX MOV AX,24H PUSH AX LEA DX,STR1 MOV AX,0900H INT 21H MOV MOV MOV MOV DI,0 BX,0 CX,10 DX,0 MOV AH,01H
GET_DIGIT:
INT 21H CMP AL,13 JE FINISH cmp al,47 jbe ter8 cmp al,58 jae ter8 MOV AH,0 SUB AX,48 MOV MOV MUL ADD MOV JMP FINISH: LOOP1: DIGIT,AX AX,BX CX AX,DIGIT BX,AX GET_DIGIT
MOV AX,BX MOV H,BX MOV DX,0 DIV CX PUSH DX CMP AX,10 JAE LOOP1
PUSH AX MOV DX,10 MOV AX,0200H INT 21H jmp loop2 ter8: jmp ter9 LOOP2: POP DX CMP DX,24H JE TER1 ADD DX,30H MOV AX,0200H INT 21H JMP LOOP2 MOV DX,10 MOV AX,0200H INT 21H MOV AX,24H PUSH AX
TER1:
MOV AX,H MOV BX,2 LOOP3: MOV DX,0 DIV BX PUSH DX CMP AX,1 JNE LOOP3
PUSH AX MOV DX,10 MOV AX,0200H INT 21H LOOP4: POP DX CMP DX,24H JE TER2 ADD DX,30H MOV AX,0200H INT 21H JMP LOOP4 MOV DX,10 MOV AX,0200H INT 21H
TER2:
MOV AX,24H PUSH AX MOV AX,H MOV BX,16 LOOP5: MOV DX,0 CMP AX,15 JBE again DIV BX PUSH DX JMP LOOP5 PUSH AX MOV DX,10 MOV AX,0200H INT 21H LOOP6: POP DX CMP DX,24H JE TER3 CMP DX,10 JAE CON ADD DX,30H MOV AX,0200H INT 21H
again:
JMP LOOP6 CON: CMP DX,10 JE A CMP DX,11 JE B CMP DX,12 JE C CMP DX,13 JE D CMP DX,14 JE E CMP DX,15 JE F A: B: C: D: E: F: PRINT: MOV DX,"A" JMP PRINT MOV DX,"B" JMP PRINT MOV DX,"C" JMP PRINT MOV DX,"D" JMP PRINT MOV DX,"E" JMP PRINT MOV DX,"F" JMP PRINT MOV AX,0200H INT 21H JMP LOOP6 MOV DX,10 MOV AX,0200H INT 21H
TER3:
PROG 5
.MODEL SMALL .STACK 100H .DATA STR DB "The Sum Of Ten Elements is: ",'$' ARR DW 5,6,7,8,9,10,11,12,13 C DW 10 .CODE MAIN PROC MOV AX,@DATA MOV DS,AX MOV AX,36 PUSH AX MOV DX,10 MOV AX,0200H INT 21H LEA DI,STR MOV AX,0900H INT 21H MOV CX,0 LEA DI,ARR MOV AX,[DI] LOOP1: INC INC INC ADD DI DI CX AX,[DI]
CMP CX,9 JB LOOP1 MOV BX,C LOOP2 : MOV DX,0 DIV BX PUSH DX CMP AX,10 JAE LOOP2
PUSH AX LOOP3: POP DX CMP DX,36 JE TER ADD DX,48 MOV AX,0200H
INT 21H JMP LOOP3 TER: MOV MOV INT MOV INT DX,10 AX,0200H 21H AX,4C00H 21H