haniemohammadi
دوشنبه 11 دی 1391, 18:49 عصر
سلام من یک برنامه دارم که میخواستم به آن یک دستور جامپ اضافه کنم برنامه ای که ابتدا باید به کاربر بگه از کدام مبنا میخواهی استفاده کنی درچهارعمل ضربو تقسیم و ضرب و جمع . ممنون میشم تا صبح جواب بدین
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
;Calculator
Calculator:
mov dx , offset Text1
mov ah , 9
int 21h
call getNumber
mov x , dx
cmp al , '+'
je num2
cmp al , '-'
je num2
cmp al , '*'
je num2
cmp al , '/'
je num2
mov ah , 1
int 21h
num2:
mov op , al
call getNumber
mov y , dx
cmp op , '+'
je Sum
cmp op , '-'
je Min
cmp op , '*'
je Ml
cmp op , '/'
je D
Sum:
mov ax , x
add ax , y
mov res , ax
jmp EndSwitch
Min:
mov ax , x
sub ax , y
mov res , ax
jmp EndSwitch
ML:
mov ax , x
mul y
jmp EndSwitch
D:
mov ax , x
mov dx , 0
div y
mov res , ax
EndSwitch:
call endl
call endl
mov dx , offset Text2
mov ah , 9
int 21h
mov dx , res
call printNumber
mov ah , 1
int 21h
call endl
call endl
jmp Calculator
lea dx, pkey
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.
start:
; set segment registers:
mov ax, data
mov ds, ax
mov es, ax
; add your code here
;Calculator
Calculator:
mov dx , offset Text1
mov ah , 9
int 21h
call getNumber
mov x , dx
cmp al , '+'
je num2
cmp al , '-'
je num2
cmp al , '*'
je num2
cmp al , '/'
je num2
mov ah , 1
int 21h
num2:
mov op , al
call getNumber
mov y , dx
cmp op , '+'
je Sum
cmp op , '-'
je Min
cmp op , '*'
je Ml
cmp op , '/'
je D
Sum:
mov ax , x
add ax , y
mov res , ax
jmp EndSwitch
Min:
mov ax , x
sub ax , y
mov res , ax
jmp EndSwitch
ML:
mov ax , x
mul y
jmp EndSwitch
D:
mov ax , x
mov dx , 0
div y
mov res , ax
EndSwitch:
call endl
call endl
mov dx , offset Text2
mov ah , 9
int 21h
mov dx , res
call printNumber
mov ah , 1
int 21h
call endl
call endl
jmp Calculator
lea dx, pkey
mov ah, 9
int 21h ; output string at ds:dx
; wait for any key....
mov ah, 1
int 21h
mov ax, 4c00h ; exit to operating system.
int 21h
ends
end start ; set entry point and stop the assembler.