Two 8086 program wanted

I want 8086 assembly language program to find any given sub-string in a string. And also I want 8086 assembly language program that multiplies
two four digit packed BCD numbers.


Comments

  • This looks suspiciously like homework!
  • : This looks suspiciously like homework!
    : Yes. But can you help me ?

  • The string handling should be in some older thread somewhere. As for the BCD multiplication, didn't your teacher teach you how to do it?
  • : I want 8086 assembly language program to find any given sub-string in a string. And also I want 8086 assembly language program that multiplies
    : two four digit packed BCD numbers.
    :
    :
    :
    yep this smells like homework :) , i think there is an algorithm for multipling the to values , but if there isnt then you have to convert the two values for a normal number :
    ex; imagine that the letters are a digit in your number ::

    abcd = a* 10^3 + b* 10^2 + c* 10^1+ d* 10^0

    after converting the two number you just have to use it normal ,
    for separat the digits use the "and" and "shr"

    shame on you :(



  • : : I want 8086 assembly language program to find any given sub-string in a string. And also I want 8086 assembly language program that multiplies
    : : two four digit packed BCD numbers.
    : :
    : :
    : :
    : yep this smells like homework :) , i think there is an algorithm for multipling the to values , but if there isnt then you have to convert the two values for a normal number :
    : ex; imagine that the letters are a digit in your number ::
    :
    : abcd = a* 10^3 + b* 10^2 + c* 10^1+ d* 10^0
    :
    : after converting the two number you just have to use it normal ,
    : for separat the digits use the "and" and "shr"
    :
    : shame on you :(
    :
    :
    :
    :

    Not quite sure about the 8086, but I know pentiums will do packed bcd math with a single instruction. You might want to look at that.
  • : I want 8086 assembly language program to find any given sub-string in a string. And also I want 8086 assembly language program that multiplies
    : two four digit packed BCD numbers.
    :
    :
    :

    Here is a NASM source which should work (don't know how to write it in MASM 'cause I never used it):

    [code]
    FindSubstr:

    ; Finds substring at DS:SI in string ES:DI
    ; Returns CX = position in string or FFFF if not found

    push bx
    push bp
    mov bx,di
    mov dx,si
    mov bp,di
    push di
    .l1:
    cmp Byte [si],0 ; end of substring reached?
    je .Found
    cmp Byte [es:di],0 ; end of searched string?
    je .NotFound
    cmpsb
    je .l1 ; compare until not equal
    inc bp
    mov di,bp ; go forward one byte
    mov si,dx ; reset substring pointer to start
    jmp .l1
    .Found:
    mov cx,di
    pop di
    sub cx,di
    pop bp
    pop bx
    ret
    .NotFound:
    add sp,2
    pop bp
    pop bx
    mov cx,0ffffh
    ret
    [/code]

    HTH.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories