





Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!






Program to add two 8 bit numbers: CODE: code segment assume cs:code start: mov ah, 0000h mov si,3000h mov al,[si] inc si mov bl,[si] add al,bl inc si mov [si],al jc l inc si mov [si],ah int 3 ; used for singnaling that a breakpoint has been hit in debug l1: inc si mov [si],ah int 3 code ends end start Output: Subtraction of two numbers: CODE: code segment assume cs:code start: mov ah, 0000h mov si,3000h mov al,[si] inc si
mov bl,[si] sub al,bl inc si mov [si],al jc l inc si mov [si],ah int 3 l1: inc si mov [si],ah int 3 code ends end start Output: Multiplication of two numbers: CODE: code segment assume cs:code start: mov ax, 0000h mov si, 3000h mov al, byte ptr [si] inc si mov bl, byte ptr [si] mul bl inc si mov byte ptr [si], al inc si mov byte ptr [si], ah int 3 code ends end start Output:
mov al, byte ptr [si] inc si mov bl, byte ptr [si] and al, bl inc si mov byte ptr [si], al inc si mov byte ptr [si], 00h int 3 code ends end start Output: Program to perform logical OR operation CODE: code segment assume cs:code start: mov si, 3000h mov al, byte ptr [si] inc si mov bl, byte ptr [si] or al, bl mov si, 3002h mov byte ptr [si], al inc si mov byte ptr [si], 00h int 3 code ends end start Output:
Taking input of string and outputting a string CODE: .model small .stack 100h .data prompt db 'Enter your name: $' buffer db 100 dup('$') ; Buffer to store input string str db 'Hello, $' .code main proc mov ax, @data mov ds, ax ; Display prompt mov ah, 09h ; 09 is used to print a string stopping at $ lea dx, prompt ; loads the effective prompt address in dx int 21h ; performs the interrupt operation according to data in ah ; Read string from user mov ah, 0Ah ; for reading string 0A is used lea dx, buffer ; loads effective address of buffer inside ds int 21h ; Move to new line mov ah, 02h ; prints character present in dl mov dl, 0Dh ; moves cursor to start int 21h mov dl, 0Ah ; moves cursor to next line int 21h ; Display str mov ah, 09h lea dx, str
56H Rename file. A program that reads a file and displays the contents of that file CODE: .model small .stack 100h .DATA MESS1 DB 0AH,0DH,07H,'PLEASE ENTER FILE NAME $' MESS2 DB 0AH,0DH,07H,'SORRY FILE OPENING ERROR $' MESS3 DB 0AH,0DH,07H,'S0RRY FILE READING ERROR$' MESS4 DB 0AH,0DH,07H,'SORRY FILE CLOSING ERROR$' STRING DB 30 DUP(?) HANDLE DW? CHAR DB? DISPLAY MACRO DISP LEA DX,DISP MOV AH,09H INT 21H ENDM .CODE ;----------------- ;READ FILE NAME ;----------------- MOV AX,@data MOV DS,AX DISPLAY MESS MOV AH,0AH ;PLACE KEYBOARD CHARACTER INTO INPUT BUFFER MOV DX,OFFSET STRING ;START OF THE INPUT BUFFER MOV STRING,27 ;MAXIMUM LENGTH OF THE STRING INT 21H MOV BX,DX ;LENGTH OF THE STRING ACTUALLY ENTERED MOV AL,STRING+1 ; SUB AH,AH ;CLEAR AH ADD BX,AX MOV BYTE PTR [BX+2],0 ;LAST CHARACTER OF THE STRING 00H ; New Line