Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
FizzBang
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Ollie Rhodes
FizzBang
Commits
cb537104
Commit
cb537104
authored
Jan 20, 2020
by
Ollie Rhodes
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Upload New File
parent
f84190b1
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
158 additions
and
0 deletions
+158
-0
fizzbang.asm
fizzbang.asm
+158
-0
No files found.
fizzbang.asm
0 → 100644
View file @
cb537104
section
.
bss
digitSpace
resb
100
digitSpacePos
resb
8
section
.
data
fizzText
db
"Fizz"
bangText
db
"Bang"
title
db
"FizzBang Demo"
,
10
section
.
text
global
_start
_start
:
xor
r10
,
r10
;loop number
mov
r11
,
20
;total iterations
;xor r12, r12 ;bang count
;xor r13, r13 ;fizz count
call
_title
loopStart
:
;mov rax, r10 ;moves the value of r10 (loop number) into RAX
;call _printRAX ;prints the int in RAX
;syscall
call
_check3
call
_check5
call
_checkNone
inc
r10
;increase the loop number
cmp
r10
,
20
;compare current loop number to 20
jle
loopStart
;jump to loop start if loop number <= 20
mov
rax
,
60
;end program
mov
rdi
,
0
syscall
_check3
:
xor
rdx
,
rdx
;clears rdx for division
mov
rax
,
r10
;moves loop no into rax
mov
rbx
,
3
;sets rbx as 3
div
rbx
;divides rax by 3
cmp
rdx
,
0
;modulo result - remainder
je
tMul
;jump if no remainder
jmp
tEnd
;otherwise go to tEnd
tMul
:
;goes here if it's a multiple of 3
mov
rax
,
1
;prints fizz
mov
rdi
,
1
mov
rsi
,
fizzText
mov
rdx
,
4
syscall
tEnd
:
ret
_check5
:
xor
rdx
,
rdx
mov
rbx
,
5
mov
rax
,
r10
div
rbx
cmp
rdx
,
0
je
fMul
jmp
fEnd
fMul
:
mov
rdx
,
1
mov
rdi
,
1
mov
rsi
,
bangText
mov
rdx
,
4
syscall
fEnd
:
ret
_checkNone
:
xor
rdx
,
rdx
mov
rbx
,
3
mov
rax
,
r10
div
rbx
cmp
rdx
,
0
jne
tNo
jmp
nEnd
tNo
:
xor
rdx
,
rdx
mov
rbx
,
5
mov
rax
,
r10
div
rbx
cmp
rdx
,
0
jne
fNo
jmp
nEnd
fNo
:
mov
rax
,
r10
call
_printRAX
syscall
nEnd
:
ret
_title
:
;prints text in title
mov
rax
,
1
mov
rdi
,
1
mov
rsi
,
title
mov
rdx
,
14
syscall
ret
; The following code was taken from an online source
; It is only used to print integers - I was unable to get this working alone
_printRAX
:
mov
rcx
,
digitSpace
mov
rbx
,
10
mov
[rcx],
rbx
inc
rcx
mov
[digitSpacePos],
rcx
_printRAXLoop
:
mov
rdx
,
0
mov
rbx
,
10
div
rbx
push
rax
add
rdx
,
48
mov
rcx
,
[digitSpacePos]
mov
[rcx],
dl
inc
rcx
mov
[digitSpacePos],
rcx
pop
rax
cmp
rax
,
0
jne
_printRAXLoop
_printRAXLoop2
:
mov
rcx
,
[digitSpacePos]
mov
rax
,
1
mov
rdi
,
1
mov
rsi
,
rcx
mov
rdx
,
1
syscall
mov
rcx
,
[digitSpacePos]
dec
rcx
mov
[digitSpacePos],
rcx
cmp
rcx
,
digitSpace
jge
_printRAXLoop2
ret
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment