Rewrite rewind in assembly

This commit is contained in:
Colin Leroy-Mira
2025-01-01 13:23:57 +01:00
parent 5531320b51
commit adfb42bfa6
3 changed files with 91 additions and 25 deletions

View File

@@ -1,25 +0,0 @@
/*
** rewind.c
**
** Christian Groessler, 07-Aug-2000
*/
#include <stdio.h>
/*****************************************************************************/
/* Code */
/*****************************************************************************/
void __fastcall__ rewind (FILE* f)
{
fseek(f, 0L, SEEK_SET);
clearerr(f);
}

35
libsrc/common/rewind.s Normal file
View File

@@ -0,0 +1,35 @@
;
; Colin Leroy-Mira <colin@colino.net>
;
; void __fastcall__ rewind (FILE* f)
; /* Rewind a file */
;
.export _rewind
.import _fseek, _clearerr
.import pushax, pushl0, popax
.include "stdio.inc"
; ------------------------------------------------------------------------
; Code
.proc _rewind
; Push f twice (once for fseek, once for clearerr later)
jsr pushax
jsr pushax
; Push offset (long) zero
jsr pushl0
lda #SEEK_SET
jsr _fseek
; Clear error
jsr popax
jmp _clearerr
.endproc