summaryrefslogblamecommitdiff
path: root/zap/source/amd64/mem/fill.s
blob: f4022d0ce4cb6942891a2bcb4ac88f71d5c335c7 (plain) (tree)
1
2
3
4
5
6
7
8
9








                                                                                                               




                                                                           
                       
                                                                       
 
                                                      
 


                                                      
 


                                                        
 
                                                      
 


                                                       

      
                                               
# Copyright 2022-2023 Gabriel Jensen.
# This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
# If a copy of the MPL was not distributed with this file, You can obtain one at <https://mozilla.org/MPL/2.0>.

.intel_syntax noprefix

.globl zap_fill

zap_fill:
	movzx   rsi,sil                # zap_i04 extval = val;
	mov     rax,0x0101010101010101 # zap_i04 val = 0x0101010101010101u;
	imul    rax,rsi                # val *= extval;

.wrdfill:                          # wrdfill:;
	cmp     rdx,0x8
	jl      short .bytefill        # if (num < 0x8u) goto bytefill;

	mov     [rdi],rax              # *dest = val8;

	add     rdi,0x8                # dest += 0x8u;
	sub     rdx,0x8                # num -= 0x8u;
	jmp     short .wrdfill         # goto wrdfill

.bytefill:                         # bytefill:;
	test    rdx,rdx                # if (rem == 0x0)
	jz      short .done            # goto done

	mov     [rsi],al               # *dest = val1;

	inc      rdi                   # ++dest;
	dec      rdx                   # --rem;
	jmp      short .bytefill       # goto bytefill;

.done:
	ret                            # return