Best forum to ask a Q about a system call?

For discussions about programming, and for programming questions and advice


Moderator: Forum moderators

Post Reply
User avatar
cobaka
Posts: 521
Joined: Thu Jul 16, 2020 6:04 am
Location: Central Coast, NSW - au
Has thanked: 87 times
Been thanked: 49 times

Best forum to ask a Q about a system call?

Post by cobaka »

Hello all! Woof!

I seek an answer about making a system call to the Puppy OS.

Normally a system call would be made using a standard C library function [eg fopen() or int fgetc()].
I want to open a file and read ASCII-HEX characters from a file, using an emulator 'running' an 8-bit uP.
The emulator itself runs under Linux but executes 8-bit machine op-codes.

The question: Where - what forum - is the best place to ask how this might be done?

Thanks,
собака.
Final detail: The file to be read consists of Motorola "S" records.
In the example below, the added spaces ' ' make the detail of a record more apparent.
They are not part of an authentic "S" record.
https://en.wikipedia.org/wiki/SREC_(file_format)

S1 0C 0100 4F 5F C6 01 12 12 12 20 F7 30
S9 03 0000 FC

собака --> это Русский --> an old dog
"so-baka" (not "co", as in coast or crib).

williams2
Posts: 1026
Joined: Sat Jul 25, 2020 5:45 pm
Been thanked: 288 times

Re: Best forum to ask a Q about a system call?

Post by williams2 »

If the 8 bit cpu is the 6809, there are various emulators available.
Not sure if any one of them have much traffic.

If you want to be able to access library functions,
like printing to std-out, or to a file handle,
I think you would need an emulator that has library wrappers,
and can be embedded in C source.

If you don't like the Gnu assembler,
you might like fasm or nasm for AMD/INTEL cpus.

Any data can be converted to hex (hexadecimal numbers.)
There are Gnu utility programs that can do that.
For example, hd name-of-file

Usually, the raw assembled binary data is put in a file with magic numbers and something like ELF headers.

Some emulators run in a web page. For example,

http://6809.uk/

6809.jpg
6809.jpg (134.63 KiB) Viewed 373 times
User avatar
cobaka
Posts: 521
Joined: Thu Jul 16, 2020 6:04 am
Location: Central Coast, NSW - au
Has thanked: 87 times
Been thanked: 49 times

Re: Best forum to ask a Q about a system call?

Post by cobaka »

@williams2
Thank you for your reply. Since you gave an answer directly to the problem (and not best forum to ask about the problem) I will set out the detail here.

The uP of interest is the Motorola 6809. The software I am working with comes from GitHub.
https://github.com/6809/sbc09
Lennart Benschop provided a package of assembler (written in C) and an emulator (v09) written in C.
From Benschop's package:

/* 6809 Simulator V09.
Copyright 1994, L.C. Benschop, Eidnhoven The Netherlands.
This version of the program is distributed under the terms and conditions of the GNU License.
THERE IS NO WARRANTY ON THIS PROGRAM!!!

This program simulates a 6809 processor.

After that he wrote a monitor program (in assembly language) that he assembled (with his assembler).
The monitor runs "under" the emulator. The monitor is called v09.
I think this means 'virtual 6809 engine'. I have used the monitor a little.
Lennart Benschop writes a lot of very nice code. Neat, yes?

I have the source code for the monitor. I modified it a little, but great modifications bring great confusion in my mind.
I decided to use Mr. Benschop's assembler to create a Motorola "S" file.
I can (and have) done that. A switch in the command-line of his assembler allows me to create either (1) a file in "S" format or (2) straight binary (machine code). At the command line I type: ./a09 -s -l list.txt source.asm and bingo! I have a Motorola format "S" file of the program I wrote.

If I had a paper-tape punch and a paper-tape reader I could load the program directly into a 6809 single board computer. But Lennart is clever! Why, he asks, would he build a 6809 single board computer when he can make an emulator in the "C" language? So he wrote an emulator and the emulator runs a monitor. He called his monitor "buggy".

The monitor has a command to load a file in "S" format. So - theoretically - I should be able to get the source code for some 6809 assembly program, assemble it (to create a file in "S" format) and read that file into the simulator memory and run it.
That's possible, according to the documents for the assembler, monitor and simulator.

Now some background: I can load and run the simulator (v09) AND the monitor (it's called 'buggy') from the terminal.
The sign-on message says: 'Welcome to buggy 1.0' (I think)
In the monitor I can dump memory, enter (hex) data and so all. All as expected.
The monitor has a command: S filename.
If I understand the manual this should read a file (S format) from disk into memory.
This is a very 'normal' process. Each record of the "S" file should first go into the command-line input buffer.
The 'S' command should take each pair of ASCII-hex characters and load them into simulator memory.
In times past (long ago) I did this many times, but using the Intel-hex format.

Appears normal, yes? Yes! So I typed the command: S <filename.s>
Whoa! I got an error message, something like "error in S record". Oh! But I checked the "S" file.
Using Geany I can see every character. Everything is good. Even the checksum value. Where, then, is the trouble?
Answer: I examined the input buffer. Horror of horrors!
There is no "S" record in the buffer! I just see my command.
Then, of course, I read the assembly language program carefully.
I cannot find any subroutine to open and read characters from the Linux file system.
That is why my command is in the buffer - not the "S" record. Oh horror!
What have I done to deserve this punishment from god? Perhaps (for a moment) I though nice words about Windows?

This lack of reading a file is why I am here. If the monitor program was written in the C language - then a call to just 2 library functions and all would be honky-dory. But no! Here the program is written in assembly language and I must find a way to open/read from the disk "inside" the emulator/monitor. I must learn about system calls for the Linux OS.

Yes, there are a lot of words here, and I apologise for that. Basically my Q was about the best forum to ask my Q.
I'm not looking for an answer on a forum about the Puppy Operating System. But I'm here. Go figure.

I just want to run Mr. Benschop's very nice emulator as he intended.

I thank you for your interest.
собака.

собака --> это Русский --> an old dog
"so-baka" (not "co", as in coast or crib).

User avatar
cobaka
Posts: 521
Joined: Thu Jul 16, 2020 6:04 am
Location: Central Coast, NSW - au
Has thanked: 87 times
Been thanked: 49 times

Re: Best forum to ask a Q about a system call?

Post by cobaka »

@williams2
BTW - I'm not looking for a solution - just a few general pointers.

собака

собака --> это Русский --> an old dog
"so-baka" (not "co", as in coast or crib).

User avatar
user1234
Posts: 413
Joined: Sat Feb 26, 2022 5:48 am
Location: Somewhere on earth
Has thanked: 154 times
Been thanked: 87 times

Re: Best forum to ask a Q about a system call?

Post by user1234 »

Well you can go over to StackOverflow to ask questions related to programming like Operating Systems, AI, Assembly, C/C++ and other programming languages, etc. (kinda like all things related to computer).

You can ask your question in separate forums which can be provided by StackExchange (kinda like a network on which a lot of forums have been created on different topics). There you won't be having forums for just computers but also for other fields such as Mathematics, Chemistry, Physics, TeX, Photography and even Comics. I just feel that the StackExchange forums are nice to ask questions related to any topic.

** (NO PAID PROMOTION) **
Regards
A StackExchange Fan

PuppyLinux 🐾 gives new life to old computers ✨

User avatar
cobaka
Posts: 521
Joined: Thu Jul 16, 2020 6:04 am
Location: Central Coast, NSW - au
Has thanked: 87 times
Been thanked: 49 times

Re: Best forum to ask a Q about a system call?

Post by cobaka »

@user1234
You:

Well you can go over to StackOverflow to ask questions ...

Me: I went there and found a very interesting book! Thanks!
собака

собака --> это Русский --> an old dog
"so-baka" (not "co", as in coast or crib).

Post Reply

Return to “Programming”