- ahmad alhayek

 

Q1: Write an Assembly language program that allows the user to enter a number and prints the factors of a number. Note: o Ass

Show transcribed image text

Expert Answerinformation icon

  • Anonymous's Avatar

    Step 1: Code

    .data
    myMsg BYTE "Enter a number to be evaluated:",0dh,0ah,0
    factor DWORD 2
    hold DWORD ?
    .code
    main PROC
    call Clrscr

    mov edx,offset myMsg
    call WriteString ;Displays myMsg
    call ReadDec ;Puts the value into EAX register
    mov edi, factor
    call prime


    exit
    main ENDP

    prime PROC

    step1: mov hold, eax
    mov eax, hold
    xor edx, edx
    div edi
    cmp edx, 0
    je step2
    add factor, 1
    mov edi, factor
    jmp step1

    step2: mov hold, eax
    mov eax, edi
    call WriteDec
    mov eax, hold
    CMP eax, 1
    jz step3
    jmp step1

    step3:
    exit
    prime ENDP


    END main

    Step 2: Summary

    I hope this code help you. Thank you.

    Comment 
Q2) Write an assembly program that prompts the user to enter a number and prints the multiplication table of the entered numb
Show transcribed image text

Expert Answerinformation icon

  • Koushal Kumar's Avatar

    .model small
    .stack 100h
    .data
    num db ?
    msg db 'Multiplication table of :$'
    string db 5 dup(?)
    .code
    main proc
    MOV AX, @data
    MOV DS, AX

    LEA DX, msg ;; PRINT THE INPUT NUMBER
    MOV AH, 9
    int 21h
    MOV AH, 1
    int 21h
    SUB AL, 48 ;; CONVERTING INTO NUMBER
    MOV num, AL

    XOR BX, BX
    MOV BL, 1
    MOV CX, 10
    TOP:MOV AL, num   
    MUL BL
    PUSH BX   
    PUSH CX
    LEA SI, string

    MOV BX, 10
    XOR CX, CX
    DIVISION: XOR DX,DX
    DIV BX
    PUSH DX
    INC CX
    CMP AX, 0
    JNE DIVISION
    STORE: POP DX
    ADD DL, 48
    MOV [SI], DL
    INC SI
    LOOP STORE
    MOV [SI], '$ '

    POP CX
    POP BX
    MOV DL, 13   
    MOV AH, 2
    INT 21h
    MOV DL, 10
    MOV AH, 2
    INT 21h
      
    LEA DX, STRING   
    MOV AH, 9
    INT 21h

    INC BL
    LOOP TOP   

    MOV AH, 4ch ;; END
    INT 21h
    MAIN ENDP
    END

    Comment 

ليست هناك تعليقات:

إرسال تعليق

ahmad alhayek تصميم ahmad alhayek جميع الحقوق محفوظة 2016

صور المظاهر بواسطة sndr. يتم التشغيل بواسطة Blogger.