GfG QA is closing soon... Please refer PRACTICE or GfG now on wards !!

Write an assembly language program that displays the register states while processes run.

the program should be in nasm assembler. 

1) explain what is question really about?

2) what are register states?

3)the code should include comments for each purpose.


hi this is my code in nasm to print contents inside the data registers . how will i print the content or address of pointer registers to screen or segment registers and to display if flag is set or not

section .text
global _start       ;must be declared for using gcc
_start :                     ;tell linker entry point

    mov eax,msg  ;stores the data to register
    mov [reg],eax  ;moves data from register to variable

mov edx, 8     ;message length
mov ecx, reg  ; message to write
mov ebx, 1      ;file descriptor (stdout)
mov eax, 4      ;system call number (sys_write)
int 0x80           ;call kernel
mov eax, 1      ;system call number (sys_exit)
int 0x80         ;call kernel

section .data

msg db "rubi",10

section .bss

reg resb 100

asked Nov 19, 2015 by harry_007
edited Dec 1, 2015 by harry_007

1 Answer

  • An assembly language (or assembler language) is a low-level programming language for a computer, or other programmable device, in which there is a very strong (generally one-to-one) correspondence between the language and the architecture's machine code instructions.
  • To speed up the processor operations, the processor includes some internal memory storage locations, called registers. The registers store data elements for processing without having to access the memory. A limited number of registers are built into the processor chip.
  • By register state we mean the information stored in the register at some point in time. If the register is data/segment/index register than we go for the data stored in it. If it's a control register ( flag ) than we see whether it's set or not.

Your question is all about write an assembly language program to print the data stored in registers ( which are being used ) while the program executes. I wrote some assembly language programs in my early semesters but I don't remember the syntax now (as I'm not an ECE guy ) so couldn't provide you the code for the same.  

answered Nov 19, 2015 by Swanky
edited Nov 19, 2015 by Swanky

hi i appreciate. so your telling me i can write any program in assembly like addition and subtraction and so on but print the data stored in registers like before and after .  is that all the question is asking?

Yup .. Its mentioned that display the register states while process executes. So, I guess you need to display the content of registers being used at each step.


ok. let me try coding if i stuck somewhere then i'll ask.

thanks alot.