._ENTRY%
mov #1,r0 ; r0=STDOUT
trap 4 ; write()
I've been experimenting with BSD 2.11 Unix. I'm having problems
getting assembly code to execute and do anything. I stripped
down to a minimal example:
ORG 0 ; position independant code
EQUW &0107 ; magic number, also branch to Startup
Aside, I've written the same code in C and compiled it, and it works
fine,
so my next direction of attack is to disassemble the generated code and
see what it's doing that my assembly code isn't.
Jonathan Harston <j...@mdfs.net> writes:
._ENTRY%Are you sure you are supposed to put the fd in r0? That doesn't look
mov #1,r0 ; r0=STDOUT
trap 4 ; write()
right to me, but it's been a while.
On Sun, 11 Jul 2021 18:10:20 -0700, Jonathan Harston wrote:
Aside, I've written the same code in C and compiled it, and it worksWhy would you want to disassemble it, when you can just tell the compiler
fine,
so my next direction of attack is to disassemble the generated code and see what it's doing that my assembly code isn't.
to retain the .s file?
On Monday, July 12, 2021 at 11:10:21 AM UTC+10, j...@mdfs.net wrote:
I've been experimenting with BSD 2.11 Unix. I'm having problems
getting assembly code to execute and do anything. I stripped
down to a minimal example:
ORG 0 ; position independant codeI'm not familiar with BSD, but in the earlier versions the magic number was 407
EQUW &0107 ; magic number, also branch to Startup
(which in fact is the PDP-11 branch instruction to skip past the header).
On Monday, 12 July 2021 at 05:22:53 UTC+1, Ian Hammond wrote:
On Monday, July 12, 2021 at 11:10:21 AM UTC+10, j...@mdfs.net wrote:
I've been experimenting with BSD 2.11 Unix. I'm having problems
getting assembly code to execute and do anything. I stripped
down to a minimal example:
Hex 107 is Oct 407. A binary dump of working code shows the same header and magic numbers.ORG 0 ; position independant codeI'm not familiar with BSD, but in the earlier versions the magic number was 407
EQUW &0107 ; magic number, also branch to Startup
(which in fact is the PDP-11 branch instruction to skip past the header).
I've been experimenting with BSD 2.11 Unix. I'm having problems
getting assembly code to execute and do anything. I stripped
down to a minimal example:
ORG 0 ; position independant code
EQUW &0107 ; magic number, also branch to Startup
EQUW _DATA%-_TEXT% ; size of text
EQUW _BSS%-_DATA% ; size of initialised data
EQUW _END%-_BSS% ; size of uninitialised data
EQUW &0000 ; size of symbol data
EQUW _ENTRY%-_TEXT% ; entry point
EQUW &0000 ; not used
EQUW &0001 ; no relocation info
ORG 0 ; position independant code
._TEXT%
;
._ENTRY%
mov #1,r0 ; r0=STDOUT
trap 4 ; write()
equw msg_hello ; Start of data
equw end_hello-msg_hello ; Length of data
;
trap 1 ; exit()
halt ; drop to monitor
;
._DATA%
.msg_hello
equs "Hello world!",10,13
.end_hello
align
;
._BSS%
._END%
Running it just returns to the command prompt with no output.
Examining the binary with adb shows the expected code and
data, and single-stepping through it successfully sets R0, then
at the sys write() it makes the call, outputs nothing, and ends
at the exit().
If I can't even get any output so I can display debug messages,
I'm stumped!
Aside, I've written the same code in C and compiled it, and it
works fine, so my next direction of attack is to disassemble
the generated code and see what it's doing that my assembly
code isn't.
Jonathan Harston <jgh@mdfs.net> writes:
I've been experimenting with BSD 2.11 Unix. I'm having problems
Aside, I've written the same code in C and compiled it, and it
works fine, so my next direction of attack is to disassemble
the generated code and see what it's doing that my assembly
code isn't.
Standard code relies on exit() to flush the stream, which (stdout)
will be fully buffered.
ubggre. That means the same binary won't run. My first thought is
to use TRAP 0 ; indirect but I bet that also uses the stack.
| Sysop: | Amessyroom |
|---|---|
| Location: | Fayetteville, NC |
| Users: | 63 |
| Nodes: | 6 (0 / 6) |
| Uptime: | 492971:08:30 |
| Calls: | 840 |
| Files: | 1,301 |
| D/L today: |
10 files (28,220K bytes) |
| Messages: | 264,285 |