mirror of
https://github.com/pkivolowitz/asm_book.git
synced 2026-06-21 01:56:47 +08:00
more scratch code
This commit is contained in:
parent
cf65bbcf99
commit
1588e75ae4
3 changed files with 333 additions and 1 deletions
5
.vscode/settings.json
vendored
5
.vscode/settings.json
vendored
|
|
@ -45,5 +45,8 @@
|
|||
"rwtypo",
|
||||
"slen",
|
||||
"ssize"
|
||||
]
|
||||
],
|
||||
"files.associations": {
|
||||
"ostream": "cpp"
|
||||
}
|
||||
}
|
||||
16
section_1/funcs/fo.cpp
Normal file
16
section_1/funcs/fo.cpp
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
#include <iostream>
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
using std::cout;
|
||||
using std::endl;
|
||||
using std::hex;
|
||||
|
||||
int main() {
|
||||
int fd = open("test.txt", O_RDWR | O_CREAT, 0666);
|
||||
cout << fd << endl;
|
||||
cout << hex << (O_RDWR | O_CREAT) << endl;
|
||||
if (fd >= 0)
|
||||
close(fd);
|
||||
return 0;
|
||||
}
|
||||
313
section_1/funcs/fo.s
Normal file
313
section_1/funcs/fo.s
Normal file
|
|
@ -0,0 +1,313 @@
|
|||
.arch armv8-a
|
||||
.file "fo.cpp"
|
||||
.text
|
||||
.section .text._ZStanSt13_Ios_FmtflagsS_,"axG",@progbits,_ZStanSt13_Ios_FmtflagsS_,comdat
|
||||
.align 2
|
||||
.weak _ZStanSt13_Ios_FmtflagsS_
|
||||
.type _ZStanSt13_Ios_FmtflagsS_, %function
|
||||
_ZStanSt13_Ios_FmtflagsS_:
|
||||
.LFB1316:
|
||||
.cfi_startproc
|
||||
sub sp, sp, #16
|
||||
.cfi_def_cfa_offset 16
|
||||
str w0, [sp, 12]
|
||||
str w1, [sp, 8]
|
||||
ldr w1, [sp, 12]
|
||||
ldr w0, [sp, 8]
|
||||
and w0, w1, w0
|
||||
add sp, sp, 16
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
.LFE1316:
|
||||
.size _ZStanSt13_Ios_FmtflagsS_, .-_ZStanSt13_Ios_FmtflagsS_
|
||||
.section .text._ZStorSt13_Ios_FmtflagsS_,"axG",@progbits,_ZStorSt13_Ios_FmtflagsS_,comdat
|
||||
.align 2
|
||||
.weak _ZStorSt13_Ios_FmtflagsS_
|
||||
.type _ZStorSt13_Ios_FmtflagsS_, %function
|
||||
_ZStorSt13_Ios_FmtflagsS_:
|
||||
.LFB1317:
|
||||
.cfi_startproc
|
||||
sub sp, sp, #16
|
||||
.cfi_def_cfa_offset 16
|
||||
str w0, [sp, 12]
|
||||
str w1, [sp, 8]
|
||||
ldr w1, [sp, 12]
|
||||
ldr w0, [sp, 8]
|
||||
orr w0, w1, w0
|
||||
add sp, sp, 16
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
.LFE1317:
|
||||
.size _ZStorSt13_Ios_FmtflagsS_, .-_ZStorSt13_Ios_FmtflagsS_
|
||||
.section .text._ZStcoSt13_Ios_Fmtflags,"axG",@progbits,_ZStcoSt13_Ios_Fmtflags,comdat
|
||||
.align 2
|
||||
.weak _ZStcoSt13_Ios_Fmtflags
|
||||
.type _ZStcoSt13_Ios_Fmtflags, %function
|
||||
_ZStcoSt13_Ios_Fmtflags:
|
||||
.LFB1319:
|
||||
.cfi_startproc
|
||||
sub sp, sp, #16
|
||||
.cfi_def_cfa_offset 16
|
||||
str w0, [sp, 12]
|
||||
ldr w0, [sp, 12]
|
||||
mvn w0, w0
|
||||
add sp, sp, 16
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
.LFE1319:
|
||||
.size _ZStcoSt13_Ios_Fmtflags, .-_ZStcoSt13_Ios_Fmtflags
|
||||
.section .text._ZStoRRSt13_Ios_FmtflagsS_,"axG",@progbits,_ZStoRRSt13_Ios_FmtflagsS_,comdat
|
||||
.align 2
|
||||
.weak _ZStoRRSt13_Ios_FmtflagsS_
|
||||
.type _ZStoRRSt13_Ios_FmtflagsS_, %function
|
||||
_ZStoRRSt13_Ios_FmtflagsS_:
|
||||
.LFB1320:
|
||||
.cfi_startproc
|
||||
stp x29, x30, [sp, -32]!
|
||||
.cfi_def_cfa_offset 32
|
||||
.cfi_offset 29, -32
|
||||
.cfi_offset 30, -24
|
||||
mov x29, sp
|
||||
str x0, [sp, 24]
|
||||
str w1, [sp, 20]
|
||||
ldr x0, [sp, 24]
|
||||
ldr w0, [x0]
|
||||
ldr w1, [sp, 20]
|
||||
bl _ZStorSt13_Ios_FmtflagsS_
|
||||
mov w1, w0
|
||||
ldr x0, [sp, 24]
|
||||
str w1, [x0]
|
||||
ldr x0, [sp, 24]
|
||||
ldp x29, x30, [sp], 32
|
||||
.cfi_restore 30
|
||||
.cfi_restore 29
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
.LFE1320:
|
||||
.size _ZStoRRSt13_Ios_FmtflagsS_, .-_ZStoRRSt13_Ios_FmtflagsS_
|
||||
.section .text._ZStaNRSt13_Ios_FmtflagsS_,"axG",@progbits,_ZStaNRSt13_Ios_FmtflagsS_,comdat
|
||||
.align 2
|
||||
.weak _ZStaNRSt13_Ios_FmtflagsS_
|
||||
.type _ZStaNRSt13_Ios_FmtflagsS_, %function
|
||||
_ZStaNRSt13_Ios_FmtflagsS_:
|
||||
.LFB1321:
|
||||
.cfi_startproc
|
||||
stp x29, x30, [sp, -32]!
|
||||
.cfi_def_cfa_offset 32
|
||||
.cfi_offset 29, -32
|
||||
.cfi_offset 30, -24
|
||||
mov x29, sp
|
||||
str x0, [sp, 24]
|
||||
str w1, [sp, 20]
|
||||
ldr x0, [sp, 24]
|
||||
ldr w0, [x0]
|
||||
ldr w1, [sp, 20]
|
||||
bl _ZStanSt13_Ios_FmtflagsS_
|
||||
mov w1, w0
|
||||
ldr x0, [sp, 24]
|
||||
str w1, [x0]
|
||||
ldr x0, [sp, 24]
|
||||
ldp x29, x30, [sp], 32
|
||||
.cfi_restore 30
|
||||
.cfi_restore 29
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
.LFE1321:
|
||||
.size _ZStaNRSt13_Ios_FmtflagsS_, .-_ZStaNRSt13_Ios_FmtflagsS_
|
||||
.section .text._ZNSt8ios_base4setfESt13_Ios_FmtflagsS0_,"axG",@progbits,_ZNSt8ios_base4setfESt13_Ios_FmtflagsS0_,comdat
|
||||
.align 2
|
||||
.weak _ZNSt8ios_base4setfESt13_Ios_FmtflagsS0_
|
||||
.type _ZNSt8ios_base4setfESt13_Ios_FmtflagsS0_, %function
|
||||
_ZNSt8ios_base4setfESt13_Ios_FmtflagsS0_:
|
||||
.LFB1350:
|
||||
.cfi_startproc
|
||||
stp x29, x30, [sp, -48]!
|
||||
.cfi_def_cfa_offset 48
|
||||
.cfi_offset 29, -48
|
||||
.cfi_offset 30, -40
|
||||
mov x29, sp
|
||||
str x0, [sp, 24]
|
||||
str w1, [sp, 20]
|
||||
str w2, [sp, 16]
|
||||
ldr x0, [sp, 24]
|
||||
ldr w0, [x0, 24]
|
||||
str w0, [sp, 44]
|
||||
ldr w0, [sp, 16]
|
||||
bl _ZStcoSt13_Ios_Fmtflags
|
||||
mov w1, w0
|
||||
ldr x0, [sp, 24]
|
||||
add x0, x0, 24
|
||||
bl _ZStaNRSt13_Ios_FmtflagsS_
|
||||
ldr w1, [sp, 16]
|
||||
ldr w0, [sp, 20]
|
||||
bl _ZStanSt13_Ios_FmtflagsS_
|
||||
mov w1, w0
|
||||
ldr x0, [sp, 24]
|
||||
add x0, x0, 24
|
||||
bl _ZStoRRSt13_Ios_FmtflagsS_
|
||||
ldr w0, [sp, 44]
|
||||
ldp x29, x30, [sp], 48
|
||||
.cfi_restore 30
|
||||
.cfi_restore 29
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
.LFE1350:
|
||||
.size _ZNSt8ios_base4setfESt13_Ios_FmtflagsS0_, .-_ZNSt8ios_base4setfESt13_Ios_FmtflagsS0_
|
||||
.section .text._ZSt3hexRSt8ios_base,"axG",@progbits,_ZSt3hexRSt8ios_base,comdat
|
||||
.align 2
|
||||
.weak _ZSt3hexRSt8ios_base
|
||||
.type _ZSt3hexRSt8ios_base, %function
|
||||
_ZSt3hexRSt8ios_base:
|
||||
.LFB1378:
|
||||
.cfi_startproc
|
||||
stp x29, x30, [sp, -32]!
|
||||
.cfi_def_cfa_offset 32
|
||||
.cfi_offset 29, -32
|
||||
.cfi_offset 30, -24
|
||||
mov x29, sp
|
||||
str x0, [sp, 24]
|
||||
mov w2, 74
|
||||
mov w1, 8
|
||||
ldr x0, [sp, 24]
|
||||
bl _ZNSt8ios_base4setfESt13_Ios_FmtflagsS0_
|
||||
ldr x0, [sp, 24]
|
||||
ldp x29, x30, [sp], 32
|
||||
.cfi_restore 30
|
||||
.cfi_restore 29
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
.LFE1378:
|
||||
.size _ZSt3hexRSt8ios_base, .-_ZSt3hexRSt8ios_base
|
||||
.local _ZStL8__ioinit
|
||||
.comm _ZStL8__ioinit,1,8
|
||||
.section .rodata
|
||||
.align 3
|
||||
.LC0:
|
||||
.string "test.txt"
|
||||
.text
|
||||
.align 2
|
||||
.global main
|
||||
.type main, %function
|
||||
main:
|
||||
.LFB1729:
|
||||
.cfi_startproc
|
||||
stp x29, x30, [sp, -32]!
|
||||
.cfi_def_cfa_offset 32
|
||||
.cfi_offset 29, -32
|
||||
.cfi_offset 30, -24
|
||||
mov x29, sp
|
||||
mov w2, 438
|
||||
mov w1, 66
|
||||
adrp x0, .LC0
|
||||
add x0, x0, :lo12:.LC0
|
||||
bl open
|
||||
str w0, [sp, 28]
|
||||
ldr w1, [sp, 28]
|
||||
adrp x0, :got:_ZSt4cout
|
||||
ldr x0, [x0, #:got_lo12:_ZSt4cout]
|
||||
bl _ZNSolsEi
|
||||
mov x2, x0
|
||||
adrp x0, :got:_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
|
||||
ldr x1, [x0, #:got_lo12:_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_]
|
||||
mov x0, x2
|
||||
bl _ZNSolsEPFRSoS_E
|
||||
adrp x0, _ZSt3hexRSt8ios_base
|
||||
add x1, x0, :lo12:_ZSt3hexRSt8ios_base
|
||||
adrp x0, :got:_ZSt4cout
|
||||
ldr x0, [x0, #:got_lo12:_ZSt4cout]
|
||||
bl _ZNSolsEPFRSt8ios_baseS0_E
|
||||
mov w1, 66
|
||||
bl _ZNSolsEi
|
||||
mov x2, x0
|
||||
adrp x0, :got:_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_
|
||||
ldr x1, [x0, #:got_lo12:_ZSt4endlIcSt11char_traitsIcEERSt13basic_ostreamIT_T0_ES6_]
|
||||
mov x0, x2
|
||||
bl _ZNSolsEPFRSoS_E
|
||||
ldr w0, [sp, 28]
|
||||
cmp w0, 0
|
||||
blt .L16
|
||||
ldr w0, [sp, 28]
|
||||
bl close
|
||||
.L16:
|
||||
mov w0, 0
|
||||
ldp x29, x30, [sp], 32
|
||||
.cfi_restore 30
|
||||
.cfi_restore 29
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
.LFE1729:
|
||||
.size main, .-main
|
||||
.align 2
|
||||
.type _Z41__static_initialization_and_destruction_0ii, %function
|
||||
_Z41__static_initialization_and_destruction_0ii:
|
||||
.LFB2230:
|
||||
.cfi_startproc
|
||||
stp x29, x30, [sp, -32]!
|
||||
.cfi_def_cfa_offset 32
|
||||
.cfi_offset 29, -32
|
||||
.cfi_offset 30, -24
|
||||
mov x29, sp
|
||||
str w0, [sp, 28]
|
||||
str w1, [sp, 24]
|
||||
ldr w0, [sp, 28]
|
||||
cmp w0, 1
|
||||
bne .L20
|
||||
ldr w1, [sp, 24]
|
||||
mov w0, 65535
|
||||
cmp w1, w0
|
||||
bne .L20
|
||||
adrp x0, _ZStL8__ioinit
|
||||
add x0, x0, :lo12:_ZStL8__ioinit
|
||||
bl _ZNSt8ios_base4InitC1Ev
|
||||
adrp x0, __dso_handle
|
||||
add x2, x0, :lo12:__dso_handle
|
||||
adrp x0, _ZStL8__ioinit
|
||||
add x1, x0, :lo12:_ZStL8__ioinit
|
||||
adrp x0, :got:_ZNSt8ios_base4InitD1Ev
|
||||
ldr x0, [x0, #:got_lo12:_ZNSt8ios_base4InitD1Ev]
|
||||
bl __cxa_atexit
|
||||
.L20:
|
||||
nop
|
||||
ldp x29, x30, [sp], 32
|
||||
.cfi_restore 30
|
||||
.cfi_restore 29
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
.LFE2230:
|
||||
.size _Z41__static_initialization_and_destruction_0ii, .-_Z41__static_initialization_and_destruction_0ii
|
||||
.align 2
|
||||
.type _GLOBAL__sub_I_main, %function
|
||||
_GLOBAL__sub_I_main:
|
||||
.LFB2231:
|
||||
.cfi_startproc
|
||||
stp x29, x30, [sp, -16]!
|
||||
.cfi_def_cfa_offset 16
|
||||
.cfi_offset 29, -16
|
||||
.cfi_offset 30, -8
|
||||
mov x29, sp
|
||||
mov w1, 65535
|
||||
mov w0, 1
|
||||
bl _Z41__static_initialization_and_destruction_0ii
|
||||
ldp x29, x30, [sp], 16
|
||||
.cfi_restore 30
|
||||
.cfi_restore 29
|
||||
.cfi_def_cfa_offset 0
|
||||
ret
|
||||
.cfi_endproc
|
||||
.LFE2231:
|
||||
.size _GLOBAL__sub_I_main, .-_GLOBAL__sub_I_main
|
||||
.section .init_array,"aw"
|
||||
.align 3
|
||||
.xword _GLOBAL__sub_I_main
|
||||
.hidden __dso_handle
|
||||
.ident "GCC: (Ubuntu 11.3.0-1ubuntu1~22.04) 11.3.0"
|
||||
.section .note.GNU-stack,"",@progbits
|
||||
Loading…
Reference in a new issue