Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement printf #8

Open
Vardan2009 opened this issue Oct 24, 2024 · 0 comments
Open

Implement printf #8

Vardan2009 opened this issue Oct 24, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@Vardan2009
Copy link
Owner

Untested implementation (needs improvements)

fn printf(fmt : ptr8, ::) : byte {
    ; fn_arg x (for accessing other arguments)
    let arg_idx : byte = 0
    loop {
        if *fmt == '%' {
            fmt = fmt + 8
            if *fmt == 'd' {
                printi(fn_arg arg_idx)
                arg_idx = arg_idx + 1
                fmt = fmt + 8
                continue
            }
            if *fmt == 's' {
                prints(fn_arg arg_idx)
                arg_idx = arg_idx + 1
                fmt = fmt + 8
                continue
            }
            if *fmt == 'x' {
                printx(fn_arg arg_idx)
                arg_idx = arg_idx + 1
                fmt = fmt + 8
                continue
            }
        }
        printc(*fmt)
        fmt = fmt + 8
        if *fmt == 0 break
    }
}
@Vardan2009 Vardan2009 added the enhancement New feature or request label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant