DEV Community

Smit Gabani
Smit Gabani

Posted on

SPO600 Lab 4 - Part 2: x86_64

  • Connecting to israel server.
ssh username@portugal.cdot.systems // replace username with your username.
Enter fullscreen mode Exit fullscreen mode
  • Copy and unpack tarball, which for a windows user like me can be a new experience.
cp /public/filename ~
tar -xvzf filename
Enter fullscreen mode Exit fullscreen mode
  • Modify the loop to run until 30 iterations (which took hours for me)

We need more steps to make the division work which makes the code longer and harder to make it work.

My x86_64 code:

.text
.globl  _start

min = 0                         
max = 30                       

_start:

        mov     $min,%r15           
        mov     $10, %r14
    mov     $10, %r13
        mov     %r15,%r13       
        mov     %r15,%r14      

        mov     $10,%r8
        movq    $len,%rdx                      


loop:

        mov     $0, %r11
            mov     %r9, %r12

            div     %r8    

        add     $'0',%12

        movb    %r14b,msg+6     


inner: 

        add     $'0', %11
        movb    %r13b,msg+7 



             movq    $msg,%rsi                      
            movq    $1,%rdi                        
        movq    $1,%rax                        
        syscall


        inc     %r15                
        cmp     $max,%r15           
        jne     loop                



        movq    $0,%rdi                        
        movq    $60,%rax                       
        syscall

.section .data

msg:    .ascii      "Loop: ##\n"
        len = . - msg
Enter fullscreen mode Exit fullscreen mode

The code did not work for me on the portugal server.

Top comments (0)