Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Other Discussions
  3. IT & Infrastructure
  4. more assembly

more assembly

Scheduled Pinned Locked Moved IT & Infrastructure
data-structuresquestion
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Sirrius
    wrote on last edited by
    #1

    Is there a conversion for this at&t syntax into nasm?

    .LC0:
    .ascii "The date is: %s\0"

    _ByteSwap4_asm:

    I don't know if this is enough code to figure it out. I did'nt want to put the entrie page up. It's just supposed to display the time with call in code. .LCO gets pushed on the stack. Thanks.

    Z 1 Reply Last reply
    0
    • S Sirrius

      Is there a conversion for this at&t syntax into nasm?

      .LC0:
      .ascii "The date is: %s\0"

      _ByteSwap4_asm:

      I don't know if this is enough code to figure it out. I did'nt want to put the entrie page up. It's just supposed to display the time with call in code. .LCO gets pushed on the stack. Thanks.

      Z Offline
      Z Offline
      ZoogieZork
      wrote on last edited by
      #2

      Something like this?

      .LC0:
      DB 'The date is: %s',0

      - Mike

      S 1 Reply Last reply
      0
      • Z ZoogieZork

        Something like this?

        .LC0:
        DB 'The date is: %s',0

        - Mike

        S Offline
        S Offline
        Sirrius
        wrote on last edited by
        #3

        Well yet another road block for this rookie in assembly coding. I am getting compile errors that say symbol time is undefined and _ctime,_printf,_LCO as well are undefined. I cant figure out why, I have rearranged the global and text labels with no prevail. Maybe one of you guys can spot the idiot flaw that I can't.

        ; .file "ByteSwap4.c"
        global _ByteSwap4_asm
        section .text
        LC0:
        DB "The date is: %s",0

        _ByteSwap4_asm:
        push ebp ;pushl %ebp
        mov ebp,esp ;movl %esp, %ebp
        sub esp,24 ;subl $24, %esp
        sub esp,12 ;subl $12, %esp
        lea eax,[ebp-4] ;leal -4(%ebp), %eax
        push eax ;pushl %eax
        call time ;call _time
        add esp,16 ;addl $16, %esp
        sub esp,8 ;subl $8, %esp
        sub esp,4 ;subl $4, %esp
        lea eax,[ebp-4] ;leal -4(%ebp), %eax
        push eax ;pushl %eax
        call _ctime ;call _ctime
        add esp,8 ;addl $8, %esp
        push eax ;pushl %eax
        push dword _LCO ;pushl $LC0
        call printf ;call _printf
        add esp,16 ;addl $16, %esp
        mov [ebp-8],0 ;movl $0, -8(%ebp)
        L2:
        mov eax,[ebp-8] ;movl -8(%ebp), %eax
        cmp eax,[ebp+8] ;cmpl 8(%ebp), %eax
        jl L5
        jmp L1
        L5:
        mov eax,[ebp-8] ;movl -8(%ebp), %eax
        lea edx,[eax*4] ;leal 0(,%eax,4), %edx
        mov eax,[ebp+12] ;movl 12(%ebp), %eax
        mov eax,[eax+edx] ;movl (%eax,%edx), %eax
        mov [ebp-12],eax ;movl %eax, -12(%ebp)
        mov al,[ebp-ebp] ;movb -12(%ebp), %al
        mov [ebp-13],al ;movb %al, -13(%ebp)
        mov al,[ebp-11] ;movb -11(%ebp), %al
        mov [ebp-14],al ;movb %al, -14(%ebp)
        mov al,[ebp-10] ;movb -10(%ebp), %al
        mov [ebp-15],al ;movb %al, -15(%ebp)
        mov al,[ebp-9] ;movb -9(%ebp), %al
        mov [ebp-16],al ;movb %al, -16(%ebp)
        mov eax,[ebp-8] ;movl -8(%ebp), %eax
        lea ecx,[eax*4] ;leal 0(,%eax,4), %ecx
        mov edx,[ebp+12] ;movl 12(%ebp), %edx
        mov eax,[ebp-16] ;movl -16(%ebp), %eax
        mov [edx+ecx],eax ;movl %eax, (%edx,%ecx)
        lea eax,[ebp-8] ;leal -8(%ebp), %eax
        inc dword [eax] ;incl (%eax)
        jmp L2
        L1:
        leave
        ret

        ;.ident	"GCC: (GNU) 3.2.3"
        
        S 1 Reply Last reply
        0
        • S Sirrius

          Well yet another road block for this rookie in assembly coding. I am getting compile errors that say symbol time is undefined and _ctime,_printf,_LCO as well are undefined. I cant figure out why, I have rearranged the global and text labels with no prevail. Maybe one of you guys can spot the idiot flaw that I can't.

          ; .file "ByteSwap4.c"
          global _ByteSwap4_asm
          section .text
          LC0:
          DB "The date is: %s",0

          _ByteSwap4_asm:
          push ebp ;pushl %ebp
          mov ebp,esp ;movl %esp, %ebp
          sub esp,24 ;subl $24, %esp
          sub esp,12 ;subl $12, %esp
          lea eax,[ebp-4] ;leal -4(%ebp), %eax
          push eax ;pushl %eax
          call time ;call _time
          add esp,16 ;addl $16, %esp
          sub esp,8 ;subl $8, %esp
          sub esp,4 ;subl $4, %esp
          lea eax,[ebp-4] ;leal -4(%ebp), %eax
          push eax ;pushl %eax
          call _ctime ;call _ctime
          add esp,8 ;addl $8, %esp
          push eax ;pushl %eax
          push dword _LCO ;pushl $LC0
          call printf ;call _printf
          add esp,16 ;addl $16, %esp
          mov [ebp-8],0 ;movl $0, -8(%ebp)
          L2:
          mov eax,[ebp-8] ;movl -8(%ebp), %eax
          cmp eax,[ebp+8] ;cmpl 8(%ebp), %eax
          jl L5
          jmp L1
          L5:
          mov eax,[ebp-8] ;movl -8(%ebp), %eax
          lea edx,[eax*4] ;leal 0(,%eax,4), %edx
          mov eax,[ebp+12] ;movl 12(%ebp), %eax
          mov eax,[eax+edx] ;movl (%eax,%edx), %eax
          mov [ebp-12],eax ;movl %eax, -12(%ebp)
          mov al,[ebp-ebp] ;movb -12(%ebp), %al
          mov [ebp-13],al ;movb %al, -13(%ebp)
          mov al,[ebp-11] ;movb -11(%ebp), %al
          mov [ebp-14],al ;movb %al, -14(%ebp)
          mov al,[ebp-10] ;movb -10(%ebp), %al
          mov [ebp-15],al ;movb %al, -15(%ebp)
          mov al,[ebp-9] ;movb -9(%ebp), %al
          mov [ebp-16],al ;movb %al, -16(%ebp)
          mov eax,[ebp-8] ;movl -8(%ebp), %eax
          lea ecx,[eax*4] ;leal 0(,%eax,4), %ecx
          mov edx,[ebp+12] ;movl 12(%ebp), %edx
          mov eax,[ebp-16] ;movl -16(%ebp), %eax
          mov [edx+ecx],eax ;movl %eax, (%edx,%ecx)
          lea eax,[ebp-8] ;leal -8(%ebp), %eax
          inc dword [eax] ;incl (%eax)
          jmp L2
          L1:
          leave
          ret

          ;.ident	"GCC: (GNU) 3.2.3"
          
          S Offline
          S Offline
          Steve S
          wrote on last edited by
          #4

          your push dword _LCO should probably be without the "_", since your symbol earlier doesn't include that. There's no reference anywhere that says what _ctime or _printf or time are. You know they're in a library somewhere, but NASM doesn't. In MASM you'd use EXTRN to declare them, so presumably NASM has a similar facility? Steve S

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups