Adds strcpy()

This commit is contained in:
2025-07-06 11:15:58 +02:00
parent a3a128354d
commit 2fb4312615
2 changed files with 95 additions and 0 deletions

View File

@@ -7,12 +7,20 @@ extern print
extern puts
; string.asm
extern strlen
extern strcpy
; convert.asm
section .rodata
TEST_print equ 1
TEST_puts equ 1
TEST_strlen equ 1
TEST_strcpy equ 1
str1 db "Hello, world!",EOS
str2 db "Hello, World!",EOS
str3 db "Hello world!",EOS
str4 db "Howdy environment!",EOS
str5 db "The quick brown fox jumps over the lazy dog",EOS
; print()
msgPrint db "TEST print()",NL,EOS
@@ -24,9 +32,18 @@ section .rodata
strlenStr1 db "Hello",EOS
strlenStr2 db "Hello, world!",NL,EOS
; strcpy()
msgStrcpy db "TEST strcpy()",NL,EOS
strcpy1 db TAB,"strcpy(strBuff1, str1, 12): ",NL,TAB,TAB,EOS
strcpy2 db TAB,"strcpy(strBuff1, str1, 13): ",NL,TAB,TAB,EOS
strcpy3 db TAB,"strcpy(strBuff1, str1, 32): ",NL,TAB,TAB,EOS
strcpy4 db TAB,"strcpy(strBuff1, str5, 32): ",NL,TAB,TAB,EOS
section .data
section .bss
strBuff1 resb 32
strBuff2 resb 4
section .text
global _start
@@ -63,6 +80,51 @@ _start:
call strlen
%endif
;---
;--- strcpy()
;---
%if TEST_strcpy
lea rdi, [rel msgStrcpy]
call print
; TEST 1
lea rdi, [rel strcpy1]
call print
lea rdi, [rel strBuff1]
lea rsi, [rel str1]
mov rdx, 12
call strcpy
mov rdi, rax
call puts
; TEST 2
lea rdi, [rel strcpy2]
call print
lea rdi, [rel strBuff1]
lea rsi, [rel str1]
mov rdx, 13
call strcpy
mov rdi, rax
call puts
; TEST 3
lea rdi, [rel strcpy3]
call print
lea rdi, [rel strBuff1]
lea rsi, [rel str1]
mov rdx, 32
call strcpy
mov rdi, rax
call puts
; TEST 4
lea rdi, [rel strcpy4]
call print
lea rdi, [rel strBuff1]
lea rsi, [rel str5]
mov rdx, 32
call strcpy
mov rdi, rax
call puts
%endif
;---
;--- exit()
;---