Author Topic: beginner questions  (Read 57731 times)

Offline jackjps

  • Jr. Member
  • *
  • Posts: 60
Re: beginner questions
« Reply #75 on: March 22, 2016, 10:40:17 AM »
Hi Bryant,
                        3-22-2016
This is the response I got so far from the linux mint forum.
I have no idea what they are talking about.
I don't know if I already have Dolphin on my Linux or how to get it.

The link below explains how to use chmod to set permissions for an additional drive. This particular article references an external drive but the process is basically the same for an additional internal drive.

http://stackoverflow.com/questions/2058 ... ing-access

Alternatively you can install the Dolphin file manager GUI, open a command prompt with #sudo dolphin, enter your password, then when the GUI opens, right click on the drive, click Permissions and select the option to share with all users.
Top
User avataradministrollaattori
Level 9
Level 9
Re: separate drive for linux mint
PostMon Mar 21, 2016 4:11 pm

What tells commands
CODE: SELECT ALL
lsblk
cat /etc/fstab

Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: beginner questions
« Reply #76 on: March 24, 2016, 03:52:38 AM »
I've personally never heard of Dolphin, but it appears to be a KDE file manager. Basically, they are telling you to open the Dolphin file manager with administrative privileges using sudo dolphin, right click on the drive and click the "Permissions" tab to select the option to "share with all users". Personally, I use FXCE desktop with Thunar file manager. The process is similar with it; run Thunar with administrative privileges using sudo Thunar (yes, that's capital T). This will give you a window that has a yellows bar saying "Warning, you are using the root account, you may harm your system". Use that file manager to navigate to the directory your files are at and Right Click in an empty space of the folder and click "Properties" at the bottom of the context menu. A dialog will appear and click "Permissions" tab. Under the "Permissions" tab, change the "Others:" option to "Read & Write", close the dialog, then close Thunar file manager. Hopefully, that should fix it.

About Bryant Keller
bkeller@about.me

Offline jackjps

  • Jr. Member
  • *
  • Posts: 60
Re: beginner questions
« Reply #77 on: March 24, 2016, 08:33:25 AM »
Code: [Select]
Hi Bryant,
1. Got it to work using your stuff. I think.
    Now if Linux Mint gets corrupted I'll be able to reinstall it
   without losing the goodies in NASM.
   I compiled the demo64 program on the HD separate from Linux.
  That worked fine. When I tried to execute the program I got 
  the following:

jack@jack-myheadache /media/jack/NASM/nasmfld $ ./demo64
bash: ./demo64: Permission denied
jack@jack-myheadache /media/jack/NASM/nasmfld $

   Is it possible that I was not in administrator mode??
   Don't know how to get there in Linux..... 

2.  Trying to understand your explanation of adding colors to the screen.
     When I do man wchgat all I get is a screen showing data for "attr"?
     
3.  In Masm32 I avoided Macros like the plague. I like to see, in my code,
     the full code for anything that needs repeated. I would write it once
     and branch to and return from it as many times as needed. This way I
     don't have to go digging for what the macro does and it's parameters.
     In NASM I have trouble knowing what is a marco and what are it's
     parameters and where to find data on the macro.
     This is my problem right now with "get_cur_coord".   
     Thanks for your help.
« Last Edit: March 25, 2016, 07:52:08 PM by jackjps »

Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: beginner questions
« Reply #78 on: March 27, 2016, 12:56:43 AM »
Hi Bryant,
1. Got it to work using your stuff. I think.
    Now if Linux Mint gets corrupted I'll be able to reinstall it
   without losing the goodies in NASM.
   I compiled the demo64 program on the HD separate from Linux.
  That worked fine. When I tried to execute the program I got 
  the following:

jack@jack-myheadache /media/jack/NASM/nasmfld $ ./demo64
bash: ./demo64: Permission denied
jack@jack-myheadache /media/jack/NASM/nasmfld $

   Is it possible that I was not in administrator mode??
   Don't know how to get there in Linux..... 

Maybe you should try this command:

Code: [Select]
$ sudo chown -R jack /media/jack
That should recursively scan through all files and directories in /media/jack and make the file/directories' owner jack.

2.  Trying to understand your explanation of adding colors to the screen.
     When I do man wchgat all I get is a screen showing data for "attr"?

Documentation for that routine is in the same manual entry for all attribute changing routines (including attron, attroff, etc.) Scrolling down a bit, you'll see the Synopsis for wchgat is:

Quote from: man wchgat
       int wchgat(WINDOW *win, int n, attr_t attr,
             short color, const void *opts)

And the explanation is bit further down:

Quote from: man wchgat
       The routine chgat changes the attributes of a given number  of  charac?
       ters  starting  at  the current cursor location of stdscr.  It does not
       update the cursor and does not perform wrapping.  A character count  of
       -1  or  greater  than  the  remaining  window width means to change at?
       tributes all the way to the end of the current line. The wchgat  func?
       tion  generalizes this to any window; the mvwchgat function does a cur?
       sor move before acting.  In these functions, the color  argument  is  a
       color-pair  index  (as  in  the  first  argument of init_pair, see col?
       or
(3NCURSES)).  The opts argument is not presently  used,  but  is  re?
       served for the future (leave it NULL).

The striked out section should be ignored. The features of NCURSES documented with the 'mv' prefix are implemented as C macros, so in assembly you have to call the wmove procedure separately.

3.  In Masm32 I avoided Macros like the plague. I like to see, in my code,
     the full code for anything that needs repeated. I would write it once
     and branch to and return from it as many times as needed. This way I
     don't have to go digging for what the macro does and it's parameters.
     In NASM I have trouble knowing what is a marco and what are it's
     parameters and where to find data on the macro.
     This is my problem right now with "get_cur_coord".   
     Thanks for your help.

There is no need to "dig" for what the macro does and it's parameters, I gave you the macro, I told you the parameters.
Do us both a favor and re-read the reply I referred you to. For clarity, I'll repost the link:

http://forum.nasm.us/index.php?topic=2204.msg9799#msg9799

I'll take partial blame for this, maybe it's my coding style that is throwing you off. I'll give you a quick introduction into the process I use to create procedures and/or macros. From this point on, I'll refer to procedures and macros as processes, not to be confused with tasks which are sometimes also called processes.. In any event, just note that when I use the word process in the following, I mean any type of procedure, function, or macro.

Step 1. - Interface Specification.

An interface specification is a contract you make with other developers (or yourself) about how the code you plan to write will be used. In general, the interface specification needs to define the name of the process, the inputs that are consumed by the process, and the outputs that are produced as a result of the process' execution. There are many styles of writing interface specifications, but the one I use is the single-line form:

Code: [Select]
;; process_name : inputs -> outputs
When you see this type of interface specification, it reads as "process_name consumes inputs and produces outputs". So, for example, when I wrote get_cur_coord macro, I began by writing the comment line:

Code: (get_cur_coord) [Select]
;; get_cur_coord : window_handle -> { x y }
Like before, this should read as "get_cur_coord consumes window_handle and produces x and y". This means that the macro takes a single argument (the window handle) and returns to you the values of X and Y.

Step 2. - Process Description.

This is a very important step! Many programmers will skip that first step assuming that the reader of the source code can infer from context the inputs and outputs, but no programmers with any real experience will leave out the process description in software they expect people to regularly use. The process description extends on the interface specification by giving a general description of what the process expects to accomplish. This is usually a paragraph that appears just below the interface specification. People who leave out the interface specification are usually taught to put this description within the code block before any actual code (you'll see people do that a lot in Visual Basic). I use my interface specifications, so I put it after them. In our get_cur_coord example, it reads;

Code: (get_cur_coord) [Select]
;; Obtains the current X and Y coordinates from a window handle
;; and returns the current X coordinate in rax and the current
;; Y coordinate in rbx.

This process description tells you that this process will obtain an X and Y coordinate from a window handle, then goes on to further explain that the X value will be located in the RAX register and the Y value in the RBX. From this description, you should be able to infer how to use the process. If we write the code:

Code: [Select]
get_cur_coord [hWindow]
After this process, the value of RAX is the X coordinate and the value of RBX is the Y coordinate.

Step 3. - Examples.

I think this is where I messed up in my code, I left this part out. When i post code on the forum, I tend to remove this comment to reduce the overall code size. I have a tendency to be verbose, or long-winded to use a local term, and I regularly hit the post length limit. So I reduce code by stripping out stuff i think people aren't going to care much about; this always includes the example section. However, it's an important part of my development process and I think I should at least explain it.

At this point in the design process, I'll take the information I've accumulated so far (the interface specification and process description) and formalize the expectations of the process. The reason I skipped this in the get_cur_coord example is simply because I was too lazy to write one. This is a bad excuse, but writing examples for processes which have "artifacts" or have some form of internal state are difficult to write. A good example of this difficulty would be a process for a random number generator. It's hard to describe a behavioral expectation for something that has an unpredictable behavior. The general layout of an example section (at least in my code) will usually be a list of uses with an '=>'  followed by the expected result. If I was to give this a try with the get_cur_coord macro, I'd probably implement it as:

Code: [Select]
;; given
;; wmove (hWindow, 0, 0); get_cur_coord [hWindow] => { RAX: 0, RBX 0 },
;; wmove (hWindow, 5, 4); get_cur_coord [hwindow] => { RAX: 4, RBX 5 }, and
;; wmove (hWindow, LINES, COLS); get_curr_coord [hWindow] => { RAX: COLS, RBX: LINES }.

This comment should assume nothing about the calling conventions used, so in this example you can see I'm referencing a call to wmove as though it was a C routine. The idea here is that we imply enough information about the use that we can formalize some form of test cases.

Step 4. - Unit Testing.

This is another section which I didn't implement in my example, and you'll rarely ever see in any code you'll download. The purpose of the unit testing code is to implement a series of processes which do exactly what your examples earlier did. It may seem odd at first that we are developing test cases before we develop the actual code, but there is valid reasoning here. The unit tests should be an un-biased VALIDATION that our implementation is properly working. There is an overwhelming urge to use our implementation to design our test cases, though this would be considerably easier, it would increase the odds that a flawed implementation detail could be overlooked.

Our expected unit test would look something like this:

Code: [Select]
get_cur_coord_ut:
   STACK_ALIGN


;; given wmove (hWindow, 0, 0); get_cur_coord [hWindow]

   mov rdx, 0
   mov rsi, 0
   mov rdi, [hWindow]
   call wmove

   get_cur_coord [hWindow]

;; expect { RAX: 0, RBX 0 }

   cmp rax, 0
   jne .FAIL
   cmp rbx, 0
   jne .FAIL

;; given wmove (hWindow, 5, 4); get_cur_coord [hwindow]

   mov rdx, 4
   mov rsi, 5
   mov rdi, [hWindow]
   call wmove

   get_cur_coord [hWindow]

;; expect { RAX: 4, RBX 5 }

   cmp rax, 4
   jne .FAIL
   cmp rbx, 5
   jne .FAIL

;; given wmove (hWindow, LINES, COLS); get_curr_coord [hWindow]

   mov rdx, [COLS]
   mov rsi, [LINES]
   mov rdi, [hWindow]
   call wmove

   get_cur_coord [hWindow]

;; expect { RAX: COLS, RBX: LINES }

   cmp rax, [COLS]
   jne .FAIL
   cmp rbx, [LINES]
   jne .FAIL

.SUCCESS:
   mov rax, TRUE
   jmp .DONE

.FAIL:
   mov rax, FALSE

.DONE:
   STACK_RESTORE
   ret

At this point, when we implement the process, we now have a method of validating whether the implementation satisfies our initial expectations or not.

Step 5. - Process Implementation.

Once we have designed all this support information, we can design the process implementation itself. In my earlier post, i gave you the interface specification, the description, and the process implementation. In this case, I looked up the implementation details of NCURSES' window structure and saw that the current Y coordinate is the first 16-bit element and the current X coordinate is the second 16-bit element of the data structure. That means, our use case for this process is to consume (as input) a window handle and produce (as output) the first element of that structure in BX and the second element of that structure in AX. Because RAX and RBX may already contain values, we need to clear the registers before retrieving the elements. So, to summarize:

Use-Case:
1. Obtain reference to our window handle.
2. Clear RAX and RBX registers.
3. Assign first 16-bit value in structure to BX.
4. Assign second 16-bit value in structure to AX.

To do this, we'll need to use a register for dereferencing the window handle and that register should probably be saved and restored in case it's currently being used. This changes our use-case to:

Use-Case:
1. Save RSI register.
2. Obtain reference to our window handle and put it in RSI.
3. Clear RAX and RBX registers.
4. Assign first 16-bit value in structure to BX.
5. Assign second 16-bit value in structure to AX.
6. Restore RSI register.

This use-case analysis finally lead me to my implementation which was a transformation of the steps to instructions:

Code: (get_cur_coord) [Select]
%macro get_cur_coord 1
push rsi
mov rsi, %1
xor rax, rax
xor rbx, rbx
mov ax, [rsi + 2]
mov bx, [rsi]
pop rsi
%endmacro

This could also have been implemented using a procedure (note: the calling convention takes parameters in RDI so we'll just use that instead of RSI).

Code: [Select]
;; get_cur_coord_proc : window_handle -> { x y }.
;; Obtains the current coordinates from a window handle in RDI
;; and returns the current x-coordinate in RAX and the current
;; y-coordinate in RBX.
;; given
;; wmove (hWindow, 0, 0); get_cur_coord_proc (hWindow) => { RAX: 0, RBX 0 },
;; wmove (hWindow, 5, 4); get_cur_coord_proc (hwindow) => { RAX: 4, RBX 5 }, and
;; wmove (hWindow, LINES, COLS); get_curr_coord_proc (hWindow) => { RAX: COLS, RBX: LINES }.
get_cur_coord_proc:
   STACK_ALIGN
   xor rax, rax
   xor rbx, rbx
   mov ax, [rdi + 2] ; second element (x-coord)
   mov bx, [rdi] ; first element (y-coord)
   STACK_RESTORE
   ret

This would, of course, require our unit test code to be changed.

In any event, I hope this clears up any confusion as to my coding style when trying to read examples I provide you. You're not the first to mention difficulty in understanding my code. It helps to point out that most of my "design" techniques come from functional programming whereas most of my implementation practices come from assembly language and a few high level structured languages. I tend to assume that people can infer the meaning of my code from context, but that is rarely the case.



As a reminder, be sure to review the previous reply I referred to:

http://forum.nasm.us/index.php?topic=2204.msg9799#msg9799



Regards,
Bryant Keller
« Last Edit: March 27, 2016, 01:07:37 AM by Bryant Keller »

About Bryant Keller
bkeller@about.me

Offline jackjps

  • Jr. Member
  • *
  • Posts: 60
Re: beginner questions
« Reply #79 on: March 27, 2016, 09:42:00 AM »
Code: [Select]
Hi Bryant,
1.   Still trying to get nasm to work on the separate HD.

jack@jack-myheadache /media/jack/NASM/nasmfld $ sudo chown -R jack /media/jack
[sudo] password for jack:
jack@jack-myheadache /media/jack/NASM/nasmfld $ nasm -f elf64 demo64.asm -o demo64.o
jack@jack-myheadache /media/jack/NASM/nasmfld $ gcc -o demo64 demo64.o -lcurses
jack@jack-myheadache /media/jack/NASM/nasmfld $ ./demo64
bash: ./demo64: Permission denied
jack@jack-myheadache /media/jack/NASM/nasmfld $

2. understanding the parameters of wchgat
    mov r8,0 
    mov rcx,COLOR_PAIR(BLACK_ON_WHITE)
    mov rdx,0
    mov rsi,len1
    mov rdi,[hWindow] 
    call wchgat

   Is my understanding of wchgat correct:
   mov r8,0 =s   const void *opts
   mov rcx,COLOR_PAIR(BLACK_ON_WHITE) =s   short color
   mov rdx,0 =s   attr_t_attr
   mov rsi,len1 =s   int n 
   mov rdi,[hWindow] =s   Window *win

    int wchgat(WINDOW *win, int n, attr_t attr,
             short color, const void *opts)
   
    Let me try to explain what I need for the demo64 program.
    In Masm32 or Goasm you could vary colors by 250,000 ways.
    I see in Nasm only color pairs that are very limited.
    For instance the demo64 program screen has a faded out blue
    a faded yellow rectangle. If the above wchgat is the way to solve
    this then I need to understand how to fill out the instruction.
    Where can I read more about this?

3. Where can I read about changing Fonts?
    Is this part of the "ATTR"?
« Last Edit: March 27, 2016, 10:55:15 AM by jackjps »

Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: beginner questions
« Reply #80 on: March 28, 2016, 01:32:45 AM »
1.   Still trying to get nasm to work on the separate HD.
Code: [Select]
jack@jack-myheadache /media/jack/NASM/nasmfld $ sudo chown -R jack /media/jack
[sudo] password for jack:
jack@jack-myheadache /media/jack/NASM/nasmfld $ nasm -f elf64 demo64.asm -o demo64.o
jack@jack-myheadache /media/jack/NASM/nasmfld $ gcc -o demo64 demo64.o -lcurses
jack@jack-myheadache /media/jack/NASM/nasmfld $ ./demo64
bash: ./demo64: Permission denied
jack@jack-myheadache /media/jack/NASM/nasmfld $

Try the command ls -al /media/jack/NASM/nasmfld and post the results here. I want to see what file attributes are being set.

2. understanding the parameters of wchgat
Code: [Select]
    mov r8,0 
    mov rcx,COLOR_PAIR(BLACK_ON_WHITE)
    mov rdx,0
    mov rsi,len1
    mov rdi,[hWindow] 
    call wchgat

   Is my understanding of wchgat correct:
Code: [Select]
   mov r8,0 =s   const void *opts
   mov rcx,COLOR_PAIR(BLACK_ON_WHITE) =s   short color
   mov rdx,0 =s   attr_t_attr
   mov rsi,len1 =s   int n 
   mov rdi,[hWindow] =s   Window *win

Code: [Select]
    int wchgat(WINDOW *win, int n, attr_t attr,
             short color, const void *opts)

Yep, that's exactly what's going on. Remembering of course that you need to put the cursor at the position where the text is at using the wmove procedure. This is kind of awkward because you are writing a string (probably with waddstr), then moving the cursor back to the start of the string and applying the formatting. It's a lot of work for colored text in the console, but it's a necessary evil.

    Let me try to explain what I need for the demo64 program.
    In Masm32 or Goasm you could vary colors by 250,000 ways.
    I see in Nasm only color pairs that are very limited.
    For instance the demo64 program screen has a faded out blue
    a faded yellow rectangle. If the above wchgat is the way to solve
    this then I need to understand how to fill out the instruction.
    Where can I read more about this?

Your issue here isn't really with NASM. You were able to do so much with Masm32 and GoASM because you were writing code for Windows and you had direct (or possibly abstracted through emulation) access to the hardware's display. I'm sure Frank could show you plenty of examples of people doing the same thing NASM in DOS/Windows consoles. The problem, if you want to call it that, is that Linux is not Windows. Linux Mint is providing you with a Terminal emulator which means you are limited to using the colors that are supported by the terminal environment. The ANSI color support (in most terminals) is limited to only a few colors:

Intensity     0               1               2               3               4               5               6               7               









NormalBlackRedGreenYellow *BlueMagentaCyanWhite
BrightBlackRedGreenYellowBlueMagentaCyanWhite









* On some terminals Normal Yellow will appear as Orange or Brown.

If you want more colorful applications, then I suggest you start reading up on GUI toolkits like Xlib or Gtk.

3. Where can I read about changing Fonts?
    Is this part of the "ATTR"?

Short answer, you can't. Slightly longer answer, CURSES is implemented in such a way that it just uses character sets and escape sequences to display information and none of the escape sequences support changing fonts.



Change of pace. I don't want this reply to be just doom and gloom. It kinds sucks that the things you're wanting to do can't be done the same way it can be done on Windows. But there is a silver lining here (somewhat). You're not the first person to have this problem. Usually, when many people deal with the same problems, eventually one of them fixes it. What follows are a list of console related projects that allow you to do more advanced stuff.

The Linux Framebuffer
One you may be interested in is called the Linux Framebuffer. I've personally never done framebuffer development, but what I gather is you just open the framebuffer's device and map it to memory, modify it and write it back to the device. Again, I've not actually done this so I don't know much about it, but kernel.org (the place where Linux itself is made) has a vague text on it:

https://www.kernel.org/doc/Documentation/fb/framebuffer.txt

That should allow you to do pixel related graphics in the console, and in theory you could draw up your own fonts and render them too. As for actually implementing code for FrameBuffer, maybe Frank has done some of this, or possibly someone else. No clue myself though, you're kinda on your own there.

The Linux SuperVGA Graphics Library
For people coming from a DOS/Windows background, the SuperVGA Graphics Library should look really familiar. This library is a graphics wrapper that allows you to develop graphical applications in the Linux console in almost exactly the same way you might have done in TurboC on DOS (that's what the source code reminds me of anyway). Not only does this library give you access to pixel graphics, but also natively supports bitmap fonts. According to the information on the SVGALib website, there is a "sister library" called vgagl that'll extend support to scalable fonts as well.

The SVGALib site has several tutorials and quite a few programs that you can reference to see what's possible. This is used a good bit for console based game development.



Regards,
Bryant Keller

About Bryant Keller
bkeller@about.me

Offline jackjps

  • Jr. Member
  • *
  • Posts: 60
Re: beginner questions
« Reply #81 on: March 28, 2016, 09:54:19 AM »
Code: [Select]
Hi Bryant,
As per your request:

#1
jack@jack-myheadache ~ $ sudo ls -al /media/jack/NASM/nasmfld
[sudo] password for jack:
total 1507
drwx------ 1 jack jack    4096 Mar 27 05:37 .
drwx------ 1 jack jack    4096 Mar 24 04:28 ..
-rw------- 1 jack jack    5408 Mar  6 16:42 Bryantscd
-rw------- 1 jack jack    4747 Mar  1 15:30 demo264.asm
-rw------- 1 jack jack   17354 Mar 27 05:37 demo64
-rw------- 1 jack jack   20093 Mar 26 16:53 demo64.asm
-rw------- 1 jack jack   12224 Mar 27 05:37 demo64.o
-rw------- 1 jack jack      42 Feb 29 07:32 demo64.sh
-rw------- 1 jack jack     942 Feb 19 16:38 hello
-rw------- 1 jack jack     457 Feb 19 16:37 hello.asm
-rw------- 1 jack jack     848 Feb 19 16:38 hello.o
-rw------- 1 jack jack    7568 Mar  7 08:33 lcurses
-rw------- 1 jack jack   12224 Mar 27 04:56 -lcurses
-rw------- 1 jack jack     592 Mar  7 08:21 LNInstructions.txt
drwx------ 1 jack jack   24576 Mar  8 11:40 nasm-2.11.08
-rw------- 1 jack jack 1398894 Feb 14 09:51 nasm-2.11.08.zip
-rw------- 1 jack jack     142 Mar 12 12:18 testnano.txt
-rw------- 1 jack jack    7493 Feb 22 16:10 tprt64c.asm
jack@jack-myheadache ~ $

#2             3-28-2016
HI Bryant,

hChildWindow   dq 0
szUserInput    db 0, 0, 0  ; don't understand this
;szUserInput    db '  ',0   ; why not this way????
I have the same problem below no matter which way I
define szUserInput.

;;  create 1st child window
   mov rcx,50    ; x value
   mov rdx,10    ; y value
   mov rsi,3     ; 3 columns for 2 digits
   mov rdi,1     ; 1 line for 1 row of digits
   call newwin
   mov [hChildWindow],rax

.g1:
   mov rdx,2
   mov rsi,szUserInput
   mov rdi,[hChildWindow]
   call wgetnstr      ; reads 2 characters good or bad
 
Every time the user keys in a wrong digit I return to
.g1 and get new digits from the user. Whatever wrong
digits/characters the user keys in I get the same error
message on the screen. This is wrong. I am doing something
wrong!
Also, I don't understand the way szUserInput is defined?

oh my - #3 is going to keep me busy for months....




« Last Edit: March 28, 2016, 09:02:55 PM by jackjps »

Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: beginner questions
« Reply #82 on: March 30, 2016, 03:51:40 AM »
Code: [Select]
jack@jack-myheadache ~ $ sudo ls -al /media/jack/NASM/nasmfld
[sudo] password for jack:
total 1507
drwx------ 1 jack jack    4096 Mar 27 05:37 .
drwx------ 1 jack jack    4096 Mar 24 04:28 ..
-rw------- 1 jack jack    5408 Mar  6 16:42 Bryantscd
-rw------- 1 jack jack    4747 Mar  1 15:30 demo264.asm
-rw------- 1 jack jack   17354 Mar 27 05:37 demo64
-rw------- 1 jack jack   20093 Mar 26 16:53 demo64.asm
-rw------- 1 jack jack   12224 Mar 27 05:37 demo64.o
-rw------- 1 jack jack      42 Feb 29 07:32 demo64.sh
-rw------- 1 jack jack     942 Feb 19 16:38 hello
-rw------- 1 jack jack     457 Feb 19 16:37 hello.asm
-rw------- 1 jack jack     848 Feb 19 16:38 hello.o
-rw------- 1 jack jack    7568 Mar  7 08:33 lcurses
-rw------- 1 jack jack   12224 Mar 27 04:56 -lcurses
-rw------- 1 jack jack     592 Mar  7 08:21 LNInstructions.txt
drwx------ 1 jack jack   24576 Mar  8 11:40 nasm-2.11.08
-rw------- 1 jack jack 1398894 Feb 14 09:51 nasm-2.11.08.zip
-rw------- 1 jack jack     142 Mar 12 12:18 testnano.txt
-rw------- 1 jack jack    7493 Feb 22 16:10 tprt64c.asm
jack@jack-myheadache ~ $

Okay! Now we see what the problem is. The file 'demo64' is a program but it's not marked as executable. Unlike Windows, Linux doesn't use the file extension to determine how a file should be used. In your listing, we can tell because there is no 'x' in the -rw------- part before the file. Try the command chmod +x /media/jack/NASM/nasmfld/demo64. The "chmod" program changes the file mode bits on a given file or directory. The "+x" portion means "make this file executable". At this point, you don't need that pesky sudo anymore because we can see that the file and group settings tell us you really do have permission to access this file.  ;)

After you use the chmod command, try to execute the program, if you get the same error, do ls -al /media/jack/NASM/nasmfld and post the results here again.

#2             3-28-2016
HI Bryant,

hChildWindow   dq 0
szUserInput    db 0, 0, 0  ; don't understand this
;szUserInput    db '  ',0   ; why not this way????
I have the same problem below no matter which way I
define szUserInput.

If you look at the ASCII code table, you'll note that 0 is a (nul) character. This character is used as an end of string character and users aren't likely to enter it as user input. A space, however, can be easily entered by the user. In the grand scheme of things, it's not a big deal, but zero'ing out the memory lets you know that it's properly initialized. :)


;;  create 1st child window
   mov rcx,50    ; x value
   mov rdx,10    ; y value
   mov rsi,3     ; 3 columns for 2 digits
   mov rdi,1     ; 1 line for 1 row of digits
   call newwin
   mov [hChildWindow],rax

.g1:
   mov rdx,2
   mov rsi,szUserInput
   mov rdi,[hChildWindow]
   call wgetnstr      ; reads 2 characters good or bad
 
Every time the user keys in a wrong digit I return to
.g1 and get new digits from the user. Whatever wrong
digits/characters the user keys in I get the same error
message on the screen. This is wrong. I am doing something
wrong!
Also, I don't understand the way szUserInput is defined?

oh my - #3 is going to keep me busy for months....
[/code]

When you detect that the input isn't a valid digit, you'll need to set the values back to the initialized versions and clear the screen before jumping back to the .g1 label.

Code: [Select]
.g1:
   mov rdx,2
   mov rsi,szUserInput
   mov rdi,[hChildWindow]
   call wgetnstr      ; reads 2 characters good or bad

   mov al, byte [szUserInput]
   cmp al, '0'
   jb .err1
   cmp al, '9'
   ja .err1

   mov al, byte [szUserInput+1]
   cmp al, '0'
   jb .err1
   cmp al, '9'
   ja .err1
   jmp .out1

.err1:
   ;; do our error for invalid input.
   ;;
   ;; ...
   ;;

   ;; Okay, at this point you've done whatever invalid input message
   ;; you wanted to display to the user, but we now need to get the new
   ;; user input...

   ;; First we reinitialize the string
   mov byte [szUserInput], 0
   mov byte [szUserInput + 1], 0

   ;; Now we need to clear that window.
extern wclear ; add this to the top section where the other extern's are at.
   mov rdi, [hChildWindow]
   call wclear

   ;; Then we should jump back and let the user try entering the code again.
   jmp .g1

.out1:
   ;; both characters read are decimal digits, convert
   ;; them to integers.
   mov rdi, szUserInput
   call atoi

About Bryant Keller
bkeller@about.me

Offline Frank Kotler

  • NASM Developer
  • Hero Member
  • *****
  • Posts: 2667
  • Country: us
Re: beginner questions
« Reply #83 on: March 30, 2016, 06:15:53 AM »
A simple tutorial on those mysterious file permission letters:

https://support.rackspace.com/how-to/checking-linux-file-permissions-with-ls/

I'm puzzled how this could happen. Nasm doesn't know about OS file permissions. We can create a Linux executable without the assistance of a linker, but we've gotta do "chmod +x myfile" to be able to run it. But ld should create "demo64" with executable permission set without further action. If this happens with other files you write using Nasm and ld, you'll want to figure out why. It's an ld problem, not a Nasm problem.

Best,
Frank


Offline jackjps

  • Jr. Member
  • *
  • Posts: 60
Re: beginner questions
« Reply #84 on: March 30, 2016, 11:46:54 AM »
Code: [Select]
Hi Bryant,
Perhaps I have keyed your instructions incorrectly?

jack@jack-myheadache /media/jack/NASM/nasmfld $ sudo chmod +x /media/jack/NASM/nasmfld/demo64
[sudo] password for jack:
jack@jack-myheadache /media/jack/NASM/nasmfld $ sudo ls -al /media/jack/NASM/nasmfld
total 1507
drwx------ 1 jack jack    4096 Mar 27 05:37 .
drwx------ 1 jack jack    4096 Mar 24 04:28 ..
-rw------- 1 jack jack    5408 Mar  6 16:42 Bryantscd
-rw------- 1 jack jack    4747 Mar  1 15:30 demo264.asm
-rw------- 1 jack jack   17354 Mar 27 05:37 demo64
-rw------- 1 jack jack   20093 Mar 26 16:53 demo64.asm
-rw------- 1 jack jack   12224 Mar 27 05:37 demo64.o
-rw------- 1 jack jack      42 Feb 29 07:32 demo64.sh
-rw------- 1 jack jack     942 Feb 19 16:38 hello
-rw------- 1 jack jack     457 Feb 19 16:37 hello.asm
-rw------- 1 jack jack     848 Feb 19 16:38 hello.o
-rw------- 1 jack jack    7568 Mar  7 08:33 lcurses
-rw------- 1 jack jack   12224 Mar 27 04:56 -lcurses
-rw------- 1 jack jack     592 Mar  7 08:21 LNInstructions.txt
drwx------ 1 jack jack   24576 Mar  8 11:40 nasm-2.11.08
-rw------- 1 jack jack 1398894 Feb 14 09:51 nasm-2.11.08.zip
-rw------- 1 jack jack     142 Mar 12 12:18 testnano.txt
-rw------- 1 jack jack    7493 Feb 22 16:10 tprt64c.asm
jack@jack-myheadache /media/jack/NASM/nasmfld $


Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: beginner questions
« Reply #85 on: March 31, 2016, 02:28:27 AM »
Okay, sounds like it could be an issue with your file system. Out of curiosity, try the mount -l command and post the output here.

About Bryant Keller
bkeller@about.me

Offline jackjps

  • Jr. Member
  • *
  • Posts: 60
Re: beginner questions
« Reply #86 on: March 31, 2016, 05:56:09 AM »
Code: [Select]
Hi Bryant,
Posted as per your previous request.

       mount directory          : mount known device here
       mount -t type dev dir    : ordinary mount command
Note that one does not really mount a device, one mounts
a filesystem (of the given type) found on the device.
One can also mount an already visible directory tree elsewhere:
       mount --bind olddir newdir
or move a subtree:
       mount --move olddir newdir
One can change the type of mount containing the directory dir:
       mount --make-shared dir
       mount --make-slave dir
       mount --make-private dir
       mount --make-unbindable dir
One can change the type of all the mounts in a mount subtree
containing the directory dir:
       mount --make-rshared dir
       mount --make-rslave dir
       mount --make-rprivate dir
       mount --make-runbindable dir
A device can be given by name, say /dev/hda1 or /dev/cdrom,
or by label, using  -L label  or by uuid, using  -U uuid .
Other options: [-nfFrsvw] [-o options] [-p passwdfd].
For many more details, say  man 8 mount .
jack@jack-myheadache /media/jack/NASM $
« Last Edit: March 31, 2016, 06:42:22 AM by jackjps »

Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: beginner questions
« Reply #87 on: March 31, 2016, 06:35:10 AM »
I wanted the output of mount -l. That's a lowercase L. This will list all mounted devices.

I have a file of bitmaps.
How can I include them in the demo64 program and use them?

You can't from the terminal. You'll need to use a GUI library like Gtk or Xlib.

About Bryant Keller
bkeller@about.me

Offline jackjps

  • Jr. Member
  • *
  • Posts: 60
Re: beginner questions
« Reply #88 on: March 31, 2016, 06:47:55 AM »
Code: [Select]
Hi Bryant,
Hope i got it right this time.....

proc on /proc type proc (rw,noexec,nosuid,nodev)
sysfs on /sys type sysfs (rw,noexec,nosuid,nodev)
none on /sys/fs/cgroup type tmpfs (rw)
none on /sys/fs/fuse/connections type fusectl (rw)
none on /sys/kernel/debug type debugfs (rw)
none on /sys/kernel/security type securityfs (rw)
udev on /dev type devtmpfs (rw,mode=0755)
devpts on /dev/pts type devpts (rw,noexec,nosuid,gid=5,mode=0620)
tmpfs on /run type tmpfs (rw,noexec,nosuid,size=10%,mode=0755)
none on /run/lock type tmpfs (rw,noexec,nosuid,nodev,size=5242880)
none on /run/shm type tmpfs (rw,nosuid,nodev)
none on /run/user type tmpfs (rw,noexec,nosuid,nodev,size=104857600,mode=0755)
none on /sys/fs/pstore type pstore (rw)
binfmt_misc on /proc/sys/fs/binfmt_misc type binfmt_misc (rw,noexec,nosuid,nodev)
systemd on /sys/fs/cgroup/systemd type cgroup (rw,noexec,nosuid,nodev,none,name=systemd)
gvfsd-fuse on /run/user/1000/gvfs type fuse.gvfsd-fuse (rw,nosuid,nodev,user=jack)
/dev/sda5 on /media/jack/NASM type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096) [NASM]
/dev/sda7 on /media/jack/masm32 type fuseblk (rw,nosuid,nodev,allow_other,default_permissions,blksize=4096) [masm32]
jack@jack-myheadache /media/jack/NASM/nasmfld $


Offline Bryant Keller

  • Forum Moderator
  • Full Member
  • *****
  • Posts: 360
  • Country: us
    • About Bryant Keller
Re: beginner questions
« Reply #89 on: March 31, 2016, 07:07:01 AM »
Okay, the problem is that the drive is NTFS. I've never used NTFS, but after searching around, I found a suggestion to try:

sudo umount /media/jack/NASM
sudo mount -t ntfs -o rw,auto,user,fmask=0022,dmask=0000,exec /dev/sda5 /media/jack/NASM

« Last Edit: March 31, 2016, 07:09:09 AM by Bryant Keller »

About Bryant Keller
bkeller@about.me