Skip to content
GitLab
Menu
Why GitLab
Pricing
Contact Sales
Explore
Why GitLab
Pricing
Contact Sales
Explore
Sign in
Get free trial
Primary navigation
Search or go to…
Project
I
intro_x86-64
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Privacy statement
Keyboard shortcuts
?
What's new
6
Snippets
Groups
Projects
Show more breadcrumbs
luamfb
intro_x86-64
Commits
998d4d69
Commit
998d4d69
authored
5 years ago
by
jshaker000
Committed by
luamfb
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
Added comments to make it more clearer where arguments come from / interact with C
Sorry for submitting so mnay merges im new to gitlab
parent
7958896b
Branches
master
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
8_asm_c/funcs.asm
+23
-1
23 additions, 1 deletion
8_asm_c/funcs.asm
with
23 additions
and
1 deletion
8_asm_c/funcs.asm
+
23
−
1
View file @
998d4d69
...
...
@@ -10,9 +10,28 @@
; with C library's _start.
; Also, we need to mark those functions as global.
;Arguments from C are passed in to these registers in order:
;Integrers/pointers: rdi, rsi, rdx, rcx, r8, r9
;Floats: xmm0, xmm1, xmm2, xmm3, ..., xmm7
;Additional pointers are pushed on the stack
;Return
;Ints/pointers rax or rdx:rax
;Floats xmm0 or xmm1:xmm0
;we must preseve rbp, rbx, r12, r13, r14, r15 so we push/pop
global
uint2str
global
factorial
;extern uint64_t uint2str(uint64_t n, uint8_t *buf, uint64_t bufsize)
;so n maps to rdi
; *buf maps to rsi
; bufsize maps to rdx
;we write the data under *buf only bufsize bytes
;we return to rax the number of bytes written
; this function doesnt add a NULL BYTE, C will need to check if there are
; any leftover room to add it before printing. Else there is possibly info leftover/failure
uint2str:
push
rbp
mov
rbp
,
rsp
...
...
@@ -71,6 +90,9 @@ uint2str:
pop
rbp
ret
; extern uint64_t factorial(uint64_t n);
; so n maps to rdi
; and we return via rax
factorial:
push
rbp
mov
rbp
,
rsp
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment