برای مشاهده مفیدترین ارسال در این موضوع اینجا کلیک کنید

نمایش نتایج: از شماره 1 تا 1 از مجموع 1
Like Tree7نفر پسندیدند
  • 4 ارسال توسط Hossein

موضوع: ماشین حساب در اسمبلی ( تحت داس - گرافیکی - متنی )

  1. #1
    بنیانگذار
    تاریخ عضویت
    2010 January
    محل سکونت
    زیر سایه خدا
    سن
    37
    ارسال ها
    1,308
    تشکر
    2,923
    تشکر شده 2,205 بار در 886 پست
    نوشته های وبلاگ
    37


    1 امتياز مثبت از 1 راي
    آيا اين پست براي شما سودمند بود؟ بله | خیر

    ماشین حساب در اسمبلی ( تحت داس - گرافیکی - متنی )

    سلام .
    چون اخیرا خیلی سوال شده بود و دوستان زیادی دنبال ماشین حساب بودن من علاوه بر پروژه هایی که دوستان از ترم های قبل گذاشتن اینا رو هم قرار میدم تا انشاالله مورد استفاده قرار بگیره و مفید واقع بشه . (انشاالله بعد از کنکور سورسهای بیشتری از اسمبلی تو بخش کتابخونه انجمن قرار میگیره که دوستان بتونن استفاده کنن . )
    چند تا ماشین حساب اینجا معرفی میکنم . یکی گرافیکی هست و دوتای دیگه معمولی .



    ابتدا سورس کد کامل این برنامه ها رو میزارم و در انتها هم سورس کدها رو ضمیمه کردم .
    شبیه ساز emu8086 4.08 و فایلهای Masm و Link هم ضمیمه شدن که میتونید دنلود کنید . (برای یادگرفتن کار با Masm میتونید اینجا رو بخونید : نحوه کامپایل و ساخت فایل اجرایی از سورس کد های اسمبلی )

    برنامه اول ماشین حساب گرافیکی تحت داس : ( تست شده و اجرا شده در emu8086 )

    توضیحات این برنامه



    ;in the name of GOD
    ;a Dos based graphical calculator in assembly
    ;ustmb.ir
    ;author: unknown
    ;---------------------------------------------------
    ;---------------------------------------------------
    ;------------------ M A C R O S -------------------
    ;---------------------------------------------------
    ;---------------------------------------------------
    push_all macro ;push all mnacros
    push ax
    push bx
    push cx
    push dx
    push si
    endm
    ;---------------------------------------------------
    pop_all macro ;pop all macros
    pop si
    pop dx
    pop cx
    pop bx
    pop ax
    endm
    ;---------------------------------------------------
    gotoxy macro x,y ;move cursor
    push_all
    mov dl,x
    mov dh,y
    mov bx,0
    mov ah,02h
    int 10h
    pop_all
    endm
    ;---------------------------------------------------
    putstr macro buffer ;print string
    push_all
    mov ah,09h
    mov dx,offset buffer
    int 21h
    pop_all
    endm
    ;---------------------------------------------------
    putch macro char,color ;print character
    push_all
    mov ah,09h
    mov al,char
    mov bh,0
    mov bl,color
    mov cx,1
    int 10h
    pop_all
    endm
    ;---------------------------------------------------
    clear macro buf
    lea si,buf
    mov [si],' '
    mov [si+1],' '
    mov [si+2],' '
    mov [si+3],' '
    mov [si+4],' '
    gotoxy 16,3
    putstr buf
    endm
    ;---------------------------------------------------
    initmouse macro
    mov ax,0
    int 33h
    endm
    ;---------------------------------------------------
    getmouse macro key

    local l1,en,en1,en2
    local r1,c11,c12,c13,c14,c15
    local r2,c21,c22,c23,c24
    local r3,c31,c32,c33,c34
    local r4,c41,c42,c43,c44

    push_all ;push all registers
    l1:
    mov ax,1 ;show mouse
    int 33h
    mov ax,3 ;get pose
    int 33h
    cmp bx,1
    jne l1

    ;....................
    r1:
    cmp cx,064h
    jna r2
    cmp cx,074h
    ja r2

    c11:
    cmp dx,14h
    jb c12
    cmp dx,24h
    ja c12
    mov [key],'E'
    jmp en1
    c12:
    cmp dx,2ch
    jb c13
    cmp dx,3ch
    ja c13
    mov [key],'7'
    jmp en1
    c13:
    cmp dx,44h
    jb c14
    cmp dx,54h
    ja c14
    mov [key],'4'
    jmp en1
    c14:
    cmp dx,5ch
    jb c15
    cmp dx,6ch
    ja c15
    mov [key],'1'
    jmp en1
    c15:
    cmp dx,74h
    jb r2
    cmp dx,84h
    ja r2
    mov [key],'C'
    jmp en1

    ;....................
    r2:
    cmp cx,084h
    jb r3
    cmp cx,094h
    ja r3

    c21:
    cmp dx,2ch
    jb c22
    cmp dx,3ch
    ja c22
    mov [key],'8'
    jmp en1
    c22:
    cmp dx,44h
    jb c23
    cmp dx,54h
    ja c23
    mov [key],'5'
    jmp en1
    c23:
    cmp dx,5ch
    jb c24
    cmp dx,6ch
    ja c24
    mov [key],'2'
    jmp en1
    c24:
    cmp dx,74h
    jb r3
    cmp dx,84h
    ja r3
    mov [key],'0'
    jmp en1

    ;....................
    r3:
    cmp cx,0a4h
    jb r4
    cmp cx,0b4h
    ja r4

    c31:
    cmp dx,2ch
    jb c32
    cmp dx,3ch
    ja c32
    mov [key],'9'
    jmp en1
    c32:
    cmp dx,44h
    jb c33
    cmp dx,54h
    ja c33
    mov [key],'6'
    jmp en1
    c33:
    cmp dx,5ch
    jb c34
    cmp dx,6ch
    ja c34
    mov [key],'3'
    jmp en1
    c34:
    cmp dx,74h
    jb r4
    cmp dx,84h
    ja r4
    mov [key],'='
    jmp en1

    ;.....................
    r4:
    cmp cx,0c4h
    jb en
    cmp cx,0d4h
    ja en

    c41:
    cmp dx,2ch
    jb c42
    cmp dx,3ch
    ja c42
    mov [key],'/'
    jmp en1
    c42:
    cmp dx,44h
    jb c43
    cmp dx,54h
    ja c43
    mov [key],'*'
    jmp en1
    c43:
    cmp dx,5ch
    jb c44
    cmp dx,6ch
    ja c44
    mov [key],'-'
    jmp en1
    c44:
    cmp dx,74h
    jb en
    cmp dx,84h
    ja en
    mov [key],'+'
    jmp en1

    ;.....................
    en:
    mov [key],'=' ;no match found!
    en1:
    cmp key,'E'
    je exit
    cmp key,'C'
    jne en2
    mov of,0
    mov xsighn,0
    jmp begin
    en2:
    pop_all ;popall registers

    endm
    ;---------------------------------------------------
    wait_for_key macro k
    local w0,w1,w2,w3

    initmouse
    getmouse k

    mov al,k
    cmp al,'-'
    jne w0
    mov operand1,'-'
    jmp w3
    w0:cmp al,'+'
    jne w1
    mov operand1,'+'
    jmp w3
    w1:cmp al,'*'
    jne w2
    mov operand1,'*'
    jmp w3
    w2:cmp al,'/'
    jne w3
    mov operand1,'/'
    w3:mov [k],al

    endm
    ;---------------------------------------------------
    number_in macro n,operand,lenth
    local l1,l1_2,l1_2_1,l1_3
    local l2,l3,l4

    push_all


    ;.........................
    mov lenth,0 ;wait for first key
    lea si,buffer ; maybe first key
    wait_for_key key ;willbe a mark
    jmp l1_2


    ;........................
    l1:
    initmouse
    getmouse key

    l1_2:
    cmp lenth,0 ;first time,clear screen
    jne l1_2_1
    clear buffer
    putstr buffer
    gotoxy 16,3
    l1_2_1:
    mov al,key ;check if its number
    cmp al,48
    jb l2
    cmp al,58
    ja l2

    l1_3:
    mov [si],al
    push_all

    mov ah,02h
    mov dx,[si]
    int 21h

    inc si
    inc lenth
    cmp lenth,6 ;just resive 5 digits + 1 operand
    jne l1
    ;........................
    l2: ;converting to integer
    mov dx,0
    cmp lenth,0
    je l4
    mov operand,al ;get operand
    lea si,buffer
    mov cx,lenth
    mov bx,10
    l3: ;make number
    mov ax,dx
    mul bx
    mov dx,ax
    mov ah,0
    mov al,[si]
    sub al,48
    add dx,ax
    inc si
    loop l3


    ;........................
    l4:
    mov n,dx
    gotoxy 24,3
    pop_all

    endm
    ;---------------------------------------------------
    putrez macro buffer,x
    local next_digit,pz1,pz2

    push_all
    mov ax,x ;convert <int> to <str>
    clear buffer
    lea si,buffer
    mov bx,10

    ;........................
    next_digit: ;seprate digits into
    mov dx,0 ; buffer
    div bx
    add dl,48
    mov [si+4],dl
    dec si
    cmp ax,0
    jne next_digit

    ;.........................
    gotoxy 16,3 ;print buffer
    putstr buffer

    cmp of,1 ;print owerflow mark
    jne pz1
    gotoxy 24,3
    putch 'F',12
    jmp pz2 ;print xsighn
    pz1:
    cmp xsighn,1
    jne pz2
    gotoxy 23,3
    putch '-',12
    pz2:
    pop_all

    endm
    ;---------------------------------------------------
    reset macro
    mov x,0
    mov y,0
    mov xsighn,0
    mov of,0
    clear buffer
    mov key,0
    mov operand1,0
    endm
    ;---------------------------------------------------
    ;---------------------------------------------------
    ;--------- D A T A -------- S E G M E N T-----------
    ;---------------------------------------------------
    ;---------------------------------------------------
    data segment
    ; add your data here!


    ;vars
    ;---------------------------------------------------
    x dw 0
    y dw 0
    buffer db 5 dup(0),'$'
    lenth dw 0
    operand1 db 0
    operand2 db 0
    key db 0
    of db 0
    ng db 0
    xsighn db 0
    ysighn db 0
    ;---------------------------------------------------


    ;print lines
    ;---------------------------------------------------
    l0 db 218,17 dup(196),191,'$'
    l1 db 179,' ',201,205,187,201,10 dup(205),187,' ',179,'$'
    l2 db 179,' ',186,' ',186,186,10 dup(' '),186,' ',179,'$'
    l3 db 179,' ',200,205,188,200,10 dup(205),188,' ',179,'$'
    l4 db 179,' ',218,196,191,' ',218,196,191,' ',218,196,191,' ',218,196,191,' ',179,'$'
    l5 db 179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,' ',179,'$'
    l6 db 179,' ',192,196,217,' ',192,196,217,' ',192,196,217,' ',192,196,217,' ',179,'$'
    l7 db 192,17 dup(196),217,'$'
    ;---------------------------------------------------


    ends
    ;---------------------------------------------------
    ;---------------------------------------------------
    ;--------- S T A C K S E G M E N T --------------
    ;---------------------------------------------------
    ;---------------------------------------------------

    stack segment
    dw 128 dup(0)
    ends

    code segment
    start:
    ; set segment registers:
    mov ax, data
    mov ds, ax
    mov es, ax

    ;--------------------------------------------------
    ;--------------------------------------------------
    ;--- C A L C U L A T O R E -------- P R O C ------
    ;--------------------------------------------------
    ;--------------------------------------------------


    call print_screen

    begin:
    reset
    calc1:
    putrez buffer,x ;print x
    number_in x,operand1,lenth
    mov al,operand1
    cmp al,'='
    je calc1
    calc2:
    number_in y,operand2,lenth
    call calculate ;x = x (operand1) y
    mov al,operand2
    cmp al,'='
    je calc1 ;if(operand2=='='):printx,start again.
    mov operand1,al ;else:operand1=operand2,printx,get buffer again.
    putrez buffer,x
    jmp calc2

    ;--------------------------------------------------
    ;--------------------------------------------------
    ;------------- F U N C T I O N S -----------------
    ;--------------------------------------------------
    ;--------------------------------------------------

    print_screen proc :


    gotoxy 10,1;...........
    putstr l0 ;
    gotoxy 10,2;........ ;
    putstr l1 ; ;
    gotoxy 10,3 ; ;out cadr
    putstr l2 ; ;
    gotoxy 10,4 ; ;
    putstr l3 ; ;
    gotoxy 10,5;...... ; ;
    putstr l4 ; ;rezualt board + exit key
    gotoxy 10,6 ; ; ;
    putstr l5 ; ; ;
    gotoxy 10,7 ; ; ;
    putstr l6 ; ; ;
    gotoxy 10,8 ; ; ;
    putstr l4 ; ; ;
    gotoxy 10,9 ;key board
    putstr l5 ; ; ;
    gotoxy 10,10 ; ; ;
    putstr l6 ; ; ;
    gotoxy 10,11 ; ; ;
    putstr l4 ; ; ;
    gotoxy 10,12 ; ; ;
    putstr l5 ; ; ;
    gotoxy 10,13 ; ; ;
    putstr l6 ; ; ;
    gotoxy 10,14 ; ; ;
    putstr l4 ; ; ;
    gotoxy 10,15;..... ; ;
    putstr l5 ; ;
    gotoxy 10,16;....... ;
    putstr l6 ;
    gotoxy 10,17;..........
    putstr l7

    ;keyboard lables
    gotoxy 13,3
    putch 'E',12
    gotoxy 13,6
    putch '7',9
    gotoxy 17,6
    putch '8',9
    gotoxy 21,6
    putch '9',9
    gotoxy 25,6
    putch '/',12
    gotoxy 13,9
    putch '4',9
    gotoxy 17,9
    putch '5',9
    gotoxy 21,9
    putch '6',9
    gotoxy 25,9
    putch '*',12
    gotoxy 13,12
    putch '1',9
    gotoxy 17,12
    putch '2',9
    gotoxy 21,12
    putch '3',9
    gotoxy 25,12
    putch '-',12
    gotoxy 13,15
    putch 'C',12
    gotoxy 17,15
    putch '0',9
    gotoxy 21,15
    putch '=',12
    gotoxy 25,15
    putch '+',12

    ret
    print_screen endp
    ;--------------------------------------------------

    calculate proc near


    cmp operand1,'+'
    je pluss
    cmp operand1,'-'
    je mines
    cmp operand1,'*'
    je mulplus
    cmp operand1,'/'
    je devide
    jmp begin ;no match found!



    ;...........................
    pluss:
    mov al,xsighn
    cmp al,0
    je pl1 ;x>0 & y>0
    jne pl2 ;x<0 & y>0
    pl1:
    mov ax,x
    add ax,y
    jno pl1_1
    mov of,1
    pl1_1:
    mov x,ax
    ret
    pl2:
    mov ax,x
    cmp ax,y
    jae pl3
    jb pl4
    pl3:
    mov ax,x
    sub ax,y
    mov x,ax
    ret
    pl4:
    mov ax,y
    sub ax,x
    mov x,ax
    mov xsighn,0
    ret

    ;...........................
    mines:
    mov al,xsighn
    cmp al,ysighn
    je mi1 ;x>0 & y>0
    jne mi2 ;x<0 & y>0
    mi1:
    mov ax,x
    cmp ax,y
    jae mi3
    jb mi4
    mi3:
    mov ax,x
    sub ax,y
    mov x,ax
    mov xsighn,0
    ret
    mi4:
    mov ax,y
    sub ax,x
    mov x,ax
    mov xsighn,1
    ret
    mi2:
    mov ax,x
    add ax,y
    jno mi5
    mov of,1
    mi5:
    mov x,ax
    mov xsighn,1
    ret


    ;...........................
    mulplus:
    mov dx,0;.........
    mov ax,x ;
    cwd;.............;
    mov bx,y ;
    mul bx ;
    jno mu1 ;
    mov of,1 ;
    mu1: ;
    add ax,dx;....
    mov x,ax
    mov al,xsighn
    cmp al,ysighn
    je mu2
    jne mu3
    mu2:
    mov xsighn,0
    ret
    mu3:
    mov xsighn,1
    ret
    ;...........................
    devide:
    mov ax,x
    cwd
    mov bx,y
    div bx
    mov x,ax

    mov al,xsighn
    cmp al,ysighn
    jne de1
    mov xsighn,0
    ret
    de1:
    mov xsighn,1
    ret
    ;...........................

    calculate endp
    ;---------------------------------------------------


    exit:

    mov ax, 4c00h ; exit to operating system.
    int 21h
    ends

    end start ; set entry point and stop the assembler.



    برنامه دوم : ماشین حساب ساده که عمل جمع - کم - ضرب و تقسیم رو انجام میده . ( تست و اجرا شده در emu8086 )



    ; command prompt based simple calculator (+,-,*,/) for 8086.
    ; example of calculation:
    ; input 1 <- number: 10
    ; input 2 <- operator: -
    ; input 3 <- number: 5
    ; -------------------
    ; 10 - 5 = 5
    ; output -> number: 5





    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; this maro is copied from emu8086.inc ;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ; this macro prints a char in AL and advances
    ; the current cursor position:
    PUTC MACRO char
    PUSH AX
    MOV AL, char
    MOV AH, 0Eh
    INT 10h
    POP AX
    ENDM
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;





    org 100h

    jmp start


    ; define variables:

    msg0 db "note: calculator works with integer values only.",0Dh,0Ah
    db "to learn how to output the result of a float division see float.asm in examples",0Dh,0Ah,'$'
    msg1 db 0Dh,0Ah, 0Dh,0Ah, 'enter first number: $'
    msg2 db "enter the operator: + - * / : $"
    msg3 db "enter second number: $"
    msg4 db 0dh,0ah , 'the approximate result of my calculations is : $'
    msg5 db 0dh,0ah ,'thank you for using the calculator! press any key... ', 0Dh,0Ah, '$'
    err1 db "wrong operator!", 0Dh,0Ah , '$'
    smth db " and something.... $"

    ; operator can be: '+','-','*','/' or 'q' to exit in the middle.
    opr db '?'

    ; first and second number:
    num1 dw ?
    num2 dw ?


    start:
    mov dx, offset msg0
    mov ah, 9
    int 21h


    lea dx, msg1
    mov ah, 09h ; output string at ds:dx
    int 21h


    ; get the multi-digit signed number
    ; from the keyboard, and store
    ; the result in cx register:

    call scan_num

    ; store first number:
    mov num1, cx



    ; new line:
    putc 0Dh
    putc 0Ah




    lea dx, msg2
    mov ah, 09h ; output string at ds:dx
    int 21h


    ; get operator:
    mov ah, 1 ; single char input to AL.
    int 21h
    mov opr, al



    ; new line:
    putc 0Dh
    putc 0Ah


    cmp opr, 'q' ; q - exit in the middle.
    je exit

    cmp opr, '*'
    jb wrong_opr
    cmp opr, '/'
    ja wrong_opr






    ; output of a string at ds:dx
    lea dx, msg3
    mov ah, 09h
    int 21h


    ; get the multi-digit signed number
    ; from the keyboard, and store
    ; the result in cx register:

    call scan_num


    ; store second number:
    mov num2, cx




    lea dx, msg4
    mov ah, 09h ; output string at ds:dx
    int 21h




    ; calculate:





    cmp opr, '+'
    je do_plus

    cmp opr, '-'
    je do_minus

    cmp opr, '*'
    je do_mult

    cmp opr, '/'
    je do_div


    ; none of the above....
    wrong_opr:
    lea dx, err1
    mov ah, 09h ; output string at ds:dx
    int 21h


    exit:
    ; output of a string at ds:dx
    lea dx, msg5
    mov ah, 09h
    int 21h


    ; wait for any key...
    mov ah, 0
    int 16h


    ret ; return back to os.











    do_plus:


    mov ax, num1
    add ax, num2
    call print_num ; print ax value.

    jmp exit



    do_minus:

    mov ax, num1
    sub ax, num2
    call print_num ; print ax value.

    jmp exit




    do_mult:

    mov ax, num1
    imul num2 ; (dx ax) = ax * num2.
    call print_num ; print ax value.
    ; dx is ignored (calc works with tiny numbers only).

    jmp exit




    do_div:
    ; dx is ignored (calc works with tiny integer numbers only).
    mov dx, 0
    mov ax, num1
    idiv num2 ; ax = (dx ax) / num2.
    cmp dx, 0
    jnz approx
    call print_num ; print ax value.
    jmp exit
    approx:
    call print_num ; print ax value.
    lea dx, smth
    mov ah, 09h ; output string at ds:dx
    int 21h
    jmp exit









    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
    ;;; these functions are copied from emu8086.inc ;;;
    ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


    ; gets the multi-digit SIGNED number from the keyboard,
    ; and stores the result in CX register:
    SCAN_NUM PROC NEAR
    PUSH DX
    PUSH AX
    PUSH SI

    MOV CX, 0

    ; reset flag:
    MOV CS:make_minus, 0

    next_digit:

    ; get char from keyboard
    ; into AL:
    MOV AH, 00h
    INT 16h
    ; and print it:
    MOV AH, 0Eh
    INT 10h

    ; check for MINUS:
    CMP AL, '-'
    JE set_minus

    ; check for ENTER key:
    CMP AL, 0Dh ; carriage return?
    JNE not_cr
    JMP stop_input
    not_cr:


    CMP AL, 8 ; 'BACKSPACE' pressed?
    JNE backspace_checked
    MOV DX, 0 ; remove last digit by
    MOV AX, CX ; division:
    DIV CS:ten ; AX = DX:AX / 10 (DX-rem).
    MOV CX, AX
    PUTC ' ' ; clear position.
    PUTC 8 ; backspace again.
    JMP next_digit
    backspace_checked:


    ; allow only digits:
    CMP AL, '0'
    JAE ok_AE_0
    JMP remove_not_digit
    ok_AE_0:
    CMP AL, '9'
    JBE ok_digit
    remove_not_digit:
    PUTC 8 ; backspace.
    PUTC ' ' ; clear last entered not digit.
    PUTC 8 ; backspace again.
    JMP next_digit ; wait for next input.
    ok_digit:


    ; multiply CX by 10 (first time the result is zero)
    PUSH AX
    MOV AX, CX
    MUL CS:ten ; DX:AX = AX*10
    MOV CX, AX
    POP AX

    ; check if the number is too big
    ; (result should be 16 bits)
    CMP DX, 0
    JNE too_big

    ; convert from ASCII code:
    SUB AL, 30h

    ; add AL to CX:
    MOV AH, 0
    MOV DX, CX ; backup, in case the result will be too big.
    ADD CX, AX
    JC too_big2 ; jump if the number is too big.

    JMP next_digit

    set_minus:
    MOV CS:make_minus, 1
    JMP next_digit

    too_big2:
    MOV CX, DX ; restore the backuped value before add.
    MOV DX, 0 ; DX was zero before backup!
    too_big:
    MOV AX, CX
    DIV CS:ten ; reverse last DX:AX = AX*10, make AX = DX:AX / 10
    MOV CX, AX
    PUTC 8 ; backspace.
    PUTC ' ' ; clear last entered digit.
    PUTC 8 ; backspace again.
    JMP next_digit ; wait for Enter/Backspace.


    stop_input:
    ; check flag:
    CMP CS:make_minus, 0
    JE not_minus
    NEG CX
    not_minus:

    POP SI
    POP AX
    POP DX
    RET
    make_minus DB ? ; used as a flag.
    SCAN_NUM ENDP





    ; this procedure prints number in AX,
    ; used with PRINT_NUM_UNS to print signed numbers:
    PRINT_NUM PROC NEAR
    PUSH DX
    PUSH AX

    CMP AX, 0
    JNZ not_zero

    PUTC '0'
    JMP printed

    not_zero:
    ; the check SIGN of AX,
    ; make absolute if it's negative:
    CMP AX, 0
    JNS positive
    NEG AX

    PUTC '-'

    positive:
    CALL PRINT_NUM_UNS
    printed:
    POP AX
    POP DX
    RET
    PRINT_NUM ENDP



    ; this procedure prints out an unsigned
    ; number in AX (not just a single digit)
    ; allowed values are from 0 to 65535 (FFFF)
    PRINT_NUM_UNS PROC NEAR
    PUSH AX
    PUSH BX
    PUSH CX
    PUSH DX

    ; flag to prevent printing zeros before number:
    MOV CX, 1

    ; (result of "/ 10000" is always less or equal to 9).
    MOV BX, 10000 ; 2710h - divider.

    ; AX is zero?
    CMP AX, 0
    JZ print_zero

    begin_print:

    ; check divider (if zero go to end_print):
    CMP BX,0
    JZ end_print

    ; avoid printing zeros before number:
    CMP CX, 0
    JE calc
    ; if AX<BX then result of DIV will be zero:
    CMP AX, BX
    JB skip
    calc:
    MOV CX, 0 ; set flag.

    MOV DX, 0
    DIV BX ; AX = DX:AX / BX (DX=remainder).

    ; print last digit
    ; AH is always ZERO, so it's ignored
    ADD AL, 30h ; convert to ASCII code.
    PUTC AL


    MOV AX, DX ; get remainder from last div.

    skip:
    ; calculate BX=BX/10
    PUSH AX
    MOV DX, 0
    MOV AX, BX
    DIV CS:ten ; AX = DX:AX / 10 (DX=remainder).
    MOV BX, AX
    POP AX

    JMP begin_print

    print_zero:
    PUTC '0'

    end_print:

    POP DX
    POP CX
    POP BX
    POP AX
    RET
    PRINT_NUM_UNS ENDP



    ten DW 10 ; used as multiplier/divider by SCAN_NUM & PRINT_NUM_UNS.







    GET_STRING PROC NEAR
    PUSH AX
    PUSH CX
    PUSH DI
    PUSH DX

    MOV CX, 0 ; char counter.

    CMP DX, 1 ; buffer too small?
    JBE empty_buffer ;

    DEC DX ; reserve space for last zero.


    ;============================
    ; Eternal loop to get
    ; and processes key presses:

    wait_for_key:

    MOV AH, 0 ; get pressed key.
    INT 16h

    CMP AL, 0Dh ; 'RETURN' pressed?
    JZ exit_GET_STRING


    CMP AL, 8 ; 'BACKSPACE' pressed?
    JNE add_to_buffer
    JCXZ wait_for_key ; nothing to remove!
    DEC CX
    DEC DI
    PUTC 8 ; backspace.
    PUTC ' ' ; clear position.
    PUTC 8 ; backspace again.
    JMP wait_for_key

    add_to_buffer:

    CMP CX, DX ; buffer is full?
    JAE wait_for_key ; if so wait for 'BACKSPACE' or 'RETURN'...

    MOV [DI], AL
    INC DI
    INC CX

    ; print the key:
    MOV AH, 0Eh
    INT 10h

    JMP wait_for_key
    ;============================

    exit_GET_STRING:

    ; terminate by null:
    MOV [DI], 0

    empty_buffer:

    POP DX
    POP DI
    POP CX
    POP AX
    RET
    GET_STRING ENDP






    برنامه سوم : ماشین حساب تحت داس معمولی : ( تست شده و اجرا شده در Masm )


    ;THIS PROGRAM DISPLAY MENU AND ADD, SUBTRACT, MULTIPLY, DIVIDE TOW NUMBERS

    ;--------------------------------------------------------------------------------------;
    ; ;
    ; PRODUCT BY BAHMAN AKBARZADEH ;
    ; ;
    ;--------------------------------------------------------------------------------------;


    STACK SEGMENT PARA STACK 'STACK'
    DB 64 DUP(?)
    STACK ENDS
    ;**************************************14 ;DATA SEGMENT
    DATA SEGMENT PARA 'DATA'
    ORG 50H
    UP DB 0C9H, 16 DUP(0CDH), 0BBH, '$'
    L1 DB 0BAH, ' ADDITION ', 0BAH, '$'
    L2 DB 0CCH, 16 DUP(0CDH), 0B9H, '$'
    L3 DB 0BAH, ' SUBTRACTION ', 0BAH, '$'
    L4 DB 0CCH, 16 DUP(0CDH), 0B9H, '$'
    L5 DB 0BAH, ' MULTIPLICATION ', 0BAH, '$'
    L6 DB 0CCH, 16 DUP(0CDH), 0B9H, '$'
    L7 DB 0BAH, ' DIVISION ', 0BAH, '$'
    L8 DB 0CCH, 16 DUP(0CDH), 0B9H, '$'
    L9 DB 0BAH, ' EXIT ', 0BAH, '$'
    DOWN DB 0C8H, 16 DUP(0CDH), 0BCH, '$'
    PRO DB ':::::::::: PRODUCT BY BAHMAN AKBARZADEH ::::::::::$'
    MSG DB ' TO SELECT AN ITEM, USE <UP / DOWN ARROW> AND PRESS < ENTER >.$'
    MSG1 DB 'ENTER NUMBER 1: $'
    MSG2 DB 'ENTER NUMBER 2: $'
    RADD DB 'RESULT OF ADDITION IS : $'
    RSUB DB 'RESULT OF SUBTRACTION IS : $'
    RMUL DB 'RESULT OF MULTIPLICATION IS : $'
    RDIV DB 'RESULT OF DIVISION IS : $'
    STRDATA1 LABEL BYTE
    MAX1 DB 5
    LEN1 DB ?
    DATA1 DB 5 DUP(?)
    STRDATA2 LABEL BYTE
    MAX2 DB 5
    LEN2 DB ?
    DATA2 DB 5 DUP(?)
    DATA3 DD ?
    NUMBER1 DB 2 DUP(?)
    NUMBER2 DB 2 DUP(?)
    RESULT DW 10 DUP(0)
    STRRESULT DB 40 DUP(5)
    DATA ENDS
    ;****************************************50 ;CODE SEGMENT
    CODE SEGMENT PARA 'CODE'
    ASSUME CS:CODE,DS:DATA,SS:STACK
    MAIN PROC FAR
    MOV AX,DATA
    MOV DS,AX
    ;****************************************56 ;DISPLAY MENU
    MOV CX,0111H
    MOV DX,0220H
    CALL DISPLAY
    ;****************************************60 ;PRINT MSG1
    MOV AH,09H
    LEA DX,MSG1
    INT 21H
    ;****************************************64 ;GIVE DATA1
    MOV AH,0AH
    LEA DX,STRDATA1
    INT 21H
    ;*****************************************68 ;LOCATION OF MOUSE
    MOV DX,0F10H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;****************************************73 ;PRINT MSG2
    MOV AH,09H
    LEA DX,MSG2
    INT 21H
    ;****************************************77 ;GIVE DATA2
    MOV AH,0AH
    LEA DX,STRDATA2
    INT 21H
    ;*****************************************81 ;DATA1(ASCII) TO DATA3(HEX)
    MOV SI,0H
    START: MOV AH,[OFFSET DATA1+SI]
    CMP AH,39H
    JL X1
    SUB AH,7H
    X1: AND AH,0FH
    MOV [OFFSET DATA3+SI],AH
    INC SI
    CMP SI,4
    JNE START
    ;*****************************************92 ;4 BYTE OF DATA3 TO 2 BYTE OF NUMBER1
    LEA SI,DATA3
    MOV AH,[SI]
    MOV BH,[SI+1]
    MOV CL,4
    SHL AH,CL
    OR AH,BH
    MOV NUMBER1,AH

    MOV AH,[SI+2]
    MOV BH,[SI+3]
    MOV CL,4
    SHL AH,CL
    OR AH,BH
    MOV NUMBER1+1,AH
    ;*****************************************107 ;DATA2(ASCII) TO DATA3(HEX)
    MOV SI,0H
    START2: MOV AH,[OFFSET DATA2+SI]
    CMP AH,39H
    JL X2
    SUB AH,7H
    X2: AND AH,0FH
    MOV [OFFSET DATA3+SI],AH
    INC SI
    CMP SI,4
    JNE START2
    ;*****************************************118 ;4 BYTE OF DATA3 TO 2 BYTE OF NUMBER2
    LEA SI,DATA3
    MOV AH,[SI]
    MOV BH,[SI+1]
    MOV CL,4
    SHL AH,CL
    OR AH,BH
    MOV NUMBER2,AH

    MOV AH,[SI+2]
    MOV BH,[SI+3]
    MOV CL,4
    SHL AH,CL
    OR AH,BH
    MOV NUMBER2+1,AH
    ;*****************************************133 ;PRIMARY PART
    MOV CX,0111H
    MOV DX,0220H
    BACK: CALL DISPLAY
    ;*****************************************137 ;LOCATION OF MOUSE
    PUSH DX
    MOV DX,1008H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;****************************************143 ;PRINT MSG
    MOV AH,09H
    LEA DX,MSG
    INT 21H
    POP DX
    ;****************************************148 PRIMARY PART
    CALL INPUT
    CMP BH,0EH
    JNE BACK
    CMP CH,01H
    JNE Z1
    CALL ADDITION
    JMP BACK
    Z1: CMP CH,03H
    JNE Z2
    CALL SUBTRACTION
    JMP BACK
    Z2: CMP CH,05H
    JNE Z3
    CALL MULTIPLICATION
    JMP BACK
    Z3: CMP CH,07H
    JNE Z4
    CALL DIVISION
    JMP BACK
    ;*****************************************168 ;CLEAR SCREEN
    Z4: MOV AH,06H
    MOV BH,07H
    MOV CX,0H
    MOV DX,2579H
    MOV AL,0H
    INT 10H
    ;*****************************************175 ;LOCATION OF MOUSE
    MOV DX,0C0EH
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************180 ;END NAMEH
    LEA DX,PRO
    MOV AH,09H
    INT 21H
    ;*****************************************184 ;GETCH()
    MOV AH,01H
    INT 21H
    ;****************************************187 ;END
    MOV AH,4CH
    INT 21H
    MAIN ENDP

    ;/////////////////////////////////////////////////////////////////////////////////////

    ;THIS PART DISPLAY MENU WITH SELECTED ITEM
    ;THIS PART GIVE CX AND DX FOR LOCATION OF SELECTED ITEM

    DISPLAY PROC NEAR
    ;*****************************************198 ;PUSH SEGMENTS
    PUSH AX
    PUSH BX
    PUSH CX
    PUSH DX
    ;*****************************************203 ;CLEAR SCREEN
    MOV AH,06H
    MOV BH,07H
    MOV CX,0H
    MOV DX,2579H
    MOV AL,0H
    INT 10H
    ;*****************************************210 ;SELECTED ITEM
    MOV AH,06H
    MOV AL,1H
    MOV BH,70H
    POP DX
    POP CX
    INT 10H
    PUSH CX
    PUSH DX
    ;*****************************************219 ;LOCATION OF MOUSE
    MOV DX,0110H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************224
    MOV AH,09H
    LEA DX,UP
    INT 21H
    ;*****************************************228 ;LOCATION OF MOUSE
    MOV DX,0210H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************233
    MOV AH,09H
    LEA DX,L1
    INT 21H
    ;*****************************************237 ;LOCATION OF MOUSE
    MOV DX,0310H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************242
    MOV AH,09H
    LEA DX,L2
    INT 21H
    ;*****************************************246 ;LOCATION OF MOUSE
    MOV DX,0410H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************251
    MOV AH,09H
    LEA DX,L3
    INT 21H
    ;*****************************************255 ;LOCATION OF MOUSE
    MOV DX,0510H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************260
    MOV AH,09H
    LEA DX,L4
    INT 21H
    ;*****************************************264 ;LOCATION OF MOUSE
    MOV DX,0610H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************269
    MOV AH,09H
    LEA DX,L5
    INT 21H
    ;*****************************************273 ;LOCATION OF MOUSE
    MOV DX,0710H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************278
    MOV AH,09H
    LEA DX,L6
    INT 21H
    ;*****************************************282 ;LOCATION OF MOUSE
    MOV DX,0810H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************287
    MOV AH,09H
    LEA DX,L7
    INT 21H
    ;*****************************************291 ;LOCATION OF MOUSE
    MOV DX,0910H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************296
    MOV AH,09H
    LEA DX,L8
    INT 21H
    ;*****************************************300 ;LOCATION OF MOUSE
    MOV DX,0A10H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************305
    MOV AH,09H
    LEA DX,L9
    INT 21H
    ;*****************************************309 ;LOCATION OF MOUSE
    MOV DX,0B10H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************314
    MOV AH,09H
    LEA DX,DOWN
    INT 21H
    ;*****************************************318 ;LOCATION OF MOUSE
    MOV DX,0D10H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;*****************************************323 ;POP SEGMENTS
    POP DX
    POP CX
    POP BX
    POP AX
    ;*****************************************328 ;END OF DISPLAY MENU
    RET
    DISPLAY ENDP

    ;/////////////////////////////////////////////////////////////////////////////////////

    ;THIS PART GIVE SELECTED ITEM FROM KEYBORD
    ;TISH PART CHANGE CX AND DX FOR SELECTED ITEM

    INPUT PROC NEAR
    ;*****************************************338 ;PUSH SEGMENTS
    PUSH AX
    ;*****************************************340 ;GIVE KEY
    MOV AH,0H
    INT 16H
    ;*****************************************343 ;MOVE
    MOV BH,0H
    CMP AH,50H
    JNE NEXT
    CMP CH,09H
    JNE R1
    MOV CH,01H
    MOV DH,02H
    JMP END
    R1: ADD CH,2H
    ADD DH,2H
    NEXT: CMP AH,48H
    JNE NEXT2
    CMP CH,01H
    JNE R2
    MOV CH,09H
    MOV DH,0AH
    JMP END
    R2: SUB CH,2H
    SUB DH,2H
    NEXT2: CMP AL,0DH
    JNE END
    MOV BH,0EH
    ;*****************************************366 ;POP SEGMENTS
    END: POP AX
    ;*****************************************368
    RET
    INPUT ENDP

    ;/////////////////////////////////////////////////////////////////////////////////////

    ;THIS PART ADDS NUMBER1 AND NUMBER2 THEN PRINT RESULT

    ADDITION PROC NEAR
    ;*****************************************377 ;PUSH SEGMENTS
    PUSH AX
    PUSH BX
    PUSH CX
    PUSH DX
    PUSH SI
    PUSH DI
    ;*****************************************384 ;ADD NUMBER1 AND NUMBER2
    CLC
    MOV AH,NUMBER1
    MOV AL,NUMBER1+1
    MOV BH,NUMBER2
    MOV BL,NUMBER2+1
    ADD AX,BX
    MOV RESULT,AX
    MOV BX,0
    ADC BX,0
    MOV RESULT+2,BX
    ;*****************************************395 ;ASCII OF RESULT TO STRRESULT
    CALL ASCII
    ;*****************************************397 ;LOCATION OF MOUSE
    MOV DX,1210H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;****************************************402 ;PRINT RADD
    MOV AH,09H
    LEA DX,RADD
    INT 21H
    ;*****************************************406 ;PRINT STRRESULT
    MOV AH,02H
    MOV SI,5
    W5: MOV DL,[OFFSET STRRESULT+SI-1]
    INT 21H
    DEC SI
    CMP SI,0
    JNE W5
    MOV DL,' '
    INT 21H
    MOV DL,'H'
    INT 21H
    ;*****************************************418 ;GETCH()
    MOV AH,01H
    INT 21H
    ;*****************************************421 ;POP SEGMENTS
    POP DI
    POP SI
    POP DX
    POP CX
    POP BX
    POP AX
    ;*****************************************428
    RET
    ADDITION ENDP

    ;/////////////////////////////////////////////////////////////////////////////////////


    ;THIS PART SUBTRACT NUMBER1 AND NUMBER2 THEN PRINT RESULT

    SUBTRACTION PROC NEAR
    ;*****************************************438 ;PUSH SEGMENTS
    PUSH AX
    PUSH BX
    PUSH CX
    PUSH DX
    PUSH SI
    PUSH DI
    ;*****************************************445 ;SUBTRACT NUMBER2 OF NUMBER1
    MOV AH,NUMBER1
    MOV AL,NUMBER1+1
    MOV BH,NUMBER2
    MOV BL,NUMBER2+1
    SUB AX,BX
    MOV RESULT,AX
    MOV BH,0
    ADC BH,0
    CMP BH,1
    JNE W7
    MOV RESULT+2,0FH
    ;*****************************************457 ;ASCII OF RESULT TO STRRESULT
    W7: CALL ASCII
    ;*****************************************459 ;LOCATION OF MOUSE
    MOV DX,1210H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;****************************************464 ;PRINT RSUB
    MOV AH,09H
    LEA DX,RSUB
    INT 21H
    ;*****************************************468 ;PRINT STRRESULT
    MOV AH,02H
    MOV SI,5
    W6: MOV DL,[OFFSET STRRESULT+SI-1]
    INT 21H
    DEC SI
    CMP SI,0
    JNE W6
    MOV DL,' '
    INT 21H
    MOV DL,'H'
    INT 21H
    ;*****************************************480 ;GETCH()
    MOV AH,01H
    INT 21H
    ;*****************************************483 ;POP SEGMENTS
    POP DI
    POP SI
    POP DX
    POP CX
    POP BX
    POP AX
    ;*****************************************490
    RET
    SUBTRACTION ENDP

    ;/////////////////////////////////////////////////////////////////////////////////////


    ;THIS PART MULTIPLY NUMBER1 AND NUMBER2 THEN PRINT RESULT

    MULTIPLICATION PROC NEAR
    ;*****************************************500 ;PUSH SEGMENTS
    PUSH AX
    PUSH BX
    PUSH CX
    PUSH DX
    PUSH SI
    PUSH DI
    ;*****************************************507 ;MULTIPLY NUMBER1 IN NUMBER2
    MOV AH,0
    MOV BH,0
    MOV SI,2
    MOV DI,0
    MOV BL,[OFFSET NUMBER2+SI-1]
    AND BL,0FH
    W8: MOV DH,0
    MOV AL,NUMBER1+1
    AND AL,0FH
    MUL BL
    ADD AL,DH
    MOV DH,AL
    AND AL,0FH
    MOV [OFFSET STRRESULT+DI],AL
    MOV CL,4
    SHR DH,CL
    MOV AL,NUMBER1+1
    SHR AL,CL
    MUL BL
    ADD AL,DH
    MOV DH,AL
    AND AL,0FH
    INC DI
    MOV [OFFSET STRRESULT+DI],AL
    SHR DH,CL
    MOV AL,NUMBER1
    AND AL,0FH
    MUL BL
    ADD AL,DH
    MOV DH,AL
    AND AL,0FH
    INC DI
    MOV [OFFSET STRRESULT+DI],AL
    SHR DH,CL
    MOV AL,NUMBER1
    SHR AL,CL
    MUL BL
    ADD AL,DH
    MOV DH,AL
    AND AL,0FH
    INC DI
    MOV [OFFSET STRRESULT+DI],AL
    SHR DH,CL
    INC DI
    MOV [OFFSET STRRESULT+DI],DH
    CMP DI,14
    JE W9
    CMP DI,4
    JE W9
    DEC SI
    MOV BL,[OFFSET NUMBER2+SI-1]
    AND BL,0FH
    JMP W10
    W9: MOV BL,[OFFSET NUMBER2+SI-1]
    SHR BL,CL
    W10: INC DI
    CMP DI,20
    JNE W8
    ;*****************************************556 ;SUMMERY OF 4 NUMBERS INTO STRRESULT
    CLC
    MOV CL,4
    MOV DH,0
    MOV AH,STRRESULT+1
    ADD AH,STRRESULT+5;
    MOV DH,AH
    AND AH,0FH
    SHR DH,CL
    MOV STRRESULT+1,AH

    MOV AH,STRRESULT+2
    ADD AH,STRRESULT+6;
    ADD AH,STRRESULT+10;
    ADD AH,DH
    MOV DH,AH
    AND AH,0FH
    SHR DH,CL
    MOV STRRESULT+2,AH

    MOV AH,STRRESULT+3
    ADD AH,STRRESULT+7;
    ADD AH,STRRESULT+11;
    ADD AH,STRRESULT+15;
    ADD AH,DH
    MOV DH,AH
    AND AH,0FH
    SHR DH,CL
    MOV STRRESULT+3,AH

    MOV AH,STRRESULT+4
    ADD AH,STRRESULT+8;
    ADD AH,STRRESULT+12;
    ADD AH,STRRESULT+16;
    ADD AH,DH
    MOV DH,AH
    AND AH,0FH
    SHR DH,CL
    MOV STRRESULT+4,AH

    MOV AH,STRRESULT+9
    ADD AH,STRRESULT+13;
    ADD AH,STRRESULT+17;
    ADD AH,DH
    MOV DH,AH
    AND AH,0FH
    SHR DH,CL
    MOV STRRESULT+5,AH

    MOV AH,STRRESULT+14
    ADD AH,STRRESULT+18;
    ADD AH,DH
    MOV DH,AH
    AND AH,0FH
    SHR DH,CL
    MOV STRRESULT+6,AH

    MOV AH,STRRESULT+19
    ADD AH,DH
    MOV DH,AH
    AND AH,0FH
    SHR DH,CL
    MOV STRRESULT+7,AH
    ;*****************************************629 ;NUMBERS TO ASCII
    MOV SI,0
    W11: MOV AH,[OFFSET STRRESULT+SI]
    CMP AH,0AH
    JL W12
    ADD AH,7H
    W12: ADD AH,30H
    MOV [OFFSET STRRESULT+SI],AH
    INC SI
    CMP SI,8
    JNE W11
    ;*****************************************640 ;LOCATION OF MOUSE
    MOV DX,1210H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;****************************************645 ;PRINT RMUL
    MOV AH,09H
    LEA DX,RMUL
    INT 21H
    ;*****************************************649 ;PRINT STRRESULT
    MOV AH,02H
    MOV SI,8
    W13: MOV DL,[OFFSET STRRESULT+SI-1]
    INT 21H
    DEC SI
    CMP SI,0
    JNE W13
    MOV DL,' '
    INT 21H
    MOV DL,'H'
    INT 21H
    ;****************************************661 ;GETCH()
    MOV AH,01H
    INT 21H
    ;*****************************************664 ;POP SEGMENTS
    POP DI
    POP SI
    POP DX
    POP CX
    POP BX
    POP AX
    ;*****************************************671
    RET
    MULTIPLICATION ENDP

    ;/////////////////////////////////////////////////////////////////////////////////////


    ;THIS PART DIVIDE NUMBER1 AND NUMBER2 THEN PRINT RESULT

    DIVISION PROC NEAR
    ;*****************************************681 ;PUSH SEGMENTS
    PUSH AX
    PUSH BX
    PUSH CX
    PUSH DX
    PUSH SI
    PUSH DI
    ;*****************************************688 ;DIVIDE NUMBER1 ON NUMBER2
    MOV AH,NUMBER1
    MOV AL,NUMBER1+1
    MOV BH,NUMBER2
    MOV BL,NUMBER2+1
    DIV BX
    MOV RESULT,AX
    ;*****************************************695 ;ASCII OF RESULT TO STRRESULT
    CALL ASCII
    ;*****************************************697 ;LOCATION OF MOUSE
    MOV DX,1210H
    MOV BH,0H
    MOV AH,02H
    INT 10H
    ;****************************************702 ;PRINT RDIV
    MOV AH,09H
    LEA DX,RDIV
    INT 21H
    ;*****************************************706 ;PRINT STRRESULT
    MOV AH,02H
    MOV SI,4
    W14: MOV DL,[OFFSET STRRESULT+SI-1]
    INT 21H
    DEC SI
    CMP SI,0
    JNE W14
    MOV DL,' '
    INT 21H
    MOV DL,'H'
    INT 21H
    ;*****************************************718 ;GETCH()
    MOV AH,01H
    INT 21H
    ;*****************************************721 ;POP SEGMENTS
    POP DI
    POP SI
    POP DX
    POP CX
    POP BX
    POP AX
    ;*****************************************728
    RET
    DIVISION ENDP

    ;/////////////////////////////////////////////////////////////////////////////////////


    ;THIS PART CONVERT RESULT TO ASCII AND SAVE IT INTO STRRESULT

    ASCII PROC NEAR
    ;*****************************************738 ;PUSH SEGMENTS
    PUSH AX
    PUSH DX
    PUSH SI
    PUSH DI
    ;*****************************************743 ;NUMBERS OF RESULT TO ASSCII OF STRRESULT
    MOV DI,0
    MOV SI,0
    W2: MOV AL,[OFFSET RESULT+DI]
    MOV DL,AL
    AND AL,0FH
    MOV CL,4
    SHR DL,CL
    OR AL,30H
    CMP AL,3AH
    JB W3
    ADD AL,7
    W3: OR DL,30H
    CMP DL,3AH
    JB W4
    ADD DL,7
    W4: MOV AH,DL
    MOV [OFFSET STRRESULT+SI],AX
    INC DI
    ADD SI,2
    CMP DI,8
    JNE W2
    ;*****************************************765 ;POP SEGMENTS
    POP DI
    POP SI
    POP DX
    POP AX
    ;*****************************************770
    RET
    ASCII ENDP

    ;/////////////////////////////////////////////////////////////////////////////////////

    CODE ENDS
    END MAIN



    فایل های پیوست شده
    Shojaee, Farzad, Unicorn و 1 نفر دیگر این نویسه را می پسندند.
    توکل بخدا
    http://DeepLearning.ir
    اولین و تنها مرجع یادگیری عمیق ایران


    هرکس از ظن خود شد یار من
    از درون من نجست اسرار من




 

 

کاربران برچسب خورده در این موضوع

کلمات کلیدی این موضوع

علاقه مندی ها (Bookmarks)

علاقه مندی ها (Bookmarks)

مجوز های ارسال و ویرایش

  • شما نمیتوانید موضوع جدیدی ارسال کنید
  • شما امکان ارسال پاسخ را ندارید
  • شما نمیتوانید فایل پیوست کنید.
  • شما نمیتوانید پست های خود را ویرایش کنید
  •  


Powered by vBulletin
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.6.0
Persian Language By Ustmb.ir
این انجمن کاملا مستقل بوده و هیچ ارتباطی با دانشگاه علوم و فنون مازندران و مسئولان آن ندارد..این انجمن و تمامی محتوای تولید شده در آن توسط دانشجویان فعلی و فارغ التحصیل ادوار گذشته این دانشگاه برای استفاده دانشجویان جدید این دانشگاه و جامعه دانشگاهی کشور فراهم شده است.لطفا برای اطلاعات بیشتر در رابطه با ماهیت انجمن با مدیریت انجمن ارتباط برقرار کنید
ساعت 09:01 AM بر حسب GMT +4 می باشد.