Results 1 to 3 of 3

Thread: Assembly Program

  1. #1
    Contributing Member
    Join Date
    Apr 2007
    Answers
    41

    Assembly Program

    Hi,

    Can Anybody help me in writing a simple assembly program, like adding of two nos or assembly program for printf??


  2. #2
    Contributing Member
    Join Date
    Sep 2006
    Answers
    962

    Re: Assembly Program

    mov al, 5 ; bin=00000101b
    mov bl, 10 ; hex=0ah or bin=00001010b
    ; 5 + 10 = 15 (decimal) or hex=0fh or bin=00001111b
    add bl, al
    ; 15 - 1 = 14 (decimal) or hex=0eh or bin=00001110b
    sub bl, 1
    ; print result in binary:
    mov cx, 8
    print: mov ah, 2 ; print function.
    mov dl, '0'
    test bl, 10000000b ; test first bit.
    jz zero
    mov dl, '1'
    zero:int 21h
    shl bl, 1
    loop print
    ; print binary suffix:
    mov dl, 'b'
    int 21h
    ; wait for any key press:
    mov ah, 0
    int 16h

    ret


    The above one using for 8086 processor and if you want more detail for sample programs then go through the following URL...

    http://www.emu8086.com/dr/asm2html/a...r_source_code/


    ----------------------
    suresh

    Last edited by psuresh1982; 07-16-2007 at 07:27 AM.

  3. #3
    Junior Member
    Join Date
    Jul 2007
    Answers
    1

    Smile Re: Assembly Program

    Yes i , can i have many solved programs of assembly here is your program

    data segment
    num1 db 20h
    num2 db 18h
    res db ?
    data ends
    code segment
    assume cs:code, ds:data
    mov ax, data ;initialize data segment
    mov ds, ax mov al, num1 ;take first number in al
    add al, num2 ;add the second to the number
    mov res, al ;store the result in location res
    mov dl,res
    sub dl,30h
    mov ah,02h
    int 21h
    code ends
    mov ax, 4c00h ;exit to operating system
    int 21h


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Applying for a job can be a stressful and frustrating experience, especially for someone who has never done it before. Considering that you are competing for the position with a at least a dozen other applicants, it is imperative that you thoroughly prepare for the job interview, in order to stand a good chance of getting hired. That's where GeekInterview can help.
Interact