doc: convert more of Person.im to assembly
This commit is contained in:
@@ -34,6 +34,9 @@
|
||||
#1: ", "
|
||||
#2: @ident[cout]
|
||||
#3: @selector[-put:]
|
||||
#4: @atom[years]
|
||||
#5: @atom[months]
|
||||
#6: @atom[days]
|
||||
@end
|
||||
|
||||
@class (net.doorstuck.test.Person)
|
||||
@@ -69,5 +72,125 @@
|
||||
@end
|
||||
|
||||
@msgh (net.doorstuck.test.Person) [-test(param:_:)]
|
||||
ldr x0, [pool, #0]
|
||||
|
||||
ldr x1, [bp, #-1]
|
||||
add x0, x1, x0
|
||||
|
||||
ldr x1, [pool, #1]
|
||||
add x0, x1, x0
|
||||
|
||||
ldr x1, [bp, #-2]
|
||||
add x0, x1, x0
|
||||
|
||||
push x0
|
||||
|
||||
ldr x1, [pool, #2]
|
||||
ldr x2, [pool, #3]
|
||||
|
||||
msg x1, x2, #1
|
||||
|
||||
ret.n
|
||||
@end
|
||||
|
||||
@msgh (net.doorstuck.test.Person) [-name]
|
||||
ldr x0, [self, #0]
|
||||
ret
|
||||
@end
|
||||
|
||||
@msgh (net.doorstuck.test.Person) [-age]
|
||||
ldr x0, [self, #1]
|
||||
ret
|
||||
@end
|
||||
|
||||
@msgh (net.doorstuck.test.Person) [-ageInMonths]
|
||||
ldr x0, [self, #1]
|
||||
ldr x1, #12
|
||||
|
||||
mul x0, x1, x0
|
||||
|
||||
ret
|
||||
@end
|
||||
|
||||
@msgh (net.doorstuck.test.Person) [-setName:]
|
||||
ldr x0, [bp, #-1]
|
||||
str x0, [self, #0]
|
||||
|
||||
ret.n
|
||||
@end
|
||||
|
||||
@msgh (net.doorstuck.test.Person) [-setAge:]
|
||||
ldr x0, [bp, #-1]
|
||||
str x0, [self, #1]
|
||||
|
||||
ret.n
|
||||
@end
|
||||
|
||||
@msgh (net.doorstuck.test.Person) [-setAge:inUnits:]
|
||||
ldr x0, [bp, #-1]
|
||||
ldr x1, [bp, #-2]
|
||||
|
||||
ldr x2, [pool, #4]
|
||||
cmp x1, x2
|
||||
b.eq L0001
|
||||
|
||||
ldr x2, [pool, #5]
|
||||
cmp x1, x2
|
||||
b.eq L0002
|
||||
|
||||
ldr x2, [pool, #6]
|
||||
cmp x1, x2
|
||||
b.eq L0003
|
||||
|
||||
ldr x0, #0
|
||||
str x0, [self, #1]
|
||||
|
||||
br L0004
|
||||
|
||||
L0001: str x0, [self, #2]
|
||||
br L0004
|
||||
|
||||
L0002: ldr x3, #12
|
||||
div x3, x0, x3
|
||||
str x3, [self, #2]
|
||||
br L0004
|
||||
|
||||
L0003: ldr x3, #365
|
||||
div x3, x0, x3
|
||||
str x3, [self, #2]
|
||||
br L0004
|
||||
L0004:
|
||||
ret.n
|
||||
@end
|
||||
|
||||
@msgh (net.doorstuck.test.Person) [-getAgeInUnits:]
|
||||
ldr x1, [bp, #-1] ; x1 = units
|
||||
|
||||
ldr x2, [pool, #4] ; x2 = #years
|
||||
cmp x1, x2
|
||||
b.eq L0001 ; [jump] if units == #years
|
||||
|
||||
ldr x2, [pool, #5] ; x2 = #months
|
||||
cmp x1, x2
|
||||
b.eq L0002 ; [jump] if units == #years
|
||||
|
||||
ldr x2, [pool, #6] ; x2 = #days
|
||||
cmp x1, x2
|
||||
b.eq L0003 ; [jump] if units == #days
|
||||
|
||||
ldr x0, #0 ; else
|
||||
ret ; return 0
|
||||
|
||||
L0001: ldr x0, [self, #1] ; [code] if units == #years
|
||||
ret ; return self.age
|
||||
|
||||
L0002: ldr x0, [self, #1] ; [code] if units == #months
|
||||
ldr x1, #12
|
||||
div x0, x1, x0
|
||||
ret ; return self.age / 12
|
||||
|
||||
L0003: ldr x0, [self, #1] ; [code] if units == #months
|
||||
ldr x1, #365
|
||||
div x0, x1, x0
|
||||
ret ; return self.age / 365
|
||||
@end
|
||||
|
||||
Reference in New Issue
Block a user