mirror of
https://github.com/pkivolowitz/asm_book.git
synced 2026-06-23 07:28:04 +08:00
trying to fix links in float directory
This commit is contained in:
parent
9435411155
commit
bba8356515
2 changed files with 0 additions and 167 deletions
|
|
@ -1,103 +0,0 @@
|
||||||
#include "apple-linux-convergence.S"
|
|
||||||
|
|
||||||
GLABEL main
|
|
||||||
.text
|
|
||||||
.align 2
|
|
||||||
|
|
||||||
dless .req d20
|
|
||||||
dmore .req d21
|
|
||||||
ndless .req d22
|
|
||||||
ndmore .req d23
|
|
||||||
|
|
||||||
Emit:
|
|
||||||
START_PROC
|
|
||||||
PUSH_P x29, x30
|
|
||||||
mov x29, sp
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
PUSH_P x1, x2
|
|
||||||
CRT printf
|
|
||||||
add sp, sp, 16
|
|
||||||
#else
|
|
||||||
CRT printf
|
|
||||||
#endif
|
|
||||||
POP_P x29, x30
|
|
||||||
ret
|
|
||||||
END_PROC
|
|
||||||
|
|
||||||
MAIN
|
|
||||||
START_PROC
|
|
||||||
PUSH_P x29, x30
|
|
||||||
stp dless, dmore, [sp, -16]!
|
|
||||||
stp ndless, ndmore, [sp, -16]!
|
|
||||||
mov x29, sp
|
|
||||||
|
|
||||||
LLD_ADDR x0, leg
|
|
||||||
CRT printf
|
|
||||||
|
|
||||||
LLD_ADDR x0, vless
|
|
||||||
ldr dless, [x0]
|
|
||||||
ldr dmore, [x0, 8]
|
|
||||||
ldr ndless, [x0, 16]
|
|
||||||
ldr ndmore, [x0, 24]
|
|
||||||
|
|
||||||
//-fcvtps- Floating-point Convert to Signed integer, rounding toward Plus infinity
|
|
||||||
fcvtps x1, dless
|
|
||||||
fcvtps x2, dmore
|
|
||||||
LLD_ADDR x0, fmt1
|
|
||||||
bl Emit
|
|
||||||
|
|
||||||
fcvtps x1, ndless
|
|
||||||
fcvtps x2, ndmore
|
|
||||||
LLD_ADDR x0, fmt1
|
|
||||||
bl Emit
|
|
||||||
//-fcvtns- Floating-point Convert to Signed integer, rounding to nearest with ties to even (scalar).
|
|
||||||
fcvtns x1, dless
|
|
||||||
fcvtns x2, dmore
|
|
||||||
LLD_ADDR x0, fmt2
|
|
||||||
bl Emit
|
|
||||||
|
|
||||||
fcvtns x1, ndless
|
|
||||||
fcvtns x2, ndmore
|
|
||||||
LLD_ADDR x0, fmt2
|
|
||||||
bl Emit
|
|
||||||
//-fcvtzs- Floating-point Convert to Signed integer, rounding toward Zero (scalar).
|
|
||||||
fcvtzs x1, dless
|
|
||||||
fcvtzs x2, dmore
|
|
||||||
LLD_ADDR x0, fmt4
|
|
||||||
bl Emit
|
|
||||||
|
|
||||||
fcvtzs x1, ndless
|
|
||||||
fcvtzs x2, ndmore
|
|
||||||
LLD_ADDR x0, fmt4
|
|
||||||
bl Emit
|
|
||||||
//-fcvtas- Floating-point Convert to Signed integer, rounding to nearest with ties to Away (scalar).
|
|
||||||
fcvtas x1, dless
|
|
||||||
fcvtas x2, dmore
|
|
||||||
LLD_ADDR x0, fmt3
|
|
||||||
bl Emit
|
|
||||||
|
|
||||||
fcvtas x1, ndless
|
|
||||||
fcvtas x2, ndmore
|
|
||||||
LLD_ADDR x0, fmt3
|
|
||||||
bl Emit
|
|
||||||
//------------------------------
|
|
||||||
|
|
||||||
ldp ndless, ndmore, [sp], 16
|
|
||||||
ldp dless, dmore, [sp], 16
|
|
||||||
POP_P x29, x30
|
|
||||||
mov w0, wzr
|
|
||||||
ret
|
|
||||||
END_PROC
|
|
||||||
|
|
||||||
.data
|
|
||||||
vless: .double 5.49
|
|
||||||
vmore: .double 5.51
|
|
||||||
nvless: .double -5.49
|
|
||||||
nvmore: .double -5.51
|
|
||||||
fmt1: .asciz "fcvtps less: %d more: %d\n"
|
|
||||||
fmt2: .asciz "fcvtns less: %d more: %d\n"
|
|
||||||
fmt3: .asciz "fcvtta less: %d more: %d\n"
|
|
||||||
fmt4: .asciz "fcvtzs less: %d more: %d\n"
|
|
||||||
leg: .asciz "less values are +/- 5.49. more values are +/- 5.51.\n"
|
|
||||||
|
|
||||||
.end
|
|
||||||
|
|
@ -1,64 +0,0 @@
|
||||||
#include "apple-linux-convergence.S"
|
|
||||||
|
|
||||||
GLABEL main
|
|
||||||
.text
|
|
||||||
.p2align 2
|
|
||||||
|
|
||||||
counter .req x20
|
|
||||||
dptr .req x21
|
|
||||||
fptr .req x22
|
|
||||||
.equ max, 4
|
|
||||||
|
|
||||||
MAIN
|
|
||||||
START_PROC
|
|
||||||
PUSH_P counter, x30
|
|
||||||
PUSH_P dptr, fptr
|
|
||||||
PUSH_R x29
|
|
||||||
mov x29, sp
|
|
||||||
|
|
||||||
LLD_ADDR dptr, d
|
|
||||||
LLD_ADDR fptr, f
|
|
||||||
mov counter, xzr
|
|
||||||
|
|
||||||
1: cmp counter, max
|
|
||||||
beq 2f
|
|
||||||
ldr d0, [dptr, counter, lsl 3]
|
|
||||||
ldr s1, [fptr, counter, lsl 2]
|
|
||||||
fcvt d1, s1
|
|
||||||
LLD_ADDR x0, fmt
|
|
||||||
add counter, counter, 1
|
|
||||||
mov x1, counter
|
|
||||||
#if defined(__APPLE__)
|
|
||||||
/*
|
|
||||||
Give us some stack space. Then read the printf template
|
|
||||||
string right to left. Variadics on the Mac are difficult
|
|
||||||
to get right. Remember that printf never prints floats.
|
|
||||||
Only doubles. Internally, floats are converted to double.
|
|
||||||
See the fcvt instruction above.
|
|
||||||
*/
|
|
||||||
sub sp, sp, 32
|
|
||||||
str d1, [sp, 16]
|
|
||||||
str d0, [sp, 8]
|
|
||||||
str x1, [sp]
|
|
||||||
CRT printf
|
|
||||||
add sp, sp, 32
|
|
||||||
#else
|
|
||||||
CRT printf
|
|
||||||
#endif
|
|
||||||
b 1b
|
|
||||||
|
|
||||||
2: POP_R x29
|
|
||||||
POP_P dptr, fptr
|
|
||||||
POP_P counter, x30
|
|
||||||
mov w0, wzr
|
|
||||||
END_PROC
|
|
||||||
ret
|
|
||||||
|
|
||||||
.data
|
|
||||||
fmt: .asciz "index %ld double %f float %f\n"
|
|
||||||
.p2align 3
|
|
||||||
d: .double 1.555555, 2.666666, 3.777777, 4.888888
|
|
||||||
.p2align 2
|
|
||||||
f: .float 1.111111, 2.222222, 3.333333, 4.444444
|
|
||||||
|
|
||||||
.end
|
|
||||||
Loading…
Reference in a new issue