当前位置: 代码迷 >> 汇编语言 >> !256色,320*200图形下画方框的程序
  详细解决方案

!256色,320*200图形下画方框的程序

热度:1646   发布时间:2013-02-26 00:00:00.0
求助!256色,320*200图形下画方框的程序
OOT_ROM_INIT:
  push dx
  push bx
  push ax
  CALL MAINMENU  
  pop ax
  pop bx
  pop dx
  retf ;远程调用返回
MAINMENU PROC NEAR
;数据区
  MOV AX,cs
  MOV DS,AX
  MOV ES,AX

JMP CODESTART
CODESTART:
mov ax,09h
  int 10h
  ;al,cx,si,bp为要传入的参数,bp为方框的大小
  mov al,35h ;color(0~255)
  mov cx,10 ;开始列(0-319)
  mov si,10 ;开始行(0-199)
  call iPCIMess
 
  mov ax,09h 
  int 10h
 
  RET
 
MAINMENU ENDP
;;***************************子程序*******************************
子程序的代码是用教材上的一个例子,原封不动的抄写下来的
iPCIMess proc near
mov bx,0a000h ;video的地址
mov es,bx
  push ax ;save color
mov ax,320 ;calculate start pixel
mul si  
mov di,ax ;start address of box
mov di,cx  
push ax ;save starting offset
mov cx,bp ;box size

BOX1:
rep stosb ;drawing top line
mov cx,bp
sub cx,2 ;update cx
BOX2:
pop di
add di,320 ;point to next row
push di
stosb ;drawing left side
add di,bp
sub di,2
stosb ;drawing right side
loop BOX2

pop di
add di,320 ;point to last row
mov cx,bp
rep stosb ;drawing bottom line

ret
iPCIMess endp
  ;END START
  end start

运行的结果是整个屏幕为黑屏,只有按ctrl+alt+del才能推出程序,是不是我传入参数错误了?还是其他原因?希望各位大侠帮忙!

------解决方案--------------------------------------------------------
Assembly code
mov di,ax ;start address of boxmov di,cx ;这行改成add di,cxpush ax ;save starting offset
------解决方案--------------------------------------------------------
这种传参方式没问题,是用寄存器传参的方式,即把子程序需要的参数放在寄存器中,子程序通过寄存器来取参数.但是你传参的bp 没有赋值啊,也就是bp 这个参数没有传过去.
另外传参也可以通过内存传参,把参数放在内存变量,栈中等,来实现传参.