classArray.asm

URL: https://mirkwood.cs.edinboro.edu/~bennett/class/cmsc3100/spring2026/notes/dynam/code/classArray.asm
 

%include "CONSTANTS.h"

extern malloc
extern free

section .data
    arraySize: dq 10
    ; int * arrayAddres{nullptr}
    arrayAddress: dq 0

section .bss

section .text

global main
main:
    ;mov rdi, format1
    ;mov rsi, -1
    ;call CallPrintf 
  
    ; arrayAddress = malloc(size_of(element) * elements);
    ; rdi must hold the size
    mov rax, 8
    mov rdi, [arraySize]
    mul rdi
    mov rdi, rax
    call malloc
    mov [arrayAddress], rax


    ;free(memoryAddress)
    mov rdi, [arrayAddress]
    call free

    jmp Exit