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

display state of registers in nasm?

hi i have been able to display contents if data register but i want to display the states of the flags registers .my code is below it is not displayin state of registers.

 

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

mov eax,msg         ; moves message "rubi" to eax register
mov [reg],eax       ; moves message from eax to reg 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, 100
mov ebx, 100
cmp ebx,eax

pushf
pop dword eax

mov [save_flags],eax

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


mov eax, 1      ;system call number (sys_exit)
int 0x80        ;call kernel

section .data

msg db "rubi",10

section .bss

reg resb 100

save_flags resw 100

 

asked Dec 2, 2015 by harry_007

1 Answer

sys_write doesn't convert integers into strings for you - you have to do that yourself (or call printf instead of using system calls) . Btw, when you say "I have been able to display contents if data register", that doesn't really appear to be true judging by your code. What you seem to be doing is displaying the contents of some memory pointed to by a register. I am no expert in assembly, you should probably check this link Display contents of register.

answered Dec 2, 2015 by Swanky
...