P
P
Pitonist2242019-10-15 19:46:01
DOS
Pitonist224, 2019-10-15 19:46:01

How to plot in dos via asm?

I have the following code to create a graph

.model small
     .stack 256h
     .data
curentx dw 0
curenty dw 100
divcoeff dd 180
stretchcoeff dd 49
addcoeff dd 100
A 	dd 2

B	dd 40d 

C	dd 03d

array dw 720 dup(0)

      .code
begin:
      mov ax,@data
      mov ds,ax
      mov es,ax
      finit
      mov si,0
@@jump:
       call calcnextpixel
       mov ax,curenty
       mov array[si],ax
       add si,2
       inc curentx
       cmp si,720
       jne @@jump
       mov ax,0a000h
       mov es,ax
       xor ax,ax
       mov al,13h
       int 10h
@@null:
       xor si,si
@@loop:        
       mov ah,01h
       int 16h
        jnz @@bef
        push si
        call shiftscreen
        pop si
        mov ax,array[si]
        mov curenty,ax
        call putpixel
        add si,2
        cmp si,720
        je @@null
        inc curentx
        jmp @@loop
@@bef:
  cmp al,1Bh
  je @@quit
  cmp al,20h
  jne @@lp2
  mov ah,0Ch
  int 21h
@@lp1:
  mov ah,01
  int 16h
  jnz @@lp2
  jmp @@lp1
@@lp2:
       mov ah,0Ch	
       int 21h  
       jmp @@loop
@@quit:
        mov ah,10h
        int 16h
        mov ax,3
        int 10h
        mov ax,4c00h
        int 21h

   shiftscreen proc
         push ds
         mov ax,0a000h
         mov ds,ax
         mov si,320*200-2
         mov di,320*200-1
         std
@@nextraw:
         mov cx,319
     rep   movsb
         dec si
         dec di
         cmp di,319
         jne @@nextraw
         pop ds
         ret
shiftscreen endp

putpixel proc
         mov bx,0
         mov cx,200
@@nextclear:
          mov byte ptr es:[bx],0
          add bx,320
          loop @@nextclear
          mov ax,320
          imul curenty
          mov bx,ax
          mov byte ptr es:[bx],10
          ret
  putpixel endp

calcnextpixel proc

 .386
 .387
     fldpi		; занесение пи  st(0)
     fimul curentx	; pi*x		st(0)
  
     fimul C		;
     fidiv divcoeff	;pi*x/180 	st(0)
     fsin		;sin(st(0))
     fidiv A		;
     fimul stretchcoeff	;a=50*sin(...)
     fiadd addcoeff	;+b	(b=100)

   
     fisub B		;
     frndint		;округлить до целого
     fistp curenty	;извлекаем из стека в Y
     ret
 calcnextpixel endp
 end begin

And how can it be remade in such a way, namely (as far as I know) the calcnextpixel function, so that such a graph can be built?
5da5f7996ea60218375662.png

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question