Answer to Question #257361 in Assembler for joe

Question #257361

write a function B() in assembly lang programming which takes the argument as 64 bit integer. It should interpret that as a 8-byte ASCII string and print individual

characters on screen. You need to call the write() system call from assembly language using the syscall instruction, passing appropriate arguments.

Modify the stack in the function B() in such a way that when B() executes

the ret instruction, it jumps to a third function C(). C() must also be

written in C.


1
Expert's answer
2021-11-04T16:26:59-0400
; que.asm
; Assemble:    nasm -f elf64 -l que.lst  que.asm
; Link:        gcc -o que  que.o
; Run:        ./que

   SECTION .data
strc:    db 10,13,"func c()",10,13,0
str:    dd 0
    
   SECTION .text           ; Code section.
   global main    
main:                
     mov rax,0x3031323334353637    ;;64 bits integer
     mov rbx, c  
     push rbx
    call b
;***************************
  b:
;***************************
    mov [str], rax
    
; sys_write
    mov eax,4
    mov ebx,1
    mov ecx, str
    mov edx,8
    int 80h
    
    pop rax
    ret
;***************************
  c:
;***************************
; sys_write:  "func c()"
    mov eax,4
    mov ebx,1
    mov ecx, strc
    mov edx,13
    int 80h

; sys_exit    
    mov rax,1
    mov rbx,0
    int 80h

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS