Skip to content

Commit

Permalink
2.36.10
Browse files Browse the repository at this point in the history
  • Loading branch information
nidud committed Dec 14, 2024
1 parent 96ea2b3 commit a4e47b5
Show file tree
Hide file tree
Showing 14 changed files with 153 additions and 108 deletions.
5 changes: 3 additions & 2 deletions include/conio.inc
Original file line number Diff line number Diff line change
Expand Up @@ -620,16 +620,17 @@ rsmodal proto __cdecl :PIDD

;;;

.template AnsiEscapeCode
.template CINPUT

final db ? ; (0x40–0x7E)
count db ? ; (0x30–0x39) -> 1;2;3
param db ? ; (0x3A–0x3F)
inter db ? ; (0x20–0x2F)
n dd 7 dup(?)
.ends
PCINPUT typedef ptr CINPUT

_readansi proto __cdecl :ptr AnsiEscapeCode
_readansi proto __cdecl :PCINPUT
_readinputA proto __cdecl :PINPUT_RECORD
_readinputW proto __cdecl :PINPUT_RECORD
_kbflushA proto __cdecl
Expand Down
2 changes: 1 addition & 1 deletion include/libc.inc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ define __LIBC_INC
; Master include file for the Asmc Run Time library.
;
define __STDC__
define __LIBC__ 234
define __LIBC__ 236
ifdef __ASMC__
if ( __ASMC__ LT __LIBC__ )
.err <incorrect version. Use the header that matches with the Asmc Assembler.>
Expand Down
13 changes: 10 additions & 3 deletions include/stdio.inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ define EOF (-1)
ifndef _FILE_DEFINED
define _FILE_DEFINED
_iobuf struct size_t
ifdef _MSVCRT
_ptr LPTSTR ?
_cnt int_t ?
_base string_t ?
Expand All @@ -59,9 +60,15 @@ _ungotten dw ?
else
_tmpfname LPTSTR ?
endif
ifdef _CRTBLD
_bk dd ?
_bb dd ?
else
_ptr string_t ?
_base string_t ?
_cnt int_t ?
_flag int_t ?
_file int_t ?
_bufsiz int_t ?
_charbuf int_t ?
_bitcnt int_t ?
endif
_iobuf ends
FILE typedef _iobuf
Expand Down
2 changes: 1 addition & 1 deletion source/libc/conio/_getcursor.asm
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ _getcursor proc uses rbx p:PCURSOR

.new cu:CONSOLE_CURSOR_INFO
ifdef __TTY__
.new a:AnsiEscapeCode
.new a:CINPUT
else
.new ci:CONSOLE_SCREEN_BUFFER_INFO
endif
Expand Down
132 changes: 77 additions & 55 deletions source/libc/conio/_readansi.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@ include stdlib.inc

.code

assume rbx:ptr AnsiEscapeCode
assume rbx:PCINPUT

_readansi proc uses rbx csi:ptr AnsiEscapeCode
_readansi proc uses rbx csi:PCINPUT

.new value:int_t
.new count:int_t
.new radix:int_t
.new final[2]:byte

ldr rbx,csi

Expand Down Expand Up @@ -89,72 +91,92 @@ _readansi proc uses rbx csi:ptr AnsiEscapeCode
.endif

_getch()
mov count,2

.if ( al == '[' )
.if ( al != '[' && al != ']' )

.while 1
mov [rbx].param,al
_getch()
mov [rbx].final,al
.return( 3 )
.endif

_getch()
inc count
mov count,2
mov ecx,0x5C5C
.if ( al == '[' )
mov ecx,0x7E40
.endif
mov final[0],cl
mov final[1],ch
mov radix,10

.if ( al >= 0x40 && al <= 0x7E )
.while 1

mov [rbx].final,al
_getch()
inc count
mov cl,final[0]
mov ch,final[1]

.switch
.case al >= cl && al <= ch
mov [rbx].final,al
.case eax == -1
.break
.case al == '/'
.if ( cl != '\' )
mov [rbx].inter,al
.endc
.endif
.case al == ';'
inc [rbx].count
movzx ecx,[rbx].count
mov [rbx+rcx*4].n,0
mov value,1
.endc
.case al >= 0x20 && al <= 0x2F
mov [rbx].inter,al
.endc
.case al >= 'a' && al <= 'f'
.endc .if ( radix == 10 )
sub al,'a'-10-'0'
.case al >= '0' && al <= '9'
sub al,'0'
movzx ecx,[rbx].count
mov edx,[rbx].n[rcx*4]
imul edx,radix
add eax,edx
mov [rbx].n[rcx*4],eax
mov value,1
.endc
.case al == 0x1B
.if ( cl != '\' )
_ungetch( eax )
dec count
.break
.endif

.if ( al >= 0x30 && al <= 0x3F )

.if ( al <= '9' )

sub al,'0'
movzx ecx,[rbx].count
imul edx,[rbx].n[rcx*4],10
add eax,edx
mov [rbx].n[rcx*4],eax
mov value,1

.elseif ( al == ';' )

inc [rbx].count
movzx ecx,[rbx].count
mov [rbx+rcx*4].n,0
mov value,1
.else
mov [rbx].param,al
.endif

.elseif ( al >= 0x20 || al <= 0x2F )
mov [rbx].inter,al
.else
.break
.endc
.case al == ':' ; \e]d;d;rgb:xxxx/xxxx/xxxx\e\\
.if ( cl == '\' )
mov radix,16
.endc
.endif
.endw
mov ecx,value
add [rbx].count,cl

.if ( [rbx].final == 'M' )

_getch()
.default
mov [rbx].param,al
_getch()
sub eax,0x21
mov [rbx].n[0],eax
_getch()
sub eax,0x21
mov [rbx].n[4],eax
add count,3
.endif
.endsw
.endw

.else
mov ecx,value
add [rbx].count,cl
.if ( [rbx].final == 'M' )

_getch()
mov [rbx].param,al
_getch()
inc count
mov [rbx].final,al
sub eax,0x21
mov [rbx].n[0],eax
_getch()
sub eax,0x21
mov [rbx].n[4],eax
add count,3
.endif

mov eax,count
ret

Expand Down
2 changes: 1 addition & 1 deletion source/libc/conio/_treadinput.asm
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ ifdef __TTY__

_readinput proc uses rsi rdi rbx Input:PINPUT_RECORD

.new a:AnsiEscapeCode
.new a:CINPUT

.while 1

Expand Down
2 changes: 1 addition & 1 deletion source/libc/conio/ttyapi.asm
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ _setconsolecursorposition endp

_getconsolescreenbufferinfo proc WINAPI uses rbx fh:HANDLE, pc:PCONSOLE_SCREEN_BUFFER_INFO

.new a:AnsiEscapeCode
.new a:CINPUT

ldr rbx,pc

Expand Down
18 changes: 9 additions & 9 deletions source/libc/stdio/_fflushb.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,27 +14,27 @@ _fflushb proc uses rbx fp:LPFILE

ldr rbx,fp

.while ( [rbx]._bk >= 8 )
.while ( [rbx]._bitcnt >= 8 )

movzx ecx,byte ptr [rbx]._bb
movzx ecx,byte ptr [rbx]._charbuf
.ifd ( fputc(ecx, rbx) == -1 )
.return
.endif
sub [rbx]._bk,8
shr [rbx]._bb,8
sub [rbx]._bitcnt,8
shr [rbx]._charbuf,8
.endw

.if ( [rbx]._bk )
.if ( [rbx]._bitcnt )

mov eax,1
mov ecx,[rbx]._bk
mov ecx,[rbx]._bitcnt
shl eax,cl
dec eax
and eax,[rbx]._bb
and eax,[rbx]._charbuf
fputc(eax, rbx)
.endif
mov [rbx]._bb,0
mov [rbx]._bk,0
mov [rbx]._charbuf,0
mov [rbx]._bitcnt,0
ret

_fflushb endp
Expand Down
18 changes: 9 additions & 9 deletions source/libc/stdio/_fgetb.asm
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,31 @@ _fgetb proc uses rbx fp:LPFILE, count:int_t
.while 1

mov ecx,count
.if ( [rbx]._bk >= ecx )
.if ( [rbx]._bitcnt >= ecx )

mov eax,1 ; create mask
shl eax,cl
dec eax
and eax,[rbx]._bb ; bits to EAX
sub [rbx]._bk,ecx ; dec bit count
shr [rbx]._bb,cl ; dump used bits
and eax,[rbx]._charbuf ; bits to EAX
sub [rbx]._bitcnt,ecx ; dec bit count
shr [rbx]._charbuf,cl ; dump used bits
.break
.endif

; add a byte to bb

.ifd ( fgetc(rbx) == -1 )

.if ( [rbx]._bk )
mov count,[rbx]._bk
.if ( [rbx]._bitcnt )
mov count,[rbx]._bitcnt
.else
.break
.endif
.else
mov ecx,[rbx]._bk
mov ecx,[rbx]._bitcnt
shl eax,cl
or [rbx]._bb,eax
add [rbx]._bk,8
or [rbx]._charbuf,eax
add [rbx]._bitcnt,8
.endif
.endw
ret
Expand Down
14 changes: 7 additions & 7 deletions source/libc/stdio/_fputb.asm
Original file line number Diff line number Diff line change
Expand Up @@ -14,23 +14,23 @@ _fputb proc uses rbx fp:LPFILE, bits:uint_t, count:int_t

ldr rbx,fp

.while ( [rbx]._bk >= 8 )
.while ( [rbx]._bitcnt >= 8 )

movzx ecx,byte ptr [rbx]._bb
movzx ecx,byte ptr [rbx]._charbuf
.ifd ( fputc(ecx, rbx) == -1 )
.return
.endif
sub [rbx]._bk,8
shr [rbx]._bb,8
sub [rbx]._bitcnt,8
shr [rbx]._charbuf,8
.endw

mov ecx,[rbx]._bk
mov ecx,[rbx]._bitcnt
mov edx,bits
mov eax,count

shl edx,cl
or [rbx]._bb,edx
add [rbx]._bk,eax
or [rbx]._charbuf,edx
add [rbx]._bitcnt,eax
ret

_fputb endp
Expand Down
12 changes: 6 additions & 6 deletions source/libc/stdio/ftbuf.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@ _ftbuf proc uses rbx flag:int_t, fp:LPFILE
mov edx,[rbx]._flag
.if ( ecx && edx & _IOFLRTN )

fflush( rbx )
fflush( rbx )

and [rbx]._flag,not (_IOYOURBUF or _IOFLRTN)
xor eax,eax
mov [rbx]._ptr,rax
mov [rbx]._base,rax
mov [rbx]._bufsiz,eax
and [rbx]._flag,not (_IOYOURBUF or _IOFLRTN)
xor eax,eax
mov [rbx]._ptr,rax
mov [rbx]._base,rax
mov [rbx]._bufsiz,eax
.endif
ret

Expand Down
2 changes: 1 addition & 1 deletion source/libc/stdio/getst.asm
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ _getst proc

mov [rcx]._cnt,eax
mov [rcx]._flag,eax
mov [rcx]._bk,eax
mov [rcx]._bitcnt,eax
mov [rcx]._ptr,rax
mov [rcx]._base,rax
dec eax
Expand Down
2 changes: 0 additions & 2 deletions source/libc/stdio/stbuf.asm
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,11 @@ _stbuf proc uses rbx fp:LPFILE
.endif

mov ecx,_INTIOBUF
if defined(_WIN64) or not defined(__UNIX__)
.if ( rax == NULL )

lea rax,[rbx]._charbuf
mov ecx,4
.endif
endif
mov [rbx]._ptr,rax
mov [rbx]._base,rax
mov [rbx]._bufsiz,ecx
Expand Down
Loading

0 comments on commit a4e47b5

Please sign in to comment.