Skip to content

GhoulKingR/asm-fizz-buzz

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 

Repository files navigation

asm-fizz-buzz

Apple Silicon assembly fizz buzz example

How to run

To run this code, you need to:

  1. Compile the main.s file
as -o main.o main.s
  1. Link the object file with libc:
gcc -o main -lc main.o
  1. Run the executable:
./main

Debugging

Usually, to debug an assembly code, you use gdb, but right now doesn't work on MacOS's arm64 assembly. Fortunately, a similar tool called LLDB can already be used on MacOS's arm64 assembly.

To use a debugger on the assembly code, you need to compile and link it with -gdwarf-4 flag, like so:

$ as main.s -o main.o -gdwarf-4
$ gcc main.o -o main -lc -gdwarf-4

This tells the compiler to add debugging information inside the executable file for the debugger. To debug your code, run this command:

lldb ./main

This command will display a REPL that allows you to set breakpoints, step over and into lines, and view the current values of all registers among other things. You can learn more about what you can do with LLDB in Apple's GDB and LLDB Command Examples archived documentation or LLDB's GDB to LLDB command map documentation page.

Maybe's

You may be able to run this example on arm64-based Linux and Windows with the same processes, but I haven't tried it out yet.

About

Apple Silicon assembly fizz buzz example

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published