Question

Generate program listing file (.lst) for the following code NASM code: section .data dividend db 00000101b...

Generate program listing file (.lst) for the following code NASM code:


section .data

dividend db 00000101b   
divisor db 00000101b

section .bss

quotient resb 1

remainder resb 1

section .text
global _start

_start:
instruction1: cmp byte [divisor] , 0
instruction2: je exit
    mov al, [dividend]
    mov bl, 0   
again: cmp al, [divisor]
jb done
inc bl   
sub al, [divisor]   
jmp again
done: mov [quotient] , al
mov [remainder], bl   
  
exit: mov eax,1
mov ebx,0
int 80h

0 0
Add a comment Improve this question Transcribed image text
Answer #1

List file is basically a file containing the detailed information of a program line by line.

To generate (*.lst) file of a program, we need to compile the program with the following command:

nasm -f elf -l filename.lst filename.asm

Here filename is prog.asm and further details can be seen in the screenshots.

Given program:

Compilation of the program and list the generated files in the directory:

In the file prog.lst

So, the generated (.lst) file contains the line numbers and some additional information like first column source code line number, the second column contains addresses/offsets. And third column contains a binary value.

Translated code is given below for easy access, screenshots are for better understanding.

     1                                
     2                                  section .data
     3                                
     4 00000000 05                      dividend db 00000101b
     5 00000001 05                      divisor db 00000101b
     6                                
     7                                  section .bss
     8                                
     9 00000000 <res 00000001>          quotient resb 1
    10                                
    11 00000001 <res 00000001>          remainder resb 1
    12                                
    13                                  section .text
    14                                  global _start
    15                                
    16                                  _start:
    17 00000000 803D[01000000]00        instruction1: cmp byte [divisor] , 0
    18 00000007 7424                    instruction2: je exit
    19 00000009 A0[00000000]                mov al, [dividend]
    20 0000000E B300                        mov bl, 0
    21 00000010 3A05[01000000]          again: cmp al, [divisor]
    22 00000016 720A                    jb done
    23 00000018 FEC3                    inc bl
    24 0000001A 2A05[01000000]          sub al, [divisor]
    25 00000020 EBEE                    jmp again
    26 00000022 A2[00000000]            done: mov [quotient] , al
    27 00000027 881D[01000000]          mov [remainder], bl
    28                                  
    29 0000002D B801000000              exit: mov eax,1
    30 00000032 BB00000000              mov ebx,0
    31 00000037 CD80                    int 80h

Add a comment
Know the answer?
Add Answer to:
Generate program listing file (.lst) for the following code NASM code: section .data dividend db 00000101b...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT