     1                                  ; ****************************************************************************
     2                                  ; line3.s - TRDOS 386 (TRDOS v2.0.3) Test Program - 'sysvideo' pixel w/r tests
     3                                  ; ----------------------------------------------------------------------------
     4                                  ;
     5                                  ; 11/02/2021 (10/02/2021)
     6                                  ;
     7                                  ; ****************************************************************************
     8                                  ; nasm line3.s -l line3.txt -o LINE3.PRG -Z error.txt
     9                                  ; (modified from 'line1.s', 09/02/2021)
    10                                  
    11                                  ; Draw lines by using 'sysvideo' bx=010Eh
    12                                  
    13                                  ; 14/07/2020
    14                                  ; 31/12/2017
    15                                  ; TRDOS 386 (v2.0) system calls
    16                                  _ver 	equ 0
    17                                  _exit 	equ 1
    18                                  _fork 	equ 2
    19                                  _read 	equ 3
    20                                  _write	equ 4
    21                                  _open	equ 5
    22                                  _close 	equ 6
    23                                  _wait 	equ 7
    24                                  _create	equ 8
    25                                  _rename	equ 9
    26                                  _delete	equ 10
    27                                  _exec	equ 11
    28                                  _chdir	equ 12
    29                                  _time 	equ 13
    30                                  _mkdir 	equ 14
    31                                  _chmod	equ 15
    32                                  _rmdir	equ 16
    33                                  _break	equ 17
    34                                  _drive	equ 18
    35                                  _seek	equ 19
    36                                  _tell 	equ 20
    37                                  _memory	equ 21
    38                                  _prompt	equ 22
    39                                  _path	equ 23
    40                                  _env	equ 24
    41                                  _stime	equ 25
    42                                  _quit	equ 26	
    43                                  _intr	equ 27
    44                                  _dir	equ 28
    45                                  _emt 	equ 29
    46                                  _ldrvt 	equ 30
    47                                  _video 	equ 31
    48                                  _audio	equ 32
    49                                  _timer	equ 33
    50                                  _sleep	equ 34
    51                                  _msg    equ 35
    52                                  _geterr	equ 36
    53                                  _fpstat	equ 37
    54                                  _pri	equ 38
    55                                  _rele	equ 39
    56                                  _fff	equ 40
    57                                  _fnf	equ 41
    58                                  _alloc	equ 42
    59                                  _dalloc equ 43
    60                                  _calbac equ 44
    61                                  _dma	equ 45	
    62                                  
    63                                  %macro sys 1-4
    64                                      ; 29/04/2016 - TRDOS 386 (TRDOS v2.0)	
    65                                      ; 03/09/2015	
    66                                      ; 13/04/2015
    67                                      ; Retro UNIX 386 v1 system call.		
    68                                      %if %0 >= 2   
    69                                          mov ebx, %2
    70                                          %if %0 >= 3    
    71                                              mov ecx, %3
    72                                              %if %0 = 4
    73                                                 mov edx, %4   
    74                                              %endif
    75                                          %endif
    76                                      %endif
    77                                      mov eax, %1
    78                                      ;int 30h
    79                                      int 40h ; TRDOS 386 (TRDOS v2.0)		   
    80                                  %endmacro
    81                                  
    82                                  ; Retro UNIX 386 v1 system call format:
    83                                  ; sys systemcall (eax) <arg1 (ebx)>, <arg2 (ecx)>, <arg3 (edx)>
    84                                  
    85                                  [BITS 32] ; We need 32-bit intructions for protected mode
    86                                  
    87                                  [ORG 0] 
    88                                  
    89                                  START_CODE:
    90                                  	; clear bss
    91 00000000 BF[D0050000]            	mov	edi, bss_start
    92 00000005 B908000000              	mov	ecx, (bss_end - bss_start)/4
    93                                  	;xor	eax, eax
    94 0000000A F3AB                    	rep	stosd
    95                                  
    96                                  	; program message
    97 0000000C BE[68040000]            	mov	esi, program_msg
    98 00000011 E86C020000              	call	print_msg
    99                                  
   100 00000016 30E4                    	xor	ah, ah
   101                                  	;int	16h	; KEYBOARD - READ CHAR FROM BUFFER, WAIT IF EMPTY
   102                                  			; Return: AH = scan code, AL = character
   103 00000018 CD32                    	int	32h	; TRDOS 386 Keyboard interrupt 
   104                                  
   105                                  	;; Set Video Mode to 13h
   106                                  	;sys	_video, 0813h
   107                                  	;cmp	eax, 14h 
   108                                  	;je	short mode_13h_set_ok
   109                                  
   110                                  	; set VGA mode by using int 31h
   111 0000001A 66B81300                	mov	ax, 13h	; mode 13h ; 
   112 0000001E CD31                    	int	31h	; real mode: int 10h
   113 00000020 EB0E                    	jmp	short mode_13h_set_ok
   114                                  
   115                                  terminate:
   116 00000022 E83A040000              	call	set_text_mode
   117                                  	sys	_exit
   117                              <1> 
   117                              <1> 
   117                              <1> 
   117                              <1> 
   117                              <1>  %if %0 >= 2
   117                              <1>  mov ebx, %2
   117                              <1>  %if %0 >= 3
   117                              <1>  mov ecx, %3
   117                              <1>  %if %0 = 4
   117                              <1>  mov edx, %4
   117                              <1>  %endif
   117                              <1>  %endif
   117                              <1>  %endif
   117 00000027 B801000000          <1>  mov eax, %1
   117                              <1> 
   117 0000002C CD40                <1>  int 40h
   118                                  halt:
   119 0000002E EBFE                    	jmp	short halt
   120                                  
   121                                  mode_13h_set_ok:
   122                                  	; create a box and the center of 640x480 screen 
   123                                  reset:	
   124 00000030 B380                    	mov	bl, 128  ; color
   125 00000032 881D[D1050000]          	mov	[color], bl
   126                                  
   127 00000038 B140                    	mov	cl, 64
   128 0000003A 880D[DC050000]          	mov	[length], cl
   129                                  
   130                                  	; BL = Line Color
   131                                  	; CL = Line Size
   132                                  
   133                                  	; move square to center of screen
   134                                  center:
   135 00000040 E8D1030000              	call	movecenter
   136                                  _0:
   137 00000045 E89C020000              	call	drawline
   138 0000004A 7206                    	jc	short waitforkey
   139 0000004C FE05[D0050000]          	inc	byte [lphase] 
   140                                  waitforkey:
   141 00000052 B401                    	mov	ah, 1
   142 00000054 CD32                    	int	32h
   143 00000056 740C                    	jz	short getkey
   144 00000058 66FF05[D2050000]        	inc	word [counter]
   145 0000005F 90                      	nop
   146 00000060 90                      	nop
   147 00000061 90                      	nop
   148 00000062 EBEE                    	jmp	short waitforkey
   149                                  getkey:
   150 00000064 30E4                    	xor	ah, ah
   151 00000066 CD32                    	int	32h
   152                                  
   153 00000068 663D032E                	cmp	ax, 2E03h
   154 0000006C 74B4                    	je	short terminate
   155 0000006E 3C1B                    	cmp	al, 1Bh ; ESC key
   156 00000070 74B0                    	je	short terminate	
   157                                  
   158 00000072 3C2B                    	cmp	al, '+'
   159 00000074 7541                    	jne	short _1
   160                                  
   161 00000076 803D[D0050000]04        	cmp	byte [lphase], 4
   162 0000007D 0F82F5010000            	jb	_14
   163                                  
   164 00000083 E82A020000              	call	clear_lines
   165                                  	; increase length
   166 00000088 FE05[DC050000]          	inc	byte [length]
   167 0000008E 7506                    	jnz	short _incl
   168 00000090 FE0D[DC050000]          	dec	byte [length]
   169                                  _incl:
   170                                  _decl:
   171 00000096 E8A2030000              	call	get_start_offset
   172 0000009B 0305[DC050000]          	add	eax, [length]
   173 000000A1 3D00FA0000              	cmp	eax, 64000
   174 000000A6 769D                    	jna	short _0
   175 000000A8 FE0D[DC050000]          	dec	byte [length]
   176 000000AE 75E6                    	jnz	short _incl
   177 000000B0 E89A030000              	call	beep
   178 000000B5 EB9B                    	jmp	short waitforkey
   179                                  _1:
   180 000000B7 3C2D                    	cmp	al, '-'
   181 000000B9 7522                    	jne	short _2
   182                                  
   183 000000BB 803D[D0050000]04        	cmp	byte [lphase], 4
   184 000000C2 0F82B0010000            	jb	_14
   185                                  
   186 000000C8 E8E5010000              	call	clear_lines
   187                                  	; decrease length
   188 000000CD FE0D[DC050000]          	dec	byte [length]
   189 000000D3 75C1                    	jnz	short _decl
   190 000000D5 FE05[DC050000]          	inc	byte [length]
   191 000000DB EBB9                    	jmp	short _decl
   192                                  _2:
   193 000000DD 3C20                    	cmp	al, 20h  ; space
   194 000000DF 7511                    	jne	short _3
   195 000000E1 8005[D1050000]08        	add	byte [color], 8 	
   196 000000E8 E8F9010000              	call	drawline
   197 000000ED E960FFFFFF              	jmp	waitforkey
   198                                  _3:
   199 000000F2 80FC4B                  	cmp	ah, 4Bh
   200 000000F5 7532                    	jne	short _4
   201                                  
   202                                  	; left arrow
   203 000000F7 803D[D0050000]04        	cmp	byte [lphase], 4
   204 000000FE 0F8274010000            	jb	_14
   205 00000104 66833D[D8050000]00      	cmp	word [x_pos], 0
   206 0000010C 770A                    	ja	short _3_
   207 0000010E E83C030000              	call	beep
   208 00000113 E93AFFFFFF              	jmp	waitforkey
   209                                  _3_:
   210 00000118 E895010000              	call	clear_lines
   211 0000011D 66FF0D[D8050000]        	dec	word [x_pos]
   212 00000124 E91CFFFFFF              	jmp	_0
   213                                  _4:
   214 00000129 80FC4D                  	cmp	ah, 4Dh
   215 0000012C 754A                    	jne	short _5
   216                                  
   217                                  	; right arrow
   218 0000012E 803D[D0050000]04        	cmp	byte [lphase], 4
   219 00000135 0F823D010000            	jb	_14
   220 0000013B E872010000              	call	clear_lines
   221 00000140 8B0D[D8050000]          	mov	ecx, [x_pos]
   222 00000146 030D[DC050000]          	add	ecx, [length]
   223 0000014C 81F940010000            	cmp	ecx, 320
   224 00000152 7218                    	jb	short _4_
   225 00000154 FE0D[DC050000]          	dec	byte [length]
   226 0000015A 7510                    	jnz	short _4_
   227 0000015C FE05[DC050000]          	inc	byte [length]
   228 00000162 E8E8020000              	call	beep
   229 00000167 E9E6FEFFFF              	jmp	waitforkey
   230                                  _4_:
   231 0000016C 66FF05[D8050000]        	inc	word [x_pos]
   232 00000173 E9CDFEFFFF              	jmp	_0
   233                                  _5:
   234 00000178 80FC50                  	cmp	ah, 50h
   235 0000017B 7548                    	jne	short _6
   236                                  	; down arrow
   237 0000017D 803D[D0050000]04        	cmp	byte [lphase], 4
   238 00000184 0F82EE000000            	jb	_14
   239 0000018A E823010000              	call	clear_lines
   240 0000018F A1[D4050000]            	mov	eax, [y_pos]
   241 00000194 0305[DC050000]          	add	eax, [length]
   242 0000019A 3DC8000000              	cmp	eax, 200
   243 0000019F 7218                    	jb	short _5_
   244 000001A1 FE0D[DC050000]          	dec	byte [length]
   245 000001A7 7510                    	jnz	short _5_
   246 000001A9 FE05[DC050000]          	inc	byte [length]
   247 000001AF E89B020000              	call	beep
   248 000001B4 E999FEFFFF              	jmp	waitforkey
   249                                  _5_:
   250 000001B9 66FF05[D4050000]        	inc	word [y_pos]
   251 000001C0 E980FEFFFF              	jmp	_0
   252                                  _6:
   253 000001C5 80FC48                  	cmp	ah, 48h
   254 000001C8 7532                    	jne	short _7
   255                                  	; up arrow
   256 000001CA 803D[D0050000]04        	cmp	byte [lphase], 4
   257 000001D1 0F82A1000000            	jb	_14
   258 000001D7 66833D[D4050000]00      	cmp	word [y_pos], 0
   259 000001DF 770A                    	ja	short _6_
   260 000001E1 E869020000              	call	beep
   261 000001E6 E967FEFFFF              	jmp	waitforkey
   262                                  _6_:
   263 000001EB E8C2000000              	call	clear_lines
   264 000001F0 66FF0D[D4050000]        	dec	word [y_pos]
   265 000001F7 E949FEFFFF              	jmp	_0
   266                                  _7:
   267 000001FC 80FC47                  	cmp	ah, 47h ; Home key
   268 000001FF 751B                    	jne	short _8
   269 00000201 E8AC000000              	call	clear_lines
   270 00000206 E80B020000              	call	movecenter
   271 0000020B E883000000              	call	drawline_x
   272 00000210 E87E000000              	call	drawline_x
   273 00000215 E879000000              	call	drawline_x
   274 0000021A EB5C                    	jmp	short _14
   275                                  _8:
   276 0000021C 80FC4F                  	cmp	ah, 4Fh ; End key
   277 0000021F 752B                    	jne	short _9
   278 00000221 E88C000000              	call	clear_lines
   279 00000226 B380                    	mov	bl, 128  ; color
   280 00000228 881D[D1050000]          	mov	[color], bl
   281 0000022E B140                    	mov	cl, 64
   282 00000230 880D[DC050000]          	mov	[length], cl
   283 00000236 E8DB010000              	call	movecenter
   284 0000023B E853000000              	call	drawline_x
   285 00000240 E84E000000              	call	drawline_x
   286 00000245 E849000000              	call	drawline_x
   287 0000024A EB2C                    	jmp	short _14
   288                                  _9:	
   289 0000024C 663D0D1C                	cmp	ax, 1C0Dh
   290 00000250 7426                    	je	short _14
   291                                  _10:	
   292 00000252 80FC53                  	cmp	ah, 53h ; INSERT
   293 00000255 7421                    	je	short _14
   294                                  _11:
   295 00000257 80FC52                  	cmp	ah, 52h  ; DEL
   296 0000025A 741C                    	je	short _14
   297                                  _12:
   298 0000025C 80FC49                  	cmp	ah, 49h  ; Page UP
   299 0000025F 7508                    	jne	short _13
   300 00000261 FE0D[D1050000]          	dec	byte [color]
   301 00000267 EB0F                    	jmp	short _14
   302                                  _13:
   303 00000269 80FC51                  	cmp	ah, 51h  ; Page Down
   304 0000026C 0F85E0FDFFFF            	jne	waitforkey
   305 00000272 FE05[D1050000]          	inc	byte [color]
   306                                  _14:
   307 00000278 E816000000              	call	drawline_x
   308 0000027D E9D0FDFFFF              	jmp	waitforkey
   309                                  
   310                                  print_msg:
   311 00000282 B40E                    	mov	ah, 0Eh
   312 00000284 BB07000000              	mov	ebx, 7
   313                                  	;mov	bl, 7 ; char attribute & color
   314                                  p_next_chr:
   315 00000289 AC                      	lodsb
   316 0000028A 08C0                    	or	al, al
   317 0000028C 7404                    	jz	short p_retn ; retn	
   318 0000028E CD31                    	int	31h
   319 00000290 EBF7                    	jmp	short p_next_chr
   320                                  p_retn:
   321 00000292 C3                      	retn
   322                                  
   323                                  drawline_x:
   324 00000293 803D[D0050000]04        	cmp	byte [lphase], 4
   325 0000029A 7316                    	jnb	short clear_lines
   326 0000029C E845000000              	call	drawline
   327 000002A1 7308                    	jnc	short drawline_x_ok
   328 000002A3 C605[D0050000]04        	mov	byte [lphase], 4
   329 000002AA C3                      	retn
   330                                  drawline_x_ok:
   331 000002AB FE05[D0050000]          	inc	byte [lphase]
   332                                  drawline_r:
   333 000002B1 C3                      	retn
   334                                  clear_lines:
   335                                  	; clear previous square by drawing black square
   336 000002B2 30E4                    	xor	ah, ah
   337 000002B4 A0[D0050000]            	mov	al, [lphase]
   338 000002B9 8825[D0050000]          	mov	[lphase], ah ; 0
   339 000002BF 8625[D1050000]          	xchg	[color], ah ; 0
   340                                  csq_1:
   341 000002C5 50                      	push	eax
   342 000002C6 E81B000000              	call	drawline
   343 000002CB 58                      	pop	eax
   344 000002CC 20C0                    	and	al, al
   345 000002CE 740A                    	jz	short csq_2
   346 000002D0 FE05[D0050000]          	inc	byte [lphase]
   347 000002D6 FEC8                    	dec	al
   348 000002D8 EBEB                    	jmp	short csq_1
   349                                  csq_2:
   350 000002DA A2[D0050000]            	mov	[lphase], al ; 0
   351 000002DF 8825[D1050000]          	mov	[color], ah ; restore color
   352 000002E5 C3                      	retn
   353                                  drawline:
   354                                  	; INPUT:
   355                                  	;	[x_pos]
   356                                  	;	[y_pos]
   357                                  	;	[length]
   358                                  	;	[color]
   359                                  	;
   360                                  	; Modified registers: edi, eax, ecx, ebx, edx	
   361                                  
   362                                  	; draw one segment of a square
   363                                  _dline0:
   364 000002E6 803D[D0050000]00        	cmp	byte [lphase], 0
   365 000002ED 774A                    	ja	short _dvline1
   366                                  	; draw (x1,y1) to (x2,y1) horizontal line at first
   367                                  _dline0_x:
   368 000002EF E849010000              	call	get_start_offset
   369                                  	; eax = start pos
   370 000002F4 8B2D[DC050000]          	mov	ebp, [length]
   371 000002FA 89C7                    	mov	edi, eax
   372 000002FC 01E8                    	add	eax, ebp
   373 000002FE 3D00FA0000              	cmp	eax, 64000
   374 00000303 7615                    	jna	short _dline0_y
   375 00000305 FE0D[DC050000]          	dec	byte [length]
   376 0000030B 75E2                    	jnz	short _dline0_x
   377                                  	; 11/02/2021
   378 0000030D FE05[DC050000]          	inc	byte [length]
   379                                  _dvline_err:
   380 00000313 E837010000              	call	beep
   381 00000318 F9                      	stc
   382 00000319 C3                      	retn
   383                                  _dline0_y:
   384 0000031A 893D[E0050000]          	mov	[p1pos], edi
   385 00000320 48                      	dec	eax
   386 00000321 A3[E4050000]            	mov	[p2pos], eax
   387                                  	; draw horizontal line
   388 00000326 668B35[D4050000]        	mov	si, [y_pos]
   389 0000032D C1E610                  	shl	esi, 16
   390 00000330 668B35[D8050000]        	mov	si, [x_pos]
   391 00000337 EB73                    	jmp	short _dvline_h 
   392                                  _dvline1:
   393 00000339 803D[D0050000]01        	cmp	byte [lphase], 1
   394 00000340 777F                    	ja	short _dvline2
   395                                  	; draw (x2,y1) to (x2,y2) vertical line
   396                                  _dline1_x:
   397 00000342 8B2D[DC050000]          	mov	ebp, [length]
   398                                   
   399 00000348 668B35[D4050000]        	mov	si, [y_pos]
   400 0000034F C1E610                  	shl	esi, 16
   401 00000352 668B35[D8050000]        	mov	si, [x_pos]
   402 00000359 6601EE                  	add	si, bp
   403 0000035C 664E                    	dec	si
   404                                  
   405 0000035E B840010000              	mov	eax, 320
   406 00000363 F7E5                    	mul	ebp
   407 00000365 8B3D[E4050000]          	mov	edi, [p2pos]
   408 0000036B 01F8                    	add	eax, edi
   409 0000036D 3D00FA0000              	cmp	eax, 64000
   410 00000372 762E                    	jna	short _dline1_y
   411                                  
   412 00000374 803D[DC050000]01        	cmp	byte [length], 1 
   413 0000037B 7696                    	jna	short _dvline_err
   414                                  	
   415 0000037D 28C0                    	sub	al, al
   416 0000037F 8605[D1050000]          	xchg	[color], al ; 0
   417 00000385 50                      	push	eax
   418 00000386 E864FFFFFF              	call	_dline0_x
   419 0000038B 58                      	pop	eax
   420 0000038C A2[D1050000]            	mov	[color], al
   421 00000391 722D                    	jc	short _dvline_ok
   422 00000393 FE0D[DC050000]          	dec	byte [length]
   423 00000399 E851FFFFFF              	call	_dline0_x
   424 0000039E 7220                    	jc	short _dvline_ok
   425 000003A0 EBA0                    	jmp	short _dline1_x
   426                                  _dline1_y:
   427 000003A2 A3[E8050000]            	mov	[p3pos], eax
   428                                  _dvline_v:
   429                                  	; draw vertical line
   430 000003A7 6681CD0010              	or	bp, 1000h ; vertical line
   431                                  _dvline_h:
   432                                  	; esi = line start position (row, column)
   433                                  	sys	_video, 010Eh, [color], ebp
   433                              <1> 
   433                              <1> 
   433                              <1> 
   433                              <1> 
   433                              <1>  %if %0 >= 2
   433 000003AC BB0E010000          <1>  mov ebx, %2
   433                              <1>  %if %0 >= 3
   433 000003B1 8B0D[D1050000]      <1>  mov ecx, %3
   433                              <1>  %if %0 = 4
   433 000003B7 89EA                <1>  mov edx, %4
   433                              <1>  %endif
   433                              <1>  %endif
   433                              <1>  %endif
   433 000003B9 B81F000000          <1>  mov eax, %1
   433                              <1> 
   433 000003BE CD40                <1>  int 40h
   434                                  _dvline_ok:
   435 000003C0 C3                      	retn	
   436                                  _dvline2:
   437 000003C1 803D[D0050000]02        	cmp	byte [lphase], 2
   438 000003C8 772D                    	ja	short _dvline3
   439                                  	; draw (x2,y2) to (x3,y2) horizontal line
   440 000003CA 8B2D[DC050000]          	mov	ebp, [length]
   441 000003D0 A1[E8050000]            	mov	eax, [p3pos]
   442 000003D5 40                      	inc	eax
   443 000003D6 89C7                    	mov	edi, eax
   444 000003D8 29E8                    	sub	eax, ebp	 
   445                                  	;jb	_dvline_err
   446 000003DA A3[EC050000]            	mov	[p4pos], eax
   447                                  	; draw horizontal line
   448 000003DF 668B35[D4050000]        	mov	si, [y_pos]
   449 000003E6 6601EE                  	add	si, bp
   450 000003E9 664E                    	dec	si
   451 000003EB C1E610                  	shl	esi, 16
   452 000003EE 668B35[D8050000]        	mov	si, [x_pos]
   453 000003F5 EBB5                    	jmp	short _dvline_h
   454                                  _dvline3:
   455                                  	; draw (x3,y2) to (x1,y1) vertical line
   456 000003F7 8B2D[DC050000]          	mov	ebp, [length] 
   457 000003FD 8B3D[EC050000]          	mov	edi, [p4pos]
   458                                  	; draw vertical line
   459 00000403 668B35[D4050000]        	mov	si, [y_pos]
   460 0000040A C1E610                  	shl	esi, 16
   461 0000040D 668B35[D8050000]        	mov	si, [x_pos]
   462 00000414 EB91                    	jmp	short _dvline_v
   463                                  
   464                                  movecenter:
   465                                  	; Modified registers: ecx	
   466                                  
   467 00000416 B940010000              	mov	ecx, 320
   468 0000041B 2B0D[DC050000]          	sub	ecx, [length]
   469 00000421 D1E9                    	shr	ecx, 1
   470 00000423 890D[D8050000]          	mov	[x_pos], ecx
   471 00000429 B9C8000000              	mov	ecx, 200
   472 0000042E 2B0D[DC050000]          	sub	ecx, [length]
   473 00000434 D1E9                    	shr	ecx, 1
   474 00000436 890D[D4050000]          	mov	[y_pos], ecx
   475 0000043C C3                      	retn
   476                                  
   477                                  get_start_offset:
   478 0000043D B840010000              	mov	eax, 320
   479 00000442 F725[D4050000]          	mul	dword [y_pos]
   480 00000448 0305[D8050000]          	add	eax, [x_pos]
   481 0000044E C3                      	retn
   482                                  beep:
   483                                  	; call beep function (16/64 second, 886Hz)
   484                                  	sys	_audio, 16, 1331
   484                              <1> 
   484                              <1> 
   484                              <1> 
   484                              <1> 
   484                              <1>  %if %0 >= 2
   484 0000044F BB10000000          <1>  mov ebx, %2
   484                              <1>  %if %0 >= 3
   484 00000454 B933050000          <1>  mov ecx, %3
   484                              <1>  %if %0 = 4
   484                              <1>  mov edx, %4
   484                              <1>  %endif
   484                              <1>  %endif
   484                              <1>  %endif
   484 00000459 B820000000          <1>  mov eax, %1
   484                              <1> 
   484 0000045E CD40                <1>  int 40h
   485 00000460 C3                      	retn
   486                                  
   487                                  set_text_mode:
   488 00000461 30E4                    	xor    ah, ah
   489 00000463 B003                    	mov    al, 3                        
   490                                   	;int   10h	; al = 03h text mode, int 10 video
   491 00000465 CD31                    	int    31h ; TRDOS 386 - Video interrupt
   492 00000467 C3                      	retn
   493                                  		
   494                                  program_msg:
   495 00000468 5452444F5320333836-     	db "TRDOS 386 v2.0.3 - ('sysvideo') Test Program - Draw Lines"
   495 00000471 2076322E302E33202D-
   495 0000047A 202827737973766964-
   495 00000483 656F27292054657374-
   495 0000048C 2050726F6772616D20-
   495 00000495 2D2044726177204C69-
   495 0000049E 6E6573             
   496 000004A1 0D0A                    	db 0Dh, 0Ah
   497 000004A3 6279204572646F6761-     	db "by Erdogan Tan - 11/02/2021"
   497 000004AC 6E2054616E202D2031-
   497 000004B5 312F30322F32303231 
   498                                  	;db 0Dh, 0Ah, 0
   499 000004BE 0D0A0D0A                	db 0Dh, 0Ah, 0Dh, 0Ah
   500                                  
   501 000004C2 557365204172726F77-     	db "Use Arrow Keys, Home, End to move the LINE .."
   501 000004CB 204B6579732C20486F-
   501 000004D4 6D652C20456E642074-
   501 000004DD 6F206D6F7665207468-
   501 000004E6 65204C494E45202E2E 
   502 000004EF 0D0A                    	db 0Dh, 0Ah
   503 000004F1 557365202B2C2D206B-     	db "Use +,- keys to increase and decrease LENGTH .."		
   503 000004FA 65797320746F20696E-
   503 00000503 63726561736520616E-
   503 0000050C 642064656372656173-
   503 00000515 65204C454E47544820-
   503 0000051E 2E2E               
   504 00000520 0D0A                    	db 0Dh, 0Ah
   505 00000522 55736520454E544552-     	db "Use ENTER key to draw SQUARE .."
   505 0000052B 206B657920746F2064-
   505 00000534 726177205351554152-
   505 0000053D 45202E2E           
   506 00000541 0D0A                    	db 0Dh, 0Ah
   507 00000543 53504143452C205067-     	db "SPACE, Pg Up, Pg Down keys to change LINE COLOR .."
   507 0000054C 2055702C2050672044-
   507 00000555 6F776E206B65797320-
   507 0000055E 746F206368616E6765-
   507 00000567 204C494E4520434F4C-
   507 00000570 4F52202E2E         
   508 00000575 0D0A                    	db 0Dh, 0Ah	
   509 00000577 55736520496E736572-     	db "Use Insert, Delete keys to delete LINE or SQUARE .."
   509 00000580 742C2044656C657465-
   509 00000589 206B65797320746F20-
   509 00000592 64656C657465204C49-
   509 0000059B 4E45206F7220535155-
   509 000005A4 415245202E2E       
   510 000005AA 0D0A                    	db 0Dh, 0Ah
   511 000005AC 0D0A                    	db 0Dh, 0Ah
   512 000005AE 507265737320616E79-     	db "Press any key to continue .."
   512 000005B7 206B657920746F2063-
   512 000005C0 6F6E74696E7565202E-
   512 000005C9 2E                 
   513                                  nextline:
   514 000005CA 0D0A00                  	db 0Dh, 0Ah, 0	
   515                                  
   516                                  bss:
   517                                  
   518                                  ABSOLUTE bss
   519                                  
   520 000005CD <res 00000003>          alignb 4
   521                                  
   522                                  bss_start:
   523                                  
   524 000005D0 <res 00000001>          lphase:	resb 1
   525 000005D1 <res 00000001>          color:	resb 1
   526                                  
   527 000005D2 <res 00000002>          counter: resw 1
   528                                  
   529 000005D4 <res 00000004>          y_pos:	resd 1
   530 000005D8 <res 00000004>          x_pos:	resd 1
   531 000005DC <res 00000004>          length: resd 1
   532                                  
   533 000005E0 <res 00000004>          p1pos: resd 1
   534 000005E4 <res 00000004>          p2pos: resd 1
   535 000005E8 <res 00000004>          p3pos: resd 1
   536 000005EC <res 00000004>          p4pos: resd 1
   537                                  
   538                                  bss_end:
