compTest.asm

URL: https://mirkwood.cs.edinboro.edu/~bennett/class/cmsc3100/spring2026/notes/files/code/list/compTest.asm
 

%include "CONSTANTS.h"

section .data
    output: db `"%s" ? "%s" returns %d\n`,0

    s1: db `and`,0
    s2: db `ant`,0
    s3: db `andrew`,0
    s4: db `bob`,0
section .bss

section .text

extern STRCMP


global main
main:
    ;mov rdi, format1
    ;mov rsi, -1
    ;call CallPrintf 

    mov rdi, s1
    mov rsi, s2
    call TEST

    mov rdi, s1
    mov rsi, s1
    call TEST

    mov rdi, s2
    mov rsi, s1
    call TEST

    mov rdi, s1
    mov rsi, s3
    call TEST

    mov rdi, s3
    mov rsi, s1
    call TEST

    mov rdi, s1
    mov rsi, s4
    call TEST

    mov rdi, s4
    mov rsi, s1
    call TEST
   
   
    jmp Exit

TEST:
    ; rdi holds string 1
    ; rsi holds string 2

    push rbp
    mov rbp, rsp

    ; save the addresses of the two strings
    push r12
    push r13
   
    mov r12, rdi
    mov r13, rsi

    ; compare them
    call STRCMP

    ; print the results
    mov rdi, output
    mov rsi, r12
    mov rdx, r13
    mov rcx, rax
    call CallPrintf

    pop r13
    pop r12

    pop rbp
    ret