王爽《汇编语言》16章16.3计算sinx完整版

     
showsin: jmp short show
          table dw ag0,ag30,ag60,ag60,ag90,ag120,ag150,ag180
	  ag0   db '0',0
	  ag30  db '0.5',0
	  ag60  db '0.866',0
	  ag90  db '1',0
	  ag120 db '0.866',0
	  ag150 db '0.5',0
	  ag180 db '0',0

	  error db 'input ovreflow',0

     show:push bx
          push es
	  push di

	  mov bx,0b800h
	  mov es,bx
	  mov di,160*12+40*2
    
          mov ah,0       
	  mov bl,30      
	  div bl
	  cmp ah,0           ;这三条指令检测al中角度是否超出范围
	  mov bx,0           ;ah中为余数,余数不为0,则显示错误
	  je show_error
	  mov bl,al      
	  mov bh,0
	  add bx,bx     
	  mov bx,cs:table[bx]      

   shows: mov ah,cs:[bx]     
          cmp ah,0          
	  je showret
          mov es:[di],ah     
	  inc bx            
	  add di,2
	  jmp short shows

  show_error:mov ah,cs:error[bx]
            cmp ah,0
	    je showret
	    mov es:[di],ah
	    inc bx
	    add di,2
	    jmp short show_error

  showret:pop di
          pop es
	  pop bx
	  ret
code ends
end start

猜你喜欢

转载自blog.csdn.net/weixin_41944412/article/details/80699833