Use NL/EOS instead of 10/0, use constants.asm for global constants
This commit is contained in:
@ -1,7 +1,7 @@
|
||||
extern NL
|
||||
|
||||
extern strlen
|
||||
|
||||
section .rodata
|
||||
NL db 10
|
||||
section .text
|
||||
global print
|
||||
global puts
|
||||
|
6
constants.asm
Normal file
6
constants.asm
Normal file
@ -0,0 +1,6 @@
|
||||
section .rodata
|
||||
global EOS
|
||||
global NL
|
||||
|
||||
EOS equ 0x0
|
||||
NL equ 0xA
|
6
makefile
6
makefile
@ -1,7 +1,9 @@
|
||||
tests: tests.o core.o console.o string.o
|
||||
gcc tests.o core.o console.o string.o -o tests -no-pie -z noexecstack
|
||||
tests: tests.o constants.o core.o console.o string.o
|
||||
gcc tests.o constants.o core.o console.o string.o -o tests -no-pie -z noexecstack
|
||||
tests.o: tests.asm
|
||||
nasm tests.asm -f elf64 -l tests.lst -g -F dwarf
|
||||
constants.o: constants.asm
|
||||
nasm constants.asm -f elf64 -l constants.lst -g -F dwarf
|
||||
core.o: core.asm
|
||||
nasm core.asm -f elf64 -l core.lst -g -F dwarf
|
||||
console.o: console.asm
|
||||
|
71
tests.asm
71
tests.asm
@ -1,5 +1,8 @@
|
||||
extern printf
|
||||
|
||||
;constants.asm
|
||||
extern EOS
|
||||
extern NL
|
||||
;core.asm
|
||||
extern min
|
||||
extern minu
|
||||
@ -39,40 +42,40 @@ section .rodata
|
||||
num1 dq 13
|
||||
num2 dq -25
|
||||
num3 equ 60
|
||||
msgNums db "> num1: %d",10,"> num2: %d",10,"> num3: %d",10,0
|
||||
msgMin db "min(num1, num2): %d",10,0
|
||||
msgMin2 db "minu(num1, num3): %d",10,0
|
||||
msgMin3 db "min(num2, num3): %d",10,0
|
||||
msgMax db "max(num1, num2): %d",10,0
|
||||
msgMax2 db "maxu(num1, num3): %d",10,0
|
||||
msgMax3 db "max(num2, num3): %d",10,0
|
||||
msgPrint db "print() test",0
|
||||
msgPuts db " and puts() test",0
|
||||
str1 db "Hello, world!",0
|
||||
str2 db "Hello World!",0
|
||||
str3 db "Howdy environment!",0
|
||||
msgStrings db "> str1: %s",10,"> str2: %s",10,"> str3: %s",10,0
|
||||
msgStrlen db "strlen(str1): %d",10,0
|
||||
msgStrlen2 db "strlen(str3): %d",10,0
|
||||
msgIslower db "islower(str1[0]): %d",10,0
|
||||
msgIslower2 db "islower(str1[1]): %d",10,0
|
||||
msgIsupper db "isupper(str1[0]): %d",10,0
|
||||
msgIsupper2 db "isupper(str1[1]): %d",10,0
|
||||
msgStrcpy db "strcpy(strBuff, str1): %s",10,0
|
||||
msgStrlcpy db "strlcpy(strBuff2, str1, -1): (%d): %s",10,0
|
||||
msgStrlcpy2 db "strlcpy(strBuff2, str1, 0): (%d): %s",10,0
|
||||
msgStrlcpy3 db "strlcpy(strBuff2, str1, 5): (%d): %s",10,0
|
||||
msgStrcat db "strcat(strBuff, str3): %s",10,0
|
||||
msgStrlen3 db "strlen(strBuff): %d",10,0
|
||||
msgTolower db "tolower(str1[0]): %c",10,0
|
||||
msgTolower2 db "tolower(str1[1]): %c",10,0
|
||||
msgTolower3 db "tolower() for whole strBuff: %s",10,0
|
||||
msgToupper db "toupper(str1[0]): %c",10,0
|
||||
msgToupper2 db "toupper(str1[1]): %c",10,0
|
||||
msgToupper3 db "toupper() for whole strBuff: %s",10,0
|
||||
msgStrcmp db "strcmp(str1, str2): %d",10,0
|
||||
msgStrings2 db "Comparing...",10,"> str1: %s",10,"> strBuff: %s",10,0
|
||||
msgStrcmp2 db "strcmp(str1, strBuff): %d",10,0
|
||||
msgNums db "> num1: %d",NL,"> num2: %d",NL,"> num3: %d",NL,EOS
|
||||
msgMin db "min(num1, num2): %d",NL,EOS
|
||||
msgMin2 db "minu(num1, num3): %d",NL,EOS
|
||||
msgMin3 db "min(num2, num3): %d",NL,EOS
|
||||
msgMax db "max(num1, num2): %d",NL,EOS
|
||||
msgMax2 db "maxu(num1, num3): %d",NL,EOS
|
||||
msgMax3 db "max(num2, num3): %d",NL,EOS
|
||||
msgPrint db "print() test",EOS
|
||||
msgPuts db " and puts() test",EOS
|
||||
str1 db "Hello, world!",EOS
|
||||
str2 db "Hello World!",EOS
|
||||
str3 db "Howdy environment!",EOS
|
||||
msgStrings db "> str1: %s",NL,"> str2: %s",NL,"> str3: %s",NL,EOS
|
||||
msgStrlen db "strlen(str1): %d",NL,EOS
|
||||
msgStrlen2 db "strlen(str3): %d",NL,EOS
|
||||
msgIslower db "islower(str1[0]): %d",NL,EOS
|
||||
msgIslower2 db "islower(str1[1]): %d",NL,EOS
|
||||
msgIsupper db "isupper(str1[0]): %d",NL,EOS
|
||||
msgIsupper2 db "isupper(str1[1]): %d",NL,EOS
|
||||
msgStrcpy db "strcpy(strBuff, str1): %s",NL,EOS
|
||||
msgStrlcpy db "strlcpy(strBuff2, str1, -1): (%d): %s",NL,EOS
|
||||
msgStrlcpy2 db "strlcpy(strBuff2, str1, 0): (%d): %s",NL,EOS
|
||||
msgStrlcpy3 db "strlcpy(strBuff2, str1, 5): (%d): %s",NL,EOS
|
||||
msgStrcat db "strcat(strBuff, str3): %s",NL,EOS
|
||||
msgStrlen3 db "strlen(strBuff): %d",NL,EOS
|
||||
msgTolower db "tolower(str1[0]): %c",NL,EOS
|
||||
msgTolower2 db "tolower(str1[1]): %c",NL,EOS
|
||||
msgTolower3 db "tolower() for whole strBuff: %s",NL,EOS
|
||||
msgToupper db "toupper(str1[0]): %c",NL,EOS
|
||||
msgToupper2 db "toupper(str1[1]): %c",NL,EOS
|
||||
msgToupper3 db "toupper() for whole strBuff: %s",NL,EOS
|
||||
msgStrcmp db "strcmp(str1, str2): %d",NL,EOS
|
||||
msgStrings2 db "Comparing...",NL,"> str1: %s",NL,"> strBuff: %s",NL,EOS
|
||||
msgStrcmp2 db "strcmp(str1, strBuff): %d",NL,EOS
|
||||
section .data
|
||||
section .bss
|
||||
strBuff resb 32
|
||||
|
Reference in New Issue
Block a user