     1                                  ; ****************************************************************************
     2                                  ; circle1.s - TRDOS 386 (TRDOS v2.0.3) Test Program - 'sysvideo' pixel tests
     3                                  ; ----------------------------------------------------------------------------
     4                                  ;
     5                                  ; 14/02/2021 (13/02/2021)
     6                                  ;
     7                                  ; ****************************************************************************
     8                                  ; nasm circle1.s -l circle1.txt -o CIRCLE1.PRG -Z error.txt
     9                                  
    10                                  ; Draw circle by using 'sysvideo' bh=3
    11                                  
    12                                  ; 14/07/2020
    13                                  ; 31/12/2017
    14                                  ; TRDOS 386 (v2.0) system calls
    15                                  _ver 	equ 0
    16                                  _exit 	equ 1
    17                                  _fork 	equ 2
    18                                  _read 	equ 3
    19                                  _write	equ 4
    20                                  _open	equ 5
    21                                  _close 	equ 6
    22                                  _wait 	equ 7
    23                                  _create	equ 8
    24                                  _rename	equ 9
    25                                  _delete	equ 10
    26                                  _exec	equ 11
    27                                  _chdir	equ 12
    28                                  _time 	equ 13
    29                                  _mkdir 	equ 14
    30                                  _chmod	equ 15
    31                                  _rmdir	equ 16
    32                                  _break	equ 17
    33                                  _drive	equ 18
    34                                  _seek	equ 19
    35                                  _tell 	equ 20
    36                                  _memory	equ 21
    37                                  _prompt	equ 22
    38                                  _path	equ 23
    39                                  _env	equ 24
    40                                  _stime	equ 25
    41                                  _quit	equ 26	
    42                                  _intr	equ 27
    43                                  _dir	equ 28
    44                                  _emt 	equ 29
    45                                  _ldrvt 	equ 30
    46                                  _video 	equ 31
    47                                  _audio	equ 32
    48                                  _timer	equ 33
    49                                  _sleep	equ 34
    50                                  _msg    equ 35
    51                                  _geterr	equ 36
    52                                  _fpstat	equ 37
    53                                  _pri	equ 38
    54                                  _rele	equ 39
    55                                  _fff	equ 40
    56                                  _fnf	equ 41
    57                                  _alloc	equ 42
    58                                  _dalloc equ 43
    59                                  _calbac equ 44
    60                                  _dma	equ 45	
    61                                  
    62                                  %macro sys 1-4
    63                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
    64                                      ; 03/09/2015	
    65                                      ; 13/04/2015
    66                                      ; Retro UNIX 386 v1 system call.		
    67                                      %if %0 >= 2   
    68                                          mov ebx, %2
    69                                          %if %0 >= 3    
    70                                              mov ecx, %3
    71                                              %if %0 = 4
    72                                                 mov edx, %4   
    73                                              %endif
    74                                          %endif
    75                                      %endif
    76                                      mov eax, %1
    77                                      ;int 30h
    78                                      int 40h ; TRDOS 386 (TRDOS v2.0)		   
    79                                  %endmacro
    80                                  
    81                                  ; Retro UNIX 386 v1 system call format:
    82                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
    83                                  
    84                                  [BITS 32] ; We need 32-bit intructions for protected mode
    85                                  
    86                                  [ORG 0] 
    87                                  
    88                                  START_CODE:
    89                                  	; clear bss
    90 00000000 BF[80050000]            	mov	edi, bss_start
    91 00000005 B908020000              	mov	ecx, (bss_end - bss_start)/4
    92                                  	;xor	eax, eax
    93 0000000A F3AB                    	rep	stosd
    94                                  
    95                                  	; program message
    96 0000000C BE[33040000]            	mov	esi, program_msg
    97 00000011 E8C7010000              	call	print_msg
    98                                  
    99 00000016 30E4                    	xor	ah, ah
   100                                  	;int	16h	; KEYBOARD - READ CHAR FROM BUFFER, WAIT IF EMPTY
   101                                  			; Return: AH = scan code, AL = character
   102 00000018 CD32                    	int	32h	; TRDOS 386 Keyboard interrupt 
   103                                  
   104                                  	;; Set Video Mode to 13h
   105                                  	;sys	_video, 0813h
   106                                  	;cmp	eax, 14h 
   107                                  	;je	short mode_13h_set_ok
   108                                  
   109                                  	; set VGA mode by using int 31h
   110 0000001A 66B81300                	mov	ax, 13h	; mode 13h ; 
   111 0000001E CD31                    	int	31h	; real mode: int 10h
   112                                  	;jmp	short mode_13h_set_ok
   113                                  
   114                                  mode_13h_set_ok:
   115                                  	; Set squares of number from 0 to 255
   116 00000020 BF[80050000]            	mov	edi, _squares
   117 00000025 B9FF000000              	mov	ecx, 255
   118 0000002A BB01000000              	mov	ebx, 1
   119                                  _ss_x:
   120 0000002F 89D8                    	mov	eax, ebx
   121 00000031 F7E3                    	mul	ebx
   122 00000033 AB                      	stosd
   123 00000034 43                      	inc	ebx
   124 00000035 E2F8                    	loop	_ss_x
   125                                  reset_color:
   126 00000037 C605[8C090000]8E        	mov	byte [color], 142 ; initial color
   127                                  reset_diameter:
   128 0000003E B864000000              	mov	eax, 100 ; initial diameter 
   129                                  newdiameter:	
   130                                  	; Set radius to 100
   131                                  	;mov	dword [radius], 100
   132                                  	;mov	dword [_r2], 10000
   133 00000043 A3[84090000]            	mov	[radius], eax
   134 00000048 89C3                    	mov	ebx, eax
   135 0000004A F7E3                    	mul	ebx
   136 0000004C A3[88090000]            	mov	[_r2], eax ; square of circle radius
   137                                  	; x2+y2 = r2	
   138                                  	; Set Y values for X values from 1 to Radius - 1
   139 00000051 BF[A0090000]            	mov	edi, _fx
   140                                  _yy_x:	
   141 00000056 4B                      	dec	ebx
   142 00000057 7422                    	jz	short center
   143 00000059 89D8                    	mov	eax, ebx
   144 0000005B F7E0                    	mul	eax
   145                                  	; eax = square of ebx
   146 0000005D 8B15[88090000]          	mov	edx, [_r2]
   147 00000063 29C2                    	sub	edx, eax
   148 00000065 E8A8030000              	call	get_squareroot
   149 0000006A AB                      	stosd
   150 0000006B EBE9                    	jmp	short _yy_x
   151                                  
   152                                  	; ***
   153                                  
   154                                  terminate:
   155 0000006D E8BA030000              	call	set_text_mode
   156                                  	sys	_exit
   156                              <1> 
   156                              <1> 
   156                              <1> 
   156                              <1> 
   156                              <1>  %if %0 >= 2
   156                              <1>  mov ebx, %2
   156                              <1>  %if %0 >= 3
   156                              <1>  mov ecx, %3
   156                              <1>  %if %0 = 4
   156                              <1>  mov edx, %4
   156                              <1>  %endif
   156                              <1>  %endif
   156                              <1>  %endif
   156 00000072 B801000000          <1>  mov eax, %1
   156                              <1> 
   156 00000077 CD40                <1>  int 40h
   157                                  halt:
   158 00000079 EBFE                    	jmp	short halt
   159                                  
   160                                  	; ***
   161                                  
   162                                  	; move circle to center of screen
   163                                  center:
   164 0000007B E8DB020000              	call	movecenter
   165                                  _0:
   166 00000080 E869010000              	call	drawcircle
   167                                  waitforkey:
   168 00000085 B401                    	mov	ah, 1
   169 00000087 CD32                    	int	32h
   170 00000089 740C                    	jz	short getkey
   171 0000008B 66FF05[80090000]        	inc	word [counter]
   172 00000092 90                      	nop
   173 00000093 90                      	nop
   174 00000094 90                      	nop
   175 00000095 EBEE                    	jmp	short waitforkey
   176                                  getkey:
   177 00000097 30E4                    	xor	ah, ah
   178 00000099 CD32                    	int	32h
   179                                  
   180 0000009B 663D032E                	cmp	ax, 2E03h
   181 0000009F 74CC                    	je	short terminate
   182 000000A1 3C1B                    	cmp	al, 1Bh ; ESC key
   183 000000A3 74C8                    	je	short terminate	
   184                                  
   185 000000A5 3C2B                    	cmp	al, '+'
   186 000000A7 7511                    	jne	short _1
   187                                  	
   188 000000A9 A1[84090000]            	mov	eax, [radius]
   189                                  
   190 000000AE 3C63                    	cmp	al, 99
   191 000000B0 734C                    	jnb	short _3_  ; beep
   192                                  	
   193                                  	; delete circle by drawing black circle
   194                                  	; with same diameter and at same coordinate
   195 000000B2 E833030000              	call	black_circle
   196                                  	; increase radius of the circle
   197 000000B7 40                      	inc	eax	
   198                                  	;mov	[radius], eax
   199 000000B8 EB89                    	jmp	newdiameter ; draw with new diameter
   200                                  _1:
   201 000000BA 3C2D                    	cmp	al, '-'
   202 000000BC 7514                    	jne	short _2
   203                                  
   204 000000BE A1[84090000]            	mov	eax, [radius]
   205                                  
   206 000000C3 3C01                    	cmp	al, 1
   207 000000C5 7637                    	jna	short _3_ ; beep
   208                                  	
   209                                  	; delete circle by drawing black circle
   210                                  	; with same diameter and at same coordinate
   211 000000C7 E81E030000              	call	black_circle
   212                                  	; decrease radius of the circle
   213 000000CC 48                      	dec	eax	
   214                                  	;mov	[radius], eax
   215 000000CD E971FFFFFF              	jmp	newdiameter ; draw with new diameter
   216                                  _2:
   217 000000D2 3C20                    	cmp	al, 20h  ; space
   218 000000D4 7509                    	jne	short _3
   219 000000D6 8005[8C090000]08        	add	byte [color], 8 	
   220 000000DD EBA1                    	jmp	short _0
   221                                  _3:
   222 000000DF 80FC4B                  	cmp	ah, 4Bh
   223 000000E2 7521                    	jne	short _4
   224                                  	; left arrow
   225 000000E4 A1[84090000]            	mov	eax, [radius]
   226 000000E9 3B05[90090000]          	cmp	eax, [_x0]
   227 000000EF 730D                    	jnb	short _3_
   228 000000F1 E8F4020000              	call	black_circle ; clear current position 
   229 000000F6 FF0D[90090000]          	dec	dword [_x0]
   230 000000FC EB82                    	jmp	_0 ; draw 
   231                                  _3_:
   232 000000FE E8FD020000              	call	beep
   233 00000103 EB80                    	jmp	waitforkey
   234                                  _4:
   235 00000105 80FC4D                  	cmp	ah, 4Dh
   236 00000108 7522                    	jne	short _5
   237                                  
   238                                  	; right arrow
   239 0000010A A1[84090000]            	mov	eax, [radius]
   240 0000010F 0305[90090000]          	add	eax, [_x0]
   241 00000115 3D3F010000              	cmp	eax, 319
   242 0000011A 73E2                    	jnb	short _3_
   243 0000011C E8C9020000              	call	black_circle ; clear current position 
   244 00000121 FF05[90090000]          	inc	dword [_x0]
   245 00000127 E954FFFFFF              	jmp	_0 ; draw 
   246                                  _5:
   247 0000012C 80FC50                  	cmp	ah, 50h
   248 0000012F 7522                    	jne	short _6
   249                                  	; down arrow
   250 00000131 A1[84090000]            	mov	eax, [radius]
   251 00000136 0305[94090000]          	add	eax, [_y0]
   252 0000013C 3DC7000000              	cmp	eax, 199
   253 00000141 73BB                    	jnb	short _3_
   254 00000143 E8A2020000              	call	black_circle ; clear current position 
   255 00000148 FF05[94090000]          	inc	dword [_y0]
   256 0000014E E92DFFFFFF              	jmp	_0 ; draw 
   257                                  _6:
   258 00000153 80FC48                  	cmp	ah, 48h
   259 00000156 751D                    	jne	short _7
   260                                  	; up arrow
   261 00000158 A1[84090000]            	mov	eax, [radius]
   262 0000015D 3B05[94090000]          	cmp	eax, [_y0]
   263 00000163 7399                    	jnb	short _3_
   264 00000165 E880020000              	call	black_circle ; clear current position 
   265 0000016A FF0D[94090000]          	dec	dword [_y0]
   266 00000170 E90BFFFFFF              	jmp	_0 ; draw 
   267                                  _7:
   268 00000175 80FC47                  	cmp	ah, 47h ; Home key
   269 00000178 750F                    	jne	short _8
   270 0000017A E86B020000              	call	black_circle ; clear current position 
   271 0000017F E87C020000              	call	beep
   272 00000184 E9B5FEFFFF              	jmp	reset_diameter
   273                                  		; reset diameter, move to center
   274                                  _8:
   275 00000189 80FC4F                  	cmp	ah, 4Fh ; End key
   276 0000018C 750F                    	jne	short _9
   277 0000018E E857020000              	call	black_circle ; clear current position 
   278 00000193 E868020000              	call	beep
   279 00000198 E99AFEFFFF              	jmp	reset_color 
   280                                  		; reset color and diameter, move to center
   281                                  _9:	
   282 0000019D 663D0D1C                	cmp	ax, 1C0Dh
   283 000001A1 7509                    	jne	short _10
   284 000001A3 8005[8C090000]04        	add	byte [color], 4
   285 000001AA EB22                    	jmp	short _14
   286                                  _10:	
   287 000001AC 80FC53                  	cmp	ah, 53h ; INSERT
   288 000001AF 741D                    	je	short _14
   289                                  _11:
   290 000001B1 80FC52                  	cmp	ah, 52h  ; DEL
   291 000001B4 7418                    	je	short _14
   292                                  _12:
   293 000001B6 80FC49                  	cmp	ah, 49h  ; Page UP
   294 000001B9 7508                    	jne	short _13
   295 000001BB FE0D[8C090000]          	dec	byte [color]
   296 000001C1 EB0B                    	jmp	short _14
   297                                  _13:
   298 000001C3 80FC51                  	cmp	ah, 51h  ; Page Down
   299 000001C6 7510                    	jne	short _15
   300 000001C8 FE05[8C090000]          	inc	byte [color]
   301                                  _14:
   302 000001CE E82D020000              	call	beep
   303 000001D3 E9A8FEFFFF              	jmp	_0
   304                                  _15:
   305 000001D8 E9A8FEFFFF              	jmp	waitforkey
   306                                  
   307                                  print_msg:
   308 000001DD B40E                    	mov	ah, 0Eh
   309 000001DF BB07000000              	mov	ebx, 7
   310                                  	;mov	bl, 7 ; char attribute & color
   311                                  p_next_chr:
   312 000001E4 AC                      	lodsb
   313 000001E5 08C0                    	or	al, al
   314 000001E7 7404                    	jz	short p_retn ; retn	
   315 000001E9 CD31                    	int	31h
   316 000001EB EBF7                    	jmp	short p_next_chr
   317                                  p_retn:
   318 000001ED C3                      	retn
   319                                  
   320                                  drawcircle:
   321                                  	; INPUT:
   322                                  	;	[_x0]
   323                                  	;	[_y0]
   324                                  	;	[radius]
   325                                  	;	[color]
   326                                  	;
   327                                  	; Modified registers: esi, eax, ecx, ebx, edx	
   328                                  _dc_ph0:
   329                                  	; quarter 1	
   330                                  	; start from y = 0, x = radius
   331 000001EE 31C0                    	xor	eax, eax
   332 000001F0 A3[9C090000]            	mov	[_y1], eax ; 0
   333 000001F5 A2[82090000]            	mov	[phase], al ; 0
   334 000001FA 8B2D[84090000]          	mov	ebp, [radius]
   335 00000200 892D[98090000]          	mov	[_x1], ebp ; y = 0, x = r
   336 00000206 BE[A0090000]            	mov	esi, _fx
   337                                  _dc_ph0_n:
   338 0000020B FF0D[98090000]          	dec	dword [_x1]
   339 00000211 AD                      	lodsd
   340                                  _dc_ph0_x:
   341 00000212 8B15[9C090000]          	mov	edx, [_y1]
   342 00000218 42                      	inc	edx
   343 00000219 39C2                    	cmp	edx, eax
   344 0000021B 7314                    	jnb	short _dc_ph0_y
   345 0000021D 50                      	push	eax
   346 0000021E 8915[9C090000]          	mov	[_y1], edx
   347 00000224 E847010000              	call	get_start_offset
   348 00000229 E818010000              	call	write_pixel
   349 0000022E 58                      	pop	eax
   350 0000022F EBE1                    	jmp	short _dc_ph0_x	
   351                                  _dc_ph0_y:
   352 00000231 A3[9C090000]            	mov	[_y1], eax
   353 00000236 E835010000              	call	get_start_offset
   354 0000023B E806010000              	call	write_pixel
   355 00000240 4D                      	dec	ebp
   356 00000241 75C8                    	jnz	short _dc_ph0_n
   357                                  _dc_ph1:
   358                                  	; quarter 2	
   359                                  	; start from y = radius, x = 0
   360 00000243 FE05[82090000]          	inc	byte [phase]
   361 00000249 31C0                    	xor	eax, eax
   362 0000024B A3[98090000]            	mov	[_x1], eax ; 0
   363 00000250 8B2D[84090000]          	mov	ebp, [radius]
   364 00000256 892D[9C090000]          	mov	[_y1], ebp ; y = r, x = 0
   365 0000025C BE[A0090000]            	mov	esi, _fx
   366                                  _dc_ph1_n:
   367 00000261 FF0D[9C090000]          	dec 	dword [_y1]
   368 00000267 AD                      	lodsd
   369                                  _dc_ph1_x:
   370 00000268 8B15[98090000]          	mov	edx, [_x1]
   371 0000026E 42                      	inc	edx
   372 0000026F 39C2                    	cmp	edx, eax
   373 00000271 7314                    	jnb	short _dc_ph1_y
   374 00000273 50                      	push	eax
   375 00000274 8915[98090000]          	mov	[_x1], edx
   376 0000027A E8F1000000              	call	get_start_offset
   377 0000027F E8C2000000              	call	write_pixel
   378 00000284 58                      	pop	eax
   379 00000285 EBE1                    	jmp	short _dc_ph1_x	
   380                                  _dc_ph1_y:
   381 00000287 A3[98090000]            	mov	[_x1], eax
   382 0000028C E8DF000000              	call	get_start_offset
   383 00000291 E8B0000000              	call	write_pixel
   384 00000296 4D                      	dec	ebp
   385 00000297 75C8                    	jnz	short _dc_ph1_n
   386                                  _dc_ph2:
   387                                  	; quarter 3	
   388                                  	; start from y = 0, x = radius
   389 00000299 FE05[82090000]          	inc	byte [phase]
   390 0000029F 31C0                    	xor	eax, eax
   391 000002A1 A3[9C090000]            	mov	[_y1], eax ; 0
   392 000002A6 8B2D[84090000]          	mov	ebp, [radius]
   393 000002AC 892D[98090000]          	mov	[_x1], ebp ; y = 0, x = r
   394 000002B2 BE[A0090000]            	mov	esi, _fx
   395                                  _dc_ph2_n:
   396 000002B7 FF0D[98090000]          	dec	dword [_x1]
   397 000002BD AD                      	lodsd
   398                                  _dc_ph2_x:
   399 000002BE 8B15[9C090000]          	mov	edx, [_y1]
   400 000002C4 42                      	inc	edx
   401 000002C5 39C2                    	cmp	edx, eax
   402 000002C7 7314                    	jnb	short _dc_ph2_y
   403 000002C9 50                      	push	eax
   404 000002CA 8915[9C090000]          	mov	[_y1], edx
   405 000002D0 E89B000000              	call	get_start_offset
   406 000002D5 E86C000000              	call	write_pixel
   407 000002DA 58                      	pop	eax
   408 000002DB EBE1                    	jmp	short _dc_ph2_x	
   409                                  _dc_ph2_y:
   410 000002DD A3[9C090000]            	mov	[_y1], eax
   411 000002E2 E889000000              	call	get_start_offset
   412 000002E7 E85A000000              	call	write_pixel
   413 000002EC 4D                      	dec	ebp
   414 000002ED 75C8                    	jnz	short _dc_ph2_n
   415                                  _dc_ph3:
   416                                  	; quarter 4	
   417                                  	; start from y = radius, x = 0
   418 000002EF FE05[82090000]          	inc	byte [phase]
   419 000002F5 31C0                    	xor	eax, eax
   420 000002F7 A3[98090000]            	mov	[_x1], eax ; 0
   421 000002FC 8B2D[84090000]          	mov	ebp, [radius]
   422 00000302 892D[9C090000]          	mov	[_y1], ebp ; y = r, x = 0
   423 00000308 BE[A0090000]            	mov	esi, _fx
   424                                  _dc_ph3_n:
   425 0000030D FF0D[9C090000]          	dec	dword [_y1]
   426 00000313 AD                      	lodsd
   427                                  _dc_ph3_x:
   428 00000314 8B15[98090000]          	mov	edx, [_x1]
   429 0000031A 42                      	inc	edx
   430 0000031B 39C2                    	cmp	edx, eax
   431 0000031D 7314                    	jnb	short _dc_ph3_y
   432 0000031F 50                      	push	eax
   433 00000320 8915[98090000]          	mov	[_x1], edx
   434 00000326 E845000000              	call	get_start_offset
   435 0000032B E816000000              	call	write_pixel
   436 00000330 58                      	pop	eax
   437 00000331 EBE1                    	jmp	short _dc_ph3_x	
   438                                  _dc_ph3_y:
   439 00000333 A3[98090000]            	mov	[_x1], eax
   440 00000338 E833000000              	call	get_start_offset
   441 0000033D E804000000              	call	write_pixel
   442 00000342 4D                      	dec	ebp
   443 00000343 75C8                    	jnz	short _dc_ph3_n
   444                                  _dc_ph4:
   445 00000345 C3                      	retn	
   446                                  
   447                                  write_pixel:
   448                                  	sys	_video, 0301h, [color], eax
   448                              <1> 
   448                              <1> 
   448                              <1> 
   448                              <1> 
   448                              <1>  %if %0 >= 2
   448 00000346 BB01030000          <1>  mov ebx, %2
   448                              <1>  %if %0 >= 3
   448 0000034B 8B0D[8C090000]      <1>  mov ecx, %3
   448                              <1>  %if %0 = 4
   448 00000351 89C2                <1>  mov edx, %4
   448                              <1>  %endif
   448                              <1>  %endif
   448                              <1>  %endif
   448 00000353 B81F000000          <1>  mov eax, %1
   448                              <1> 
   448 00000358 CD40                <1>  int 40h
   449 0000035A C3                      	retn  
   450                                  
   451                                  movecenter:
   452 0000035B C705[90090000]A000-     	mov	dword [_x0], 320/2
   452 00000363 0000               
   453 00000365 C705[94090000]6400-     	mov	dword [_y0], 200/2
   453 0000036D 0000               
   454 0000036F C3                      	retn
   455                                  
   456                                  get_start_offset:
   457 00000370 B840010000              	mov	eax, 320
   458 00000375 8B15[94090000]          	mov	edx, [_y0]
   459 0000037B 803D[82090000]00        	cmp	byte [phase], 0
   460 00000382 7715                    	ja	short gso_1
   461                                  gso_0:
   462                                  	; quarter 1
   463 00000384 2B15[9C090000]          	sub	edx, [_y1] ; y = 0 -> r
   464 0000038A F7E2                    	mul	edx
   465 0000038C 0305[90090000]          	add	eax, [_x0]
   466 00000392 0305[98090000]          	add	eax, [_x1] ; x = r -> 0
   467 00000398 C3                      	retn
   468                                  gso_1:
   469 00000399 803D[82090000]01        	cmp	byte [phase], 1
   470 000003A0 7715                    	ja	short gso_2
   471                                  	; quarter 2
   472 000003A2 2B15[9C090000]          	sub	edx, [_y1] ; y = r -> 0
   473 000003A8 F7E2                    	mul	edx
   474 000003AA 0305[90090000]          	add	eax, [_x0]
   475 000003B0 2B05[98090000]          	sub	eax, [_x1] ; x = 0 -> -r
   476 000003B6 C3                      	retn
   477                                  gso_2:
   478 000003B7 803D[82090000]02        	cmp	byte [phase], 2
   479 000003BE 7715                    	ja	short gso_3
   480                                  	; quarter 3
   481 000003C0 0315[9C090000]          	add	edx, [_y1] ; y = 0 -> -r 
   482 000003C6 F7E2                    	mul	edx
   483 000003C8 0305[90090000]          	add	eax, [_x0]
   484 000003CE 2B05[98090000]          	sub	eax, [_x1] ; x = -r -> 0 
   485 000003D4 C3                      	retn
   486                                  gso_3:
   487                                  	; quarter 4
   488 000003D5 0315[9C090000]          	add	edx, [_y1] ; y = -r -> 0
   489 000003DB F7E2                    	mul	edx
   490 000003DD 0305[90090000]          	add	eax, [_x0]
   491 000003E3 0305[98090000]          	add	eax, [_x1] ; x = 0 -> r 
   492 000003E9 C3                      	retn
   493                                  
   494                                  black_circle:
   495 000003EA 30E4                    	xor	ah, ah
   496 000003EC 8625[8C090000]          	xchg	[color], ah ; color = 0 
   497 000003F2 50                      	push	eax
   498 000003F3 E8F6FDFFFF              	call	drawcircle
   499 000003F8 58                      	pop	eax
   500 000003F9 8625[8C090000]          	xchg	[color], ah ; restore color
   501 000003FF C3                      	retn
   502                                  
   503                                  beep:
   504                                  	; call beep function (16/64 second, 886Hz)
   505                                  	sys	_audio, 16, 1331
   505                              <1> 
   505                              <1> 
   505                              <1> 
   505                              <1> 
   505                              <1>  %if %0 >= 2
   505 00000400 BB10000000          <1>  mov ebx, %2
   505                              <1>  %if %0 >= 3
   505 00000405 B933050000          <1>  mov ecx, %3
   505                              <1>  %if %0 = 4
   505                              <1>  mov edx, %4
   505                              <1>  %endif
   505                              <1>  %endif
   505                              <1>  %endif
   505 0000040A B820000000          <1>  mov eax, %1
   505                              <1> 
   505 0000040F CD40                <1>  int 40h
   506 00000411 C3                      	retn
   507                                  
   508                                  get_squareroot:
   509                                  	; input: edx = square of the number (y)
   510                                  	; output: eax = approx. square root of ebx 
   511 00000412 BE[80050000]            	mov	esi, _squares
   512 00000417 53                      	push	ebx
   513 00000418 31DB                    	xor	ebx, ebx
   514                                  	;mov	ecx, 256
   515 0000041A 8B0D[84090000]          	mov	ecx, [radius] ; max. value of radius is 256
   516                                  q_sr_x:	
   517 00000420 AD                      	lodsd
   518 00000421 39D0                    	cmp	eax, edx
   519 00000423 7303                    	jnb	short q_sr_ok
   520 00000425 43                      	inc	ebx
   521 00000426 E2F8                    	loop	q_sr_x
   522                                  q_sr_ok:
   523 00000428 89D8                    	mov	eax, ebx
   524 0000042A 5B                      	pop	ebx
   525 0000042B C3                      	retn
   526                                  
   527                                  set_text_mode:
   528 0000042C 30E4                    	xor    ah, ah
   529 0000042E B003                    	mov    al, 3                        
   530                                   	;int   10h	; al = 03h text mode, int 10 video
   531 00000430 CD31                    	int    31h ; TRDOS 386 - Video interrupt
   532 00000432 C3                      	retn
   533                                  		
   534                                  program_msg:
   535 00000433 5452444F5320333836-     	db "TRDOS 386 v2.0.3 - ('sysvideo') Test Program - Draw Circle"
   535 0000043C 2076322E302E33202D-
   535 00000445 202827737973766964-
   535 0000044E 656F27292054657374-
   535 00000457 2050726F6772616D20-
   535 00000460 2D2044726177204369-
   535 00000469 72636C65           
   536 0000046D 0D0A                    	db 0Dh, 0Ah
   537 0000046F 6279204572646F6761-     	db "by Erdogan Tan - 14/02/2021"
   537 00000478 6E2054616E202D2031-
   537 00000481 342F30322F32303231 
   538                                  	;db 0Dh, 0Ah, 0
   539 0000048A 0D0A0D0A                	db 0Dh, 0Ah, 0Dh, 0Ah
   540                                  
   541 0000048E 557365204172726F77-     	db "Use Arrow Keys, Home, End to move the CIRCLE .."
   541 00000497 204B6579732C20486F-
   541 000004A0 6D652C20456E642074-
   541 000004A9 6F206D6F7665207468-
   541 000004B2 6520434952434C4520-
   541 000004BB 2E2E               
   542 000004BD 0D0A                    	db 0Dh, 0Ah
   543 000004BF 557365202B2C2D206B-     	db "Use +,- keys to increase and decrease DIAMETER .."		
   543 000004C8 65797320746F20696E-
   543 000004D1 63726561736520616E-
   543 000004DA 642064656372656173-
   543 000004E3 65204449414D455445-
   543 000004EC 52202E2E           
   544 000004F0 0D0A                    	db 0Dh, 0Ah
   545 000004F2 55736520454E544552-     	db "Use ENTER key to draw CIRCLE .."
   545 000004FB 206B657920746F2064-
   545 00000504 72617720434952434C-
   545 0000050D 45202E2E           
   546 00000511 0D0A                    	db 0Dh, 0Ah
   547 00000513 557365205350414345-     	db "Use SPACE, Pg Up, Pg Down keys to change COLOR .."
   547 0000051C 2C2050672055702C20-
   547 00000525 506720446F776E206B-
   547 0000052E 65797320746F206368-
   547 00000537 616E676520434F4C4F-
   547 00000540 52202E2E           
   548 00000544 0D0A                    	db 0Dh, 0Ah	
   549 00000546 507265737320455343-     	db "Press ESC to exit .."
   549 0000054F 20746F206578697420-
   549 00000558 2E2E               
   550 0000055A 0D0A                    	db 0Dh, 0Ah
   551 0000055C 0D0A                    	db 0Dh, 0Ah
   552 0000055E 507265737320616E79-     	db "Press any key to continue .."
   552 00000567 206B657920746F2063-
   552 00000570 6F6E74696E7565202E-
   552 00000579 2E                 
   553                                  nextline:
   554 0000057A 0D0A00                  	db 0Dh, 0Ah, 0	
   555                                  
   556                                  bss:
   557                                  
   558                                  ABSOLUTE bss
   559                                  
   560 0000057D <res 00000003>          alignb 4
   561                                  
   562                                  bss_start:
   563                                  _squares:
   564 00000580 <res 00000400>          	resd 256 ; squares of numbers from 0 t0 255	
   565                                  counter:
   566 00000980 <res 00000002>          	resw 1
   567 00000982 <res 00000002>          phase:	resw 1
   568 00000984 <res 00000004>          radius:	resd 1 ; Current Radius value
   569 00000988 <res 00000004>          _r2:	resd 1 ; Square of R
   570 0000098C <res 00000004>          color:	resd 1
   571 00000990 <res 00000004>          _x0:	resd 1
   572 00000994 <res 00000004>          _y0:	resd 1
   573 00000998 <res 00000004>          _x1:	resd 1
   574 0000099C <res 00000004>          _y1:	resd 1
   575 000009A0 <res 00000400>          _fx:	resd 256 ; For every X values from 0 to 255
   576                                  
   577                                  
   578                                  bss_end:
