Author Topic: Error checking on Linux  (Read 712 times)

GoneFishing

  • Member
  • *****
  • Posts: 1056
  • Gone fishing
Error checking on Linux
« on: January 04, 2018, 07:39:26 PM »
Hi,

Attachment contains sources and binaries for 3 small  programs:

Error :  prints out all known  errno's  and corresponding error messages
fnf      :  tries to open non-existent file and shows error message by calling error , error_at_line or perror   
             depending on user choice ( read comments in fnf.asm )
fnfc    : tries to open non-existent file and shows error message . Demonstrates usage of GCC magic constant  -   
             __FUNCTION__

NOTE: UASM has new builtin variable @ProcLine . Would it be logical to implement something like
                       @CurrProc or @ProcName   ?                                 

             

jj2007

  • Member
  • *****
  • Posts: 8618
  • Assembler is fun ;-)
    • MasmBasic
Re: Error checking on Linux
« Reply #1 on: January 04, 2018, 09:05:26 PM »
@Line has been around for a while, and @ProcName can be implemented in the PROLOG:
Code: [Select]
include \Masm32\MasmBasic\Res\JBasic.inc ; ## console demo, builds in 32- or 64-bit mode with ML, UAsm, AsmC ##
.code
MyTest proc
  nop
  % echo ## the name of this procedure is jbProc$ ## ; see build output
  tmp$ CATSTR <Str$("This is proc >, jbProc$, < starting in line %i\n", jbPrologRun)>
  Print tmp$
  ret
MyTest endp
Init ; OPT_64 1 ; 1=use 64 bit assembly
  PrintLine Chr$("This code was assembled with ", @AsmUsed$(1), " in ", jbit$, "-bit format")
  jinvoke MyTest
  Inkey "That was easy"
EndOfCode

Output:
Code: [Select]
This code was assembled with ml64 in 64-bit format
This is proc MyTest starting in line 3
That was easy

GoneFishing

  • Member
  • *****
  • Posts: 1056
  • Gone fishing
Re: Error checking on Linux
« Reply #2 on: January 04, 2018, 09:16:00 PM »
@Line has been around for a while ...

@ProcLine is a little bit different :
Quote from: uasm246_ext.pdf
@ProcLine, indicates the current source code line number relative to the start of the current procedure. 

Can you post source code for your jbProc ?



jj2007

  • Member
  • *****
  • Posts: 8618
  • Assembler is fun ;-)
    • MasmBasic
Re: Error checking on Linux
« Reply #3 on: January 04, 2018, 09:33:48 PM »
Relative to the proc start is easy. too:
Code: [Select]
include \Masm32\MasmBasic\Res\JBasic.inc ; ## console demo, builds in 32- or 64-bit mode with ML, UAsm, AsmC ##
.code









MyTest proc
  nop
  % echo ## the name of this procedure is jbProc$ ## ; see build output
  tmp$ CATSTR <Str$("This is proc >, jbProc$, < starting in line %i\n", @Line-jbPrologRun)>
  Print tmp$
  ret
MyTest endp

Output:
Code: [Select]
This is proc MyTest starting in line 4
Can you post source code for your jbProc ?
It's included in the MasmBasic package as \Masm32\MasmBasic\Res\JBasic.inc

GoneFishing

  • Member
  • *****
  • Posts: 1056
  • Gone fishing
Re: Error checking on Linux
« Reply #4 on: January 04, 2018, 09:57:19 PM »
Thanks. I'll look into JBasic.inc

Now let's wait for  JOHNSA 

EDIT: Oh, I've forgotten that I had already played with this kind of helper macro for obtaining proc name. It was easy.  Still having   builtin little magic trick like  @ProcName or @CurrProcName or @ProcCurr would be great !
 

johnsa

  • Member
  • ****
  • Posts: 686
    • Uasm
Re: Error checking on Linux
« Reply #5 on: January 05, 2018, 03:51:56 AM »
Hey,

We can definitely add it in. I will do so and include it in the next update. @ProcName ok with everyone?

johnsa

  • Member
  • ****
  • Posts: 686
    • Uasm
Re: Error checking on Linux
« Reply #6 on: January 08, 2018, 03:20:23 AM »
@ProcName is in,  the stack alignment issue is sorted and a bunch of other pending changes. 2.46.6 packages are up :)

GoneFishing

  • Member
  • *****
  • Posts: 1056
  • Gone fishing
Re: Error checking on Linux
« Reply #7 on: January 08, 2018, 03:51:49 AM »
Great!
I'll  check it tomorrow .