PU Assembly language Solved Past Paper

Check vowel or consonant in Assembly

MODEL SMALL

STACK 100H

DATA

VOWEL DB 0DH,0AH,'VOWEL$'

CONSONANT DB 0DH,0AH,'CONSONANT$'

CODE

MAIN PROC

MOV AX,@DATA

MOV DS,AX  

MOV AH,1

INT 21H

CMP AL,'A'

JE VL

CMP AL,'E'

JE VL

CMP AL,'I'

JE VL

CMP AL,'O'

 JE VL

 CMP AL,'U'

 JE VL

 CMP AL,'a'

 JE VL

 CMP AL,'e'

 JE VL

 CMP AL,'i'

 JE VL

 CMP AL,'o'

 JE VL

 CMP AL,'u'

 JE VL

  LEA DX,CONSONANT

  MOV AH,9

  INT 21H

  JMP EXIT


  

 VL:

  LEA DX,VOWEL

  MOV AH,9

  INT 21H

   

 EXIT:

  MOV AH,4CH

  INT 21H

 MAIN ENDP

END MAIN


FACTORIAL NUMBER

CODE

MAIN PROC


//GIVEN NUMBER STORED IN R1 REGISTER

//RESULT IS STORED IN R7 REGISTER

//RESULT IS IN HEXADECIMAL 

//FACTORIAL UP TO 20 CAN BE FOUND 


ORG 0000

MOV R1,#20

MOV R7,#01

LCALL FACT

MOV R7,A

FACT:

MOV A,R7

CJNE R1,#00,UP

SJMP UP1

UP:

MOV B,R1

MUL AB

DJNZ R1,UP

UP1:

RET

END

sorting using array


public _Sort

.model flat

.code

Sort proc


    push ebp

    mov ebp, esp

    push esi

    push edi


    mov edi, [esp + 4]    ; address of destination array

    mov esi, [esp + 8]    ; address of source array

    mov ecx, [esp + 16]   ; # of elements to mov

    cld

    rep movsd

L1:

    mov eax, [esi]

    cmp [esi + 8], eax

    jg L2

    xchg eax, [esi + 8]

    mov [esi], eax

L2: 

    pop edi

    pop esi

    pop ebp


    ret     

Sort endp

end



INVOKE DIR

The INVOKE directive is a powerful replacement for

Intel’s CALL instruction that lets you pass multiple

arguments.

Syntax:

INVOKE procedureName [, argumentList]

ArgumentList is an optional comma-delimited list of procedure arguments

Arguments can be:

immediate values and integer expressions

variable names

address and ADDR expressions

register names


EXAMPLE


data

byteVal BYTE 10

wordVal WORD 1000h

code

; direct operands:

INVOKE Sub1,byteVal,wordVal

; address of variable:

INVOKE Sub2,ADDR byteVal

; register name, integer expression:

INVOKE Sub3,eax,(10 * 20)

; address expression (indirect operand):

INVOKE Sub4,[ebx]

Get updates in your Inbox
Subscribe