Author Topic: need to delay deleting a message  (Read 3451 times)

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2359
  • Country: us
Re: need to delay deleting a message
« Reply #15 on: March 14, 2016, 06:10:40 PM »
Code: [Select]
;section text
mov rdi,struc
mov rsi,struc
   call nanosleep

You want the name of the structure, "mytime", not the macro "struc" here.

Best,
Frank


Offline jackjps

  • Jr. Member
  • *
  • Posts: 60
Re: need to delay deleting a message
« Reply #16 on: March 14, 2016, 09:54:15 PM »
Code: [Select]
      3-14-2016

Thanks Frank,
This gave the following errors in 64-bit
during the compile:

demo64.asm:114: error: parser: instruction expected
demo64.asm:117: error: (endstruc:1) `%$strucname': context stack is empty
demo64.asm:117: error: (endstruc:1) `%$strucname': context stack is empty
demo64.asm:117: error: (endstruc:1) `%$strucname_size': context stack is empty
demo64.asm:117: error: (endstruc:1) `%$strucname': context stack is empty
demo64.asm:117: error: (endstruc:1) `%$strucname_size': context stack is empty
demo64.asm:117: error: (endstruc:1) `%$strucname': context stack is empty
demo64.asm:117: error: label or instruction expected at start of line
demo64.asm:117: error: (endstruc:2) `%pop': context stack is empty
demo64.asm:119: error: symbol `mytime' redefined
demo64.asm:120: error: non-constant argument supplied to TIMES
demo64.asm:121: error: non-constant argument supplied to TIMES



;section data
extern nanosleep

114 mytime timespec
115   tv_sec resd 1
116    tv_nsec resd 1
117endstruc

119 mytime istruc timespec
120   at tv_sec, dd 5
121    at tv_nsec, dd 0

;section text
mov rdi,struc
mov rsi,struc
   call nanosleep

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2359
  • Country: us
Re: need to delay deleting a message
« Reply #17 on: March 15, 2016, 07:12:08 AM »
May not actually work, but it assembles.

Code: [Select]
;section data
extern nanosleep

struc timespec
  tv_sec resd 1
  tv_nsec resd 1
endstruc

mytime istruc timespec
   at tv_sec, dd 5
   at tv_nsec, dd 0
iend

;section text
mov rdi,mytime
mov rsi,mytime
   call nanosleep

Best,
Frank


Offline jackjps

  • Jr. Member
  • *
  • Posts: 60
Re: need to delay deleting a message
« Reply #18 on: March 15, 2016, 10:16:20 AM »
Thanks for responding  Frank,

I had to make this change to the struc to get it to work:
    tv_sec resd 5

struc timespec
  tv_sec resd 1?????
  tv_nsec resd 1
endstruc

Since I don't know what I am doing, is this correct??

The process is to put an error message on the screen and let the user
have time to read it. Then I delete the message.



« Last Edit: March 15, 2016, 11:43:36 AM by jackjps »

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2359
  • Country: us
Re: need to delay deleting a message
« Reply #19 on: March 15, 2016, 05:07:05 PM »
I don't know. My 32-bit man page says "time_t" for the seconds and "long" for nanoseconds. I tried to look up "time_t" and I still can't say I know...
http://stackoverflow.com/questions/471248/what-is-ultimately-a-time-t-typedef-to
I don't see any reason why we should reserve any more than 8 bytes, tops. Maybe you've got a really long error message, or a really slow-reading user. I'm an old geezer, and 2038 does not seem like a problem to me. :)

If one way works and the other doesn't, go with the way that works!

Best,
Frank