हिंदी

Write an Assembly Language Program to find the product of two numbers stored in memory location C005H and C006H. Store the result in C000H and C001H. - Computer Science 2

Advertisements
Advertisements

प्रश्न

Write an Assembly Language Program to find the product of two numbers stored in memory location C005H and C006H. Store the result in C000H and C001H.

कोड लेखन
Advertisements

उत्तर

        LDA C005H        ; A = multiplicand
        MOV B, A         ; B = multiplicand

        LDA C006H        ; A = multiplier
        MOV C, A         ; C = multiplier (counter)

        LXI H, 0000H     ; HL = 0000 (16-bit result)

LOOP:   MOV A, L         ; Add multiplicand to L
        ADD B
        MOV L, A
        JNC NEXT         ; If no carry, skip increment
        INR H            ; If carry, increment high byte

NEXT:   DCR C            ; Decrease multiplier count
        JNZ LOOP         ; Repeat till C = 0

        MOV A, L         ; Store result low byte
        STA C000H
        MOV A, H         ; Store result high byte
        STA C001H

        HLT
shaalaa.com
  क्या इस प्रश्न या उत्तर में कोई त्रुटि है?
2021-2022 (March) Set 1

APPEARS IN

Share
Notifications

Englishहिंदीमराठी


      Forgot password?
Use app×