用汇编开发的一个简单的数据库

 .file "test3.s"
 .data
 .p2align 5
 .type current_cd, @object
 .size current_cd, 80
current_cd:
 .string ""
 .string ""
 .zero 78
 .section .rodata
.LC0:
 .string "title.db"
.globl title_file
 .data
 .p2align 2
 .type title_file, @object
 .size title_file, 4
title_file:
 .long .LC0
 .section .rodata
.LC1:
 .string "tracks.db"
.globl tracks_file
 .data
 .p2align 2
 .type tracks_file, @object
 .size tracks_file, 4
tracks_file:
 .long .LC1
 .section .rodata
.LC2:
 .string "db.tmp"
.globl temp_file
 .data
 .p2align 2
 .type temp_file, @object
 .size temp_file, 4
temp_file:
 .long .LC2
 .section .rodata
.LC3:
 .string "aadd new element"
.LC4:
 .string "ffind element"
 .p2align 2
.LC5:
 .string "ccount elements and tracks in the catalog"
.LC6:
 .string "qquit"
.globl main_menu
 .data
 .p2align 2
 .type main_menu, @object
 .size main_menu, 20
main_menu:
 .long .LC3
 .long .LC4
 .long .LC5
 .long .LC6
 .long 0
 .section .rodata
 .p2align 2
.LC7:
 .string "llist tracks on current element"
.LC8:
 .string "rremove current element"
.LC9:
 .string "uupdate track information"
.globl extended_menu
 .data
 .p2align 5
 .type extended_menu, @object
 .size extended_menu, 32
extended_menu:
 .long .LC3
 .long .LC4
 .long .LC5
 .long .LC7
 .long .LC8
 .long .LC9
 .long .LC6
 .long 0
 .section .rodata
.LC10:
 .string "Options:"
 .text
 .p2align 2,,3
.globl main
 .type main, @function
main:
 pushl %ebp
 movl %esp, %ebp
 subl $24, %esp
 andl $-16, %esp
 movl $0, %eax
 addl $15, %eax
 addl $15, %eax
 shrl $4, %eax
 sall $4, %eax
 subl %eax, %esp
 call initscr
.L2:
 subl $8, %esp
 cmpb $0, current_cd
 je .L5
 movl $extended_menu, -8(%ebp)
 jmp .L6
.L5:
 movl $main_menu, -8(%ebp)
.L6:
 pushl -8(%ebp)
 pushl $.LC10
 call getchoice
 addl $16, %esp
 movl %eax, -4(%ebp)
 movl -4(%ebp), %eax
 subl $97, %eax
 movl %eax, -12(%ebp)
 cmpl $20, -12(%ebp)
 ja .L4
 movl -12(%ebp), %edx
 movl .L15(,%edx,4), %eax
 jmp *%eax
 .section .rodata
 .p2align 2
 .p2align 2
.L15:
 .long .L9
 .long .L4
 .long .L10
 .long .L4
 .long .L4
 .long .L11
 .long .L4
 .long .L4
 .long .L4
 .long .L4
 .long .L4
 .long .L12
 .long .L4
 .long .L4
 .long .L4
 .long .L4
 .long .L4
 .long .L13
 .long .L4
 .long .L4
 .long .L14
 .text
.L9:
 call add_record
 jmp .L4
.L10:
 call count_cds
 jmp .L4
.L11:
 call find_cd
 jmp .L4
.L12:
 call list_tracks
 jmp .L4
.L13:
 call remove_cd
 jmp .L4
.L14:
 call update_cd
.L4:
 cmpl $113, -4(%ebp)
 je .L3
 jmp .L2
.L3:
 call endwin
 subl $12, %esp
 pushl $0
 call exit
 .size main, .-main
 .local selected_row.0
 .comm selected_row.0,4,4
 .p2align 2,,3
.globl getchoice
 .type getchoice, @function
getchoice:
 pushl %ebp
 movl %esp, %ebp
 subl $24, %esp
 movl $0, -4(%ebp)
 movl $6, -8(%ebp)
 movl $10, -12(%ebp)
 movl $0, -24(%ebp)
 movl 12(%ebp), %eax
 movl %eax, -16(%ebp)
.L17:
 movl -16(%ebp), %eax
 cmpl $0, (%eax)
 je .L18
 leal -4(%ebp), %eax
 incl (%eax)
 leal -16(%ebp), %eax
 addl $4, (%eax)
 jmp .L17
.L18:
 movl selected_row.0, %eax
 cmpl -4(%ebp), %eax
 jl .L19
 movl $0, selected_row.0
.L19:
 call clear_all_screen
 subl $4, %esp
 pushl 8(%ebp)
 pushl -12(%ebp)
 movl -8(%ebp), %eax
 subl $2, %eax
 pushl %eax
 call mvprintw
 addl $16, %esp
 subl $8, %esp
 pushl $1
 pushl stdscr
 call keypad
 addl $16, %esp
 call cbreak
 call noecho
 movl $0, -24(%ebp)
.L20:
 cmpl $113, -24(%ebp)
 je .L21
 cmpl $343, -24(%ebp)
 je .L21
 cmpl $10, -24(%ebp)
 je .L21
 cmpl $259, -24(%ebp)
 jne .L22
 cmpl $0, selected_row.0
 jne .L23
 movl -4(%ebp), %eax
 decl %eax
 movl %eax, selected_row.0
 jmp .L22
.L23:
 decl selected_row.0
.L22:
 cmpl $258, -24(%ebp)
 jne .L25
 movl -4(%ebp), %eax
 decl %eax
 cmpl selected_row.0, %eax
 jne .L26
 movl $0, selected_row.0
 jmp .L25
.L26:
 incl selected_row.0
.L25:
 movl selected_row.0, %eax
 leal 0(,%eax,4), %edx
 movl 12(%ebp), %eax
 movl (%edx,%eax), %eax
 movsbl (%eax),%eax
 movl %eax, -20(%ebp)
 pushl -12(%ebp)
 pushl -8(%ebp)
 pushl selected_row.0
 pushl 12(%ebp)
 call draw_menu
 addl $16, %esp
 subl $12, %esp
 pushl stdscr
 call wgetch
 addl $16, %esp
 movl %eax, -24(%ebp)
 jmp .L20
.L21:
 subl $8, %esp
 pushl $0
 pushl stdscr
 call keypad
 addl $16, %esp
 call nocbreak
 call echo
 cmpl $113, -24(%ebp)
 jne .L28
 movl $113, -20(%ebp)
.L28:
 movl -20(%ebp), %eax
 leave
 ret
 .size getchoice, .-getchoice
 .section .rodata
.LC11:
 .string "%s"
 .p2align 2
.LC12:
 .string "Move highlight then press Return "
 .text
 .p2align 2,,3
.globl draw_menu
 .type draw_menu, @function
draw_menu:
 pushl %ebp
 movl %esp, %ebp
 subl $24, %esp
 movl $0, -4(%ebp)
 movl 8(%ebp), %eax
 movl %eax, -8(%ebp)
.L30:
 movl -8(%ebp), %eax
 cmpl $0, (%eax)
 je .L31
 movl -4(%ebp), %eax
 cmpl 12(%ebp), %eax
 jne .L32
 subl $4, %esp
 pushl $0
 pushl $65536
 pushl stdscr
 call wattr_on
 addl $16, %esp
.L32:
 movl -4(%ebp), %eax
 leal 0(,%eax,4), %edx
 movl 8(%ebp), %eax
 movl (%edx,%eax), %eax
 movl %eax, -12(%ebp)
 leal -12(%ebp), %eax
 incl (%eax)
 pushl -12(%ebp)
 pushl $.LC11
 pushl 20(%ebp)
 movl -4(%ebp), %eax
 addl 16(%ebp), %eax
 pushl %eax
 call mvprintw
 addl $16, %esp
 movl -4(%ebp), %eax
 cmpl 12(%ebp), %eax
 jne .L33
 subl $4, %esp
 pushl $0
 pushl $65536
 pushl stdscr
 call wattr_off
 addl $16, %esp
.L33:
 leal -4(%ebp), %eax
 incl (%eax)
 leal -8(%ebp), %eax
 addl $4, (%eax)
 jmp .L30
.L31:
 subl $4, %esp
 pushl $.LC12
 pushl 20(%ebp)
 movl -4(%ebp), %eax
 addl 16(%ebp), %eax
 addl $3, %eax
 pushl %eax
 call mvprintw
 addl $16, %esp
 subl $12, %esp
 pushl stdscr
 call wrefresh
 addl $16, %esp
 leave
 ret
 .size draw_menu, .-draw_menu
 .section .rodata
.LC13:
 .string "My Database Application"
.LC14:
 .string "Current element: %s: %s/n"
 .text
 .p2align 2,,3
.globl clear_all_screen
 .type clear_all_screen, @function
clear_all_screen:
 pushl %ebp
 movl %esp, %ebp
 subl $8, %esp
 subl $12, %esp
 pushl stdscr
 call wclear
 addl $16, %esp
 pushl $.LC13
 pushl $.LC11
 pushl $20
 pushl $2
 call mvprintw
 addl $16, %esp
 cmpb $0, current_cd
 je .L35
 subl $12, %esp
 pushl $current_cd
 pushl $current_cat
 pushl $.LC14
 pushl $0
 pushl $22
 call mvprintw
 addl $32, %esp
.L35:
 subl $12, %esp
 pushl stdscr
 call wrefresh
 addl $16, %esp
 leave
 ret
 .size clear_all_screen, .-clear_all_screen
 .section .rodata
.LC15:
 .string " Press return "
 .text
 .p2align 2,,3
.globl get_return
 .type get_return, @function
get_return:
 pushl %ebp
 movl %esp, %ebp
 subl $8, %esp
 pushl $.LC15
 pushl $.LC11
 pushl $0
 pushl $23
 call mvprintw
 addl $16, %esp
 subl $12, %esp
 pushl stdscr
 call wrefresh
 addl $16, %esp
.L37:
 cmpl $0, __isthreaded
 jne .L39
 movl __stdinp, %eax
 decl 4(%eax)
 cmpl $0, 4(%eax)
 jns .L41
 subl $12, %esp
 pushl __stdinp
 call __srget
 addl $16, %esp
 movl %eax, -8(%ebp)
 jmp .L40
.L41:
 movl __stdinp, %eax
 movl (%eax), %edx
 movzbl (%edx), %edx
 movl %edx, -8(%ebp)
 incl (%eax)
 jmp .L40
.L39:
 subl $12, %esp
 pushl __stdinp
 call getc
 addl $16, %esp
 movl %eax, -8(%ebp)
.L40:
 movl -8(%ebp), %eax
 movl %eax, -4(%ebp)
 cmpl $10, %eax
 je .L36
 cmpl $-1, -4(%ebp)
 je .L36
 jmp .L37
.L36:
 leave
 ret
 .size get_return, .-get_return
 .section .rodata
.LC16:
 .string "Are you sure? "
.LC17:
 .string "    Cancelled"
 .text
 .p2align 2,,3
.globl get_confirm
 .type get_confirm, @function
get_confirm:
 pushl %ebp
 movl %esp, %ebp
 subl $8, %esp
 movl $0, -4(%ebp)
 movb $78, -5(%ebp)
 subl $4, %esp
 pushl $.LC16
 pushl $5
 pushl $20
 call mvprintw
 addl $16, %esp
 subl $12, %esp
 pushl stdscr
 call wclrtoeol
 addl $16, %esp
 subl $12, %esp
 pushl stdscr
 call wrefresh
 addl $16, %esp
 call cbreak
 subl $12, %esp
 pushl stdscr
 call wgetch
 addl $16, %esp
 movb %al, -5(%ebp)
 cmpb $89, -5(%ebp)
 je .L45
 cmpb $121, -5(%ebp)
 je .L45
 jmp .L44
.L45:
 movl $1, -4(%ebp)
.L44:
 call nocbreak
 cmpl $0, -4(%ebp)
 jne .L46
 subl $4, %esp
 pushl $.LC17
 pushl $1
 pushl $20
 call mvprintw
 addl $16, %esp
 subl $12, %esp
 pushl stdscr
 call wclrtoeol
 addl $16, %esp
 subl $12, %esp
 pushl stdscr
 call wrefresh
 addl $16, %esp
 subl $12, %esp
 pushl $1
 call sleep
 addl $16, %esp
.L46:
 movl -4(%ebp), %eax
 leave
 ret
 .size get_confirm, .-get_confirm
 .section .rodata
.LC18:
 .string "a"
 .p2align 2
.LC19:
 .string "cannot open My titles database"
.LC20:
 .string "%s/n"
 .text
 .p2align 2,,3
.globl insert_title
 .type insert_title, @function
insert_title:
 pushl %ebp
 movl %esp, %ebp
 subl $8, %esp
 subl $8, %esp
 pushl $.LC18
 pushl title_file
 call fopen
 addl $16, %esp
 movl %eax, -4(%ebp)
 cmpl $0, -4(%ebp)
 jne .L48
 subl $4, %esp
 pushl $.LC19
 pushl $0
 pushl $22
 call mvprintw
 addl $16, %esp
 jmp .L47
.L48:
 subl $4, %esp
 pushl 8(%ebp)
 pushl $.LC20
 pushl -4(%ebp)
 call fprintf
 addl $16, %esp
 subl $12, %esp
 pushl -4(%ebp)
 call fclose
 addl $16, %esp
.L47:
 leave
 ret
 .size insert_title, .-insert_title
 .p2align 2,,3
.globl get_string
 .type get_string, @function
get_string:
 pushl %ebp
 movl %esp, %ebp
 subl $8, %esp
 subl $4, %esp
 pushl $80
 pushl 8(%ebp)
 pushl stdscr
 call wgetnstr
 addl $16, %esp
 subl $12, %esp
 pushl 8(%ebp)
 call strlen
 addl $16, %esp
 movl %eax, -4(%ebp)
 cmpl $0, -4(%ebp)
 jle .L50
 movl -4(%ebp), %eax
 addl 8(%ebp), %eax
 decl %eax
 cmpb $10, (%eax)
 jne .L50
 movl -4(%ebp), %eax
 addl 8(%ebp), %eax
 decl %eax
 movb $0, (%eax)
.L50:
 leave
 ret
 .size get_string, .-get_string
 .section .rodata
.LC21:
 .string "Enter new element details"
.LC22:
 .string "Catalog Number: "
.LC23:
 .string "      element Title: "
.LC24:
 .string "       element Type: "
.LC25:
 .string "        titles: "
.LC26:
 .string "About to add this new entry:"
.LC27:
 .string "%s,%s,%s,%s"
 .text
 .p2align 2,,3
.globl add_record
 .type add_record, @function
add_record:
 pushl %ebp
 movl %esp, %ebp
 subl $424, %esp
 movl $6, -412(%ebp)
 movl $10, -416(%ebp)
 call clear_all_screen
 subl $4, %esp
 pushl $.LC21
 pushl -416(%ebp)
 pushl -412(%ebp)
 call mvprintw
 addl $16, %esp
 leal -412(%ebp), %eax
 addl $2, (%eax)
 subl $4, %esp
 pushl $.LC22
 pushl -416(%ebp)
 pushl -412(%ebp)
 call mvprintw
 addl $16, %esp
 subl $12, %esp
 leal -88(%ebp), %eax
 pushl %eax
 call get_string
 addl $16, %esp
 leal -412(%ebp), %eax
 incl (%eax)
 subl $4, %esp
 pushl $.LC23
 pushl -416(%ebp)
 pushl -412(%ebp)
 call mvprintw
 addl $16, %esp
 subl $12, %esp
 leal -168(%ebp), %eax
 pushl %eax
 call get_string
 addl $16, %esp
 leal -412(%ebp), %eax
 incl (%eax)
 subl $4, %esp
 pushl $.LC24
 pushl -416(%ebp)
 pushl -412(%ebp)
 call mvprintw
 addl $16, %esp
 subl $12, %esp
 leal -248(%ebp), %eax
 pushl %eax
 call get_string
 addl $16, %esp
 leal -412(%ebp), %eax
 incl (%eax)
 subl $4, %esp
 pushl $.LC25
 pushl -416(%ebp)
 pushl -412(%ebp)
 call mvprintw
 addl $16, %esp
 subl $12, %esp
 leal -328(%ebp), %eax
 pushl %eax
 call get_string
 addl $16, %esp
 leal -412(%ebp), %eax
 incl (%eax)
 subl $4, %esp
 pushl $.LC26
 pushl $5
 pushl $15
 call mvprintw
 addl $16, %esp
 subl $8, %esp
 leal -328(%ebp), %eax
 pushl %eax
 leal -248(%ebp), %eax
 pushl %eax
 leal -168(%ebp), %eax
 pushl %eax
 leal -88(%ebp), %eax
 pushl %eax
 pushl $.LC27
 leal -408(%ebp), %eax
 pushl %eax
 call sprintf
 addl $32, %esp
 leal -408(%ebp), %eax
 pushl %eax
 pushl $.LC11
 pushl $5
 pushl $17
 call mvprintw
 addl $16, %esp
 subl $12, %esp
 pushl stdscr
 call wrefresh
 addl $16, %esp
 subl $4, %esp
 pushl $0
 pushl $18
 pushl stdscr
 call wmove
 addl $16, %esp
 call get_confirm
 testl %eax, %eax
 je .L52
 subl $12, %esp
 leal -408(%ebp), %eax
 pushl %eax
 call insert_title
 addl $16, %esp
 subl $8, %esp
 leal -168(%ebp), %eax
 pushl %eax
 pushl $current_cd
 call strcpy
 addl $16, %esp
 subl $8, %esp
 leal -88(%ebp), %eax
 pushl %eax
 pushl $current_cat
 call strcpy
 addl $16, %esp
.L52:
 leave
 ret
 .size add_record, .-add_record
 .section .rodata
.LC28:
 .string "r"
 .p2align 2
.LC29:
 .string "Database contains %d titles, with a total of %d tracks."
 .text
 .p2align 2,,3
.globl count_cds
 .type count_cds, @function
count_cds:
 pushl %ebp
 movl %esp, %ebp
 subl $1064, %esp
 movl $0, -1052(%ebp)
 movl $0, -1056(%ebp)
 subl $8, %esp
 pushl $.LC28
 pushl title_file
 call fopen
 addl $16, %esp
 movl %eax, -12(%ebp)
 cmpl $0, -12(%ebp)
 je .L55
.L56:
 subl $4, %esp
 pushl -12(%ebp)
 pushl $1024
 leal -1048(%ebp), %eax
 pushl %eax
 call fgets
 addl $16, %esp
 testl %eax, %eax
 je .L57
 leal -1052(%ebp), %eax
 incl (%eax)
 jmp .L56
.L57:
 subl $12, %esp
 pushl -12(%ebp)
 call fclose
 addl $16, %esp
.L55:
 subl $8, %esp
 pushl $.LC28
 pushl tracks_file
 call fopen
 addl $16, %esp
 movl %eax, -16(%ebp)
 cmpl $0, -16(%ebp)
 je .L58
.L59:
 subl $4, %esp
 pushl -16(%ebp)
 pushl $1024
 leal -1048(%ebp), %eax
 pushl %eax
 call fgets
 addl $16, %esp
 testl %eax, %eax
 je .L60
 leal -1056(%ebp), %eax
 incl (%eax)
 jmp .L59
.L60:
 subl $12, %esp
 pushl -16(%ebp)
 call fclose
 addl $16, %esp
.L58:
 subl $12, %esp
 pushl -1056(%ebp)
 pushl -1052(%ebp)
 pushl $.LC29
 pushl $0
 pushl $22
 call mvprintw
 addl $32, %esp
 call get_return
 leave
 ret
 .size count_cds, .-count_cds
 .section .rodata
 .p2align 2
.LC30:
 .string "Enter a string to search for in element titles: "
.LC31:
 .string ","
 .p2align 2
.LC32:
 .string "Sorry, no matching element found. "
 .p2align 2
.LC33:
 .string "Sorry, match is ambiguous: %d elements found. "
 .text
 .p2align 2,,3
.globl find_cd
 .type find_cd, @function
find_cd:
 pushl %ebp
 movl %esp, %ebp
 subl $1144, %esp
 movl $0, -1120(%ebp)
 subl $4, %esp
 pushl $.LC30
 pushl $0
 pushl $20
 call mvprintw
 addl $16, %esp
 subl $12, %esp
 leal -88(%ebp), %eax
 pushl %eax
 call get_string
 addl $16, %esp
 subl $8, %esp
 pushl $.LC28
 pushl title_file
 call fopen
 addl $16, %esp
 movl %eax, -1116(%ebp)
 cmpl $0, -1116(%ebp)
 je .L62
.L63:
 subl $4, %esp
 pushl -1116(%ebp)
 pushl $1024
 leal -1112(%ebp), %eax
 pushl %eax
 call fgets
 addl $16, %esp
 testl %eax, %eax
 je .L64
 leal -1112(%ebp), %eax
 movl %eax, -1132(%ebp)
 subl $8, %esp
 pushl $.LC31
 pushl -1132(%ebp)
 call strstr
 addl $16, %esp
 movl %eax, -1124(%ebp)
 cmpl $0, -1124(%ebp)
 je .L63
 movl -1124(%ebp), %eax
 movb $0, (%eax)
 movl -1124(%ebp), %eax
 incl %eax
 movl %eax, -1128(%ebp)
 subl $8, %esp
 pushl $.LC31
 pushl -1128(%ebp)
 call strstr
 addl $16, %esp
 movl %eax, -1124(%ebp)
 cmpl $0, -1124(%ebp)
 je .L63
 movl -1124(%ebp), %eax
 movb $0, (%eax)
 leal -88(%ebp), %eax
 subl $8, %esp
 pushl %eax
 pushl -1128(%ebp)
 call strstr
 addl $16, %esp
 movl %eax, -1124(%ebp)
 cmpl $0, -1124(%ebp)
 je .L63
 leal -1120(%ebp), %eax
 incl (%eax)
 subl $8, %esp
 pushl -1128(%ebp)
 pushl $current_cd
 call strcpy
 addl $16, %esp
 subl $8, %esp
 pushl -1132(%ebp)
 pushl $current_cat
 call strcpy
 addl $16, %esp
 jmp .L63
.L64:
 subl $12, %esp
 pushl -1116(%ebp)
 call fclose
 addl $16, %esp
.L62:
 cmpl $1, -1120(%ebp)
 je .L61
 cmpl $0, -1120(%ebp)
 jne .L69
 subl $4, %esp
 pushl $.LC32
 pushl $0
 pushl $22
 call mvprintw
 addl $16, %esp
.L69:
 cmpl $1, -1120(%ebp)
 jle .L70
 pushl -1120(%ebp)
 pushl $.LC33
 pushl $0
 pushl $22
 call mvprintw
 addl $16, %esp
.L70:
 movb $0, current_cd
 call get_return
.L61:
 leave
 ret
 .size find_cd, .-find_cd
 .section .rodata
.LC34:
 .string "w"
 .text
 .p2align 2,,3
.globl remove_tracks
 .type remove_tracks, @function
remove_tracks:
 pushl %ebp
 movl %esp, %ebp
 subl $1080, %esp
 cmpb $0, current_cd
 jne .L72
 jmp .L71
.L72:
 subl $12, %esp
 pushl $current_cat
 call strlen
 addl $16, %esp
 movl %eax, -1068(%ebp)
 subl $8, %esp
 pushl $.LC28
 pushl tracks_file
 call fopen
 addl $16, %esp
 movl %eax, -12(%ebp)
 cmpl $0, -12(%ebp)
 jne .L73
 jmp .L71
.L73:
 subl $8, %esp
 pushl $.LC34
 pushl temp_file
 call fopen
 addl $16, %esp
 movl %eax, -16(%ebp)
.L74:
 subl $4, %esp
 pushl -12(%ebp)
 pushl $1024
 leal -1064(%ebp), %eax
 pushl %eax
 call fgets
 addl $16, %esp
 testl %eax, %eax
 je .L75
 leal -1064(%ebp), %eax
 subl $4, %esp
 pushl -1068(%ebp)
 pushl %eax
 pushl $current_cat
 call strncmp
 addl $16, %esp
 testl %eax, %eax
 je .L74
 subl $8, %esp
 pushl -16(%ebp)
 leal -1064(%ebp), %eax
 pushl %eax
 call fputs
 addl $16, %esp
 jmp .L74
.L75:
 subl $12, %esp
 pushl -12(%ebp)
 call fclose
 addl $16, %esp
 subl $12, %esp
 pushl -16(%ebp)
 call fclose
 addl $16, %esp
 subl $12, %esp
 pushl tracks_file
 call unlink
 addl $16, %esp
 subl $8, %esp
 pushl tracks_file
 pushl temp_file
 call rename
 addl $16, %esp
.L71:
 leave
 ret
 .size remove_tracks, .-remove_tracks
 .section .rodata
 .p2align 2
.LC35:
 .string "About to remove element %s: %s. "
 .text
 .p2align 2,,3
.globl remove_cd
 .type remove_cd, @function
remove_cd:
 pushl %ebp
 movl %esp, %ebp
 subl $1064, %esp
 cmpb $0, current_cd
 jne .L78
 jmp .L77
.L78:
 call clear_all_screen
 subl $12, %esp
 pushl $current_cd
 pushl $current_cat
 pushl $.LC35
 pushl $0
 pushl $18
 call mvprintw
 addl $32, %esp
 call get_confirm
 testl %eax, %eax
 jne .L79
 jmp .L77
.L79:
 subl $12, %esp
 pushl $current_cat
 call strlen
 addl $16, %esp
 movl %eax, -1052(%ebp)
 subl $8, %esp
 pushl $.LC28
 pushl title_file
 call fopen
 addl $16, %esp
 movl %eax, -12(%ebp)
 subl $8, %esp
 pushl $.LC34
 pushl temp_file
 call fopen
 addl $16, %esp
 movl %eax, -16(%ebp)
.L80:
 subl $4, %esp
 pushl -12(%ebp)
 pushl $1024
 leal -1048(%ebp), %eax
 pushl %eax
 call fgets
 addl $16, %esp
 testl %eax, %eax
 je .L81
 leal -1048(%ebp), %eax
 subl $4, %esp
 pushl -1052(%ebp)
 pushl %eax
 pushl $current_cat
 call strncmp
 addl $16, %esp
 testl %eax, %eax
 je .L80
 subl $8, %esp
 pushl -16(%ebp)
 leal -1048(%ebp), %eax
 pushl %eax
 call fputs
 addl $16, %esp
 jmp .L80
.L81:
 subl $12, %esp
 pushl -12(%ebp)
 call fclose
 addl $16, %esp
 subl $12, %esp
 pushl -16(%ebp)
 call fclose
 addl $16, %esp
 subl $12, %esp
 pushl title_file
 call unlink
 addl $16, %esp
 subl $8, %esp
 pushl title_file
 pushl temp_file
 call rename
 addl $16, %esp
 call remove_tracks
 movb $0, current_cd
.L77:
 leave
 ret
 .size remove_cd, .-remove_cd
 .section .rodata
 .p2align 2
.LC36:
 .string "You must select a element first. "
.LC37:
 .string "element Track Listing/n"
 .p2align 2
.LC38:
 .string "Cursor keys to scroll, RETURN or q to exit"
.LC39:
 .string "RETURN or q to exit"
 .text
 .p2align 2,,3
.globl list_tracks
 .type list_tracks, @function
list_tracks:
 pushl %ebp
 movl %esp, %ebp
 subl $1080, %esp
 movl $0, -1056(%ebp)
 movl $0, -1064(%ebp)
 movl $0, -1072(%ebp)
 cmpb $0, current_cd
 jne .L84
 pushl __stdoutp
 pushl $.LC36
 pushl $0
 pushl $22
 call mvprintw
 addl $16, %esp
 call get_return
 jmp .L83
.L84:
 call clear_all_screen
 subl $12, %esp
 pushl $current_cat
 call strlen
 addl $16, %esp
 movl %eax, -1052(%ebp)
 subl $8, %esp
 pushl $.LC28
 pushl tracks_file
 call fopen
 addl $16, %esp
 movl %eax, -12(%ebp)
 cmpl $0, -12(%ebp)
 jne .L86
 jmp .L83
.L86:
 subl $4, %esp
 pushl -12(%ebp)
 pushl $1024
 leal -1048(%ebp), %eax
 pushl %eax
 call fgets
 addl $16, %esp
 testl %eax, %eax
 je .L87
 leal -1048(%ebp), %eax
 subl $4, %esp
 pushl -1052(%ebp)
 pushl %eax
 pushl $current_cat
 call strncmp
 addl $16, %esp
 testl %eax, %eax
 jne .L86
 leal -1064(%ebp), %eax
 incl (%eax)
 jmp .L86
.L87:
 subl $12, %esp
 pushl -12(%ebp)
 call fclose
 addl $16, %esp
 subl $8, %esp
 pushl $61
 movl -1064(%ebp), %eax
 addl $12, %eax
 pushl %eax
 call newpad
 addl $16, %esp
 movl %eax, -1060(%ebp)
 cmpl $0, -1060(%ebp)
 jne .L89
 jmp .L83
.L89:
 subl $8, %esp
 pushl $.LC28
 pushl tracks_file
 call fopen
 addl $16, %esp
 movl %eax, -12(%ebp)
 cmpl $0, -12(%ebp)
 jne .L90
 jmp .L83
.L90:
 subl $4, %esp
 pushl $.LC37
 pushl $0
 pushl $4
 call mvprintw
 addl $16, %esp
.L91:
 subl $4, %esp
 pushl -12(%ebp)
 pushl $1024
 leal -1048(%ebp), %eax
 pushl %eax
 call fgets
 addl $16, %esp
 testl %eax, %eax
 je .L92
 leal -1048(%ebp), %eax
 subl $4, %esp
 pushl -1052(%ebp)
 pushl %eax
 pushl $current_cat
 call strncmp
 addl $16, %esp
 testl %eax, %eax
 jne .L91
 subl $12, %esp
 leal -1048(%ebp), %eax
 addl -1052(%ebp), %eax
 incl %eax
 pushl %eax
 pushl $.LC11
 pushl $0
 movl -1056(%ebp), %eax
 pushl %eax
 leal -1056(%ebp), %eax
 incl (%eax)
 pushl -1060(%ebp)
 call mvwprintw
 addl $32, %esp
 jmp .L91
.L92:
 subl $12, %esp
 pushl -12(%ebp)
 call fclose
 addl $16, %esp
 cmpl $11, -1056(%ebp)
 jle .L94
 subl $4, %esp
 pushl $.LC38
 pushl $0
 pushl $6
 call mvprintw
 addl $16, %esp
 jmp .L95
.L94:
 subl $4, %esp
 pushl $.LC39
 pushl $0
 pushl $6
 call mvprintw
 addl $16, %esp
.L95:
 subl $12, %esp
 pushl stdscr
 call wrefresh
 addl $16, %esp
 subl $8, %esp
 pushl $1
 pushl stdscr
 call keypad
 addl $16, %esp
 call cbreak
 call noecho
 movl $0, -1068(%ebp)
.L96:
 cmpl $113, -1068(%ebp)
 je .L97
 cmpl $343, -1068(%ebp)
 je .L97
 cmpl $10, -1068(%ebp)
 je .L97
 cmpl $259, -1068(%ebp)
 jne .L98
 cmpl $0, -1072(%ebp)
 jle .L98
 leal -1072(%ebp), %eax
 decl (%eax)
.L98:
 cmpl $258, -1068(%ebp)
 jne .L100
 movl -1072(%ebp), %eax
 addl $12, %eax
 cmpl -1064(%ebp), %eax
 jge .L100
 leal -1072(%ebp), %eax
 incl (%eax)
.L100:
 subl $4, %esp
 pushl $62
 pushl $19
 pushl $2
 pushl $8
 pushl $0
 pushl -1072(%ebp)
 pushl -1060(%ebp)
 call prefresh
 addl $32, %esp
 subl $12, %esp
 pushl stdscr
 call wgetch
 addl $16, %esp
 movl %eax, -1068(%ebp)
 jmp .L96
.L97:
 subl $12, %esp
 pushl -1060(%ebp)
 call delwin
 addl $16, %esp
 subl $8, %esp
 pushl $0
 pushl stdscr
 call keypad
 addl $16, %esp
 call nocbreak
 call echo
.L83:
 leave
 ret
 .size list_tracks, .-list_tracks
 .section .rodata
 .p2align 2
.LC40:
 .string "Re-entering tracks for element. "
.LC41:
 .string "Enter a blank line to finish"
.LC42:
 .string "Track %d: "
.LC43:
 .string "%s,%d,%s/n"
 .text
 .p2align 2,,3
.globl update_cd
 .type update_cd, @function
update_cd:
 pushl %ebp
 movl %esp, %ebp
 subl $136, %esp
 movl $1, -112(%ebp)
 movl $1, -116(%ebp)
 call clear_all_screen
 subl $4, %esp
 pushl $.LC40
 pushl $0
 pushl $18
 call mvprintw
 addl $16, %esp
 call get_confirm
 testl %eax, %eax
 jne .L103
 jmp .L102
.L103:
 subl $4, %esp
 pushl $0
 pushl $18
 pushl stdscr
 call wmove
 addl $16, %esp
 subl $12, %esp
 pushl stdscr
 call wclrtoeol
 addl $16, %esp
 call remove_tracks
 subl $4, %esp
 pushl $.LC41
 pushl $0
 pushl $6
 call mvprintw
 addl $16, %esp
 subl $8, %esp
 pushl $.LC18
 pushl tracks_file
 call fopen
 addl $16, %esp
 movl %eax, -12(%ebp)
 subl $12, %esp
 pushl $1
 pushl $7
 pushl $62
 pushl $13
 pushl stdscr
 call subwin
 addl $32, %esp
 movl %eax, -120(%ebp)
 cmpl $0, -120(%ebp)
 jne .L104
 jmp .L102
.L104:
 subl $12, %esp
 pushl $0
 pushl $0
 pushl $0
 pushl $0
 pushl acs_map+452
 pushl acs_map+452
 pushl acs_map+480
 pushl acs_map+480
 pushl -120(%ebp)
 call wborder
 addl $48, %esp
 subl $12, %esp
 pushl $2
 pushl $8
 pushl $60
 pushl $11
 pushl stdscr
 call subwin
 addl $32, %esp
 movl %eax, -124(%ebp)
 cmpl $0, -124(%ebp)
 jne .L105
 jmp .L102
.L105:
 subl $8, %esp
 pushl $1
 pushl -124(%ebp)
 call scrollok
 addl $16, %esp
 subl $12, %esp
 pushl -124(%ebp)
 call werase
 addl $16, %esp
 pushl $1
 cmpl $0, stdscr
 je .L106
 movl stdscr, %eax
 movswl 4(%eax),%eax
 movl %eax, -128(%ebp)
 movl -128(%ebp), %eax
 incl %eax
 movl %eax, -128(%ebp)
 jmp .L107
.L106:
 movl $-1, -128(%ebp)
.L107:
 pushl -128(%ebp)
 pushl $0
 pushl stdscr
 call wtouchln
 addl $16, %esp
.L108:
 subl $12, %esp
 pushl -112(%ebp)
 pushl $.LC42
 pushl $4
 movl -116(%ebp), %eax
 pushl %eax
 leal -116(%ebp), %eax
 incl (%eax)
 pushl -124(%ebp)
 call mvwprintw
 addl $32, %esp
 subl $12, %esp
 pushl stdscr
 call wclrtoeol
 addl $16, %esp
 subl $12, %esp
 pushl stdscr
 call wrefresh
 addl $16, %esp
 subl $4, %esp
 pushl $80
 leal -104(%ebp), %eax
 pushl %eax
 pushl -124(%ebp)
 call wgetnstr
 addl $16, %esp
 leal -104(%ebp), %eax
 subl $12, %esp
 pushl %eax
 call strlen
 addl $16, %esp
 movl %eax, -108(%ebp)
 cmpl $0, -108(%ebp)
 jle .L111
 leal -105(%ebp), %eax
 addl -108(%ebp), %eax
 cmpb $10, (%eax)
 jne .L111
 leal -105(%ebp), %eax
 addl -108(%ebp), %eax
 movb $0, (%eax)
.L111:
 cmpb $0, -104(%ebp)
 je .L112
 subl $12, %esp
 leal -104(%ebp), %eax
 pushl %eax
 pushl -112(%ebp)
 pushl $current_cat
 pushl $.LC43
 pushl -12(%ebp)
 call fprintf
 addl $32, %esp
.L112:
 leal -112(%ebp), %eax
 incl (%eax)
 cmpl $10, -116(%ebp)
 jle .L110
 subl $8, %esp
 pushl $1
 pushl -124(%ebp)
 call wscrl
 addl $16, %esp
 leal -116(%ebp), %eax
 decl (%eax)
.L110:
 cmpb $0, -104(%ebp)
 je .L109
 jmp .L108
.L109:
 subl $12, %esp
 pushl -124(%ebp)
 call delwin
 addl $16, %esp
 subl $12, %esp
 pushl -12(%ebp)
 call fclose
 addl $16, %esp
.L102:
 leave
 ret
 .size update_cd, .-update_cd
 .local current_cat
 .comm current_cat,80,32
 .ident "GCC: (GNU) 3.4.6 [FreeBSD] 20060305"

 

供大家学习汇编之用

说明:执行环境FreeBSD_6.2 Linux_2.6内核级LINUX

我的开发环境:FreeBSD_6.2_RELEASE

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值