0
我想知道如何可以优化这个代码更多一点。现在他有467k和59条线。我如何优化此代码? [大会8086字母金字塔]
数据段:
code_char db 'A'
counter_space db 39
counter_char dw 1
counter_rows dw 25
程序段:
rows:
mov cl, counter_space ;here I write space
mov ah,02h
mov dl,''
space:
int 21h
loop space
mov cx, counter_char ;here I write letters
mov ah,02h
mov dl,code_char
letters:
int 21h
loop letters
mov ah,02h ;here I go to another line(enter)
mov dl,0ah
int 21h
INC code_char ;here I change the value of variable's
DEC counter_space
ADD counter_char,2
DEC counter_rows
mov cx,counter_rows ;here I count the rows to 25
loop rows
mov ah,01h ;here I w8 to any key
int 21h
mov ah,4ch
mov al,0
int 21h
如果您有任何建议,请发表评论。 我刚开始学习Assembly。
你的目标是优化速度或大小?你在用什么汇编语言?以及你用于汇编程序的命令行参数是什么?代码看起来像MS-DOS环境的16位代码('int 21h'等等),所以它已经过时了。如果使用16位代码不是老师给出的要求,而且您现在也不打算写自己的引导加载程序,我建议您学习现代的32位或64位x86/x86-64程序集,而不是过时的16位x86汇编。 – nrz 2014-12-07 15:06:37
我必须对大小(行数,内存)进行优化。您对其MS-DOS环境的16位是正确的)。我必须使用16位。 – Lukas 2014-12-07 15:11:44
你正在使用什么汇编程序和什么命令行参数?你用'(线,内存)'来表示什么?在我看来,对代码行进行优化对于汇编代码来说没有多大意义。如果你真的需要,只需使用'db'编写所有的代码,你只能得到1行代码......你的意思是你的EXE文件的大小是467千字节?如果您确实需要优化可执行文件大小,请将您的可执行文件作为COM文件。之后,检查代码中所有指令的编码大小,并查找缩短可执行文件的位置。 – nrz 2014-12-07 15:38:41