emu8086作为输入的过程并输出中断

时间:2015-03-23 17:41:04

标签: assembly x86-16

emu8086作为输入的过程并输出中断。 程序计算算术平均值。 期望提高程序的速度。 为什么使用程序程序要慢得多?

include 'emu8086.inc'


;srednee arifmiticheskoe
data segment  
    msg1 db '4islo ne vhodit v diapazon ot 1 do 30, povtorite vvod.'
    mas dw 30 DUP(?)
    razmernost dw ?
    s dw ?
    n dw ?

ends

stack segment
    dw   128  dup(0)
ends

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





xor ax, ax
xor si, si
xor cx,cx

vvod1:CALL   pthis
     DB  'The dimension of the array(ot 1 do 30):', 0
     call SCAN_NUM;zapros vvoda razmernost
     cmp cx,30
     JG OSHIBKA 
     cmp cx,0
     JNL  razm
    oshibka:   lea si,msg1
       call print_string
       call clear_screen
       jmp vvod1 
  razm:   mov razmernost,cx;pomes4enie x v peremennyiy x  


     xor si,si
     mov ax,0     

     vvod2:push cx 
     CALL   pthis
     Db  13, 10, 'ввод элемента массива number ', 0 
     CALL   print_num 
     Print ' : '
     call SCAN_NUM           
     mov mas[si], cx        
     add si, 2
     inc ax
     pop cx
     loop vvod2
     call clear_screen

xor ax, ax
xor si, si
mov cx, razmernost
@1:
add ax, mas[si]
add si, 2
inc n
loop @1
cwd
idiv n
mov s, ax


PRINT 'MAS = '
xor si, si 
mov cx, razmernost
@22:
xor ax, ax
add ax, mas[si]
add si, 2  
CALL   print_num  
Print ' '
loop @22 
gotoxy 0,1
PRINT 'average = ' 
Print ' '
mov ax, s
CALL   print_num 


DEFINE_SCAN_NUM
DEFINE_PRINT_STRING
DEFINE_PRINT_NUM
DEFINE_PRINT_NUM_UNS  
DEFINE_PTHIS
DEFINE_clear_screen


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

end start ; set entry point and stop the assembler.

1 个答案:

答案 0 :(得分:0)

你的代码很好,我只是运行它(实际上,它很快)。首先,EMU8086有一个速度控制,下一个图像显示在哪里:

enter image description here

另一方面,您可能正在运行EMU8086内的程序。唐'吨。找到程序的可执行文件并运行它,下一个图像显示它的位置:

enter image description here

您的可执行文件的名称类似于" my_program.exe _" (最后注意下划线)。将其重命名为" my_program.exe",并在DOS框或虚拟机中运行它,您将看到程序在EMU8086内运行时的速度有多快。

最后,我们可以怪你的电脑。你在用奶奶的电脑吗?