From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: <6FB2CC30-C95E-4C51-830D-FEE61A889161@kix.in> From: Anant Narayanan To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Content-Type: multipart/alternative; boundary=Apple-Mail-1-904761903 Mime-Version: 1.0 (Apple Message framework v915) Date: Sat, 9 Feb 2008 15:14:21 +0530 Subject: [9fans] Hello Assembly Topicbox-Message-UUID: 4d6cb78a-ead3-11e9-9d60-3106f5b1d025 --Apple-Mail-1-904761903 Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Hi, I'm trying to make a Hello World program in assembly without depending on libc. Here's what I have so far: DATA string+0(SB)/7, $"Hello\n\z" GLOBL string+0(SB), $7 TEXT _main+0(SB), 1, $0 // first arg; $1 = stdout MOVL $1, (SP) // second arg, address of string MOVL $string+0(SB), 4(SP) // third arg, $7 = length of string MOVL $7, 8(SP) // fourth argument, -1LL (vlong offset) MOVL $-1, 12(SP) MOVL $-1, 16(SP) // use pwrite syscall MOVL $51, AX INT $64 RET The program assembles and links fine - but executing it gives me: 8.out 1183: suicide: invalid address 0x7 in sys call pc=0x104e It's probably something silly - I'll be extremely grateful if someone could point out what I'm doing wrong. Thanks! -- Anant --Apple-Mail-1-904761903 Content-Type: text/html; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi,

I'm trying to make a Hello = World program in assembly without depending on libc. Here's what I have = so far:

DATA string+0(SB)/7, = $"Hello\n\z"
GLOBL string+0(SB), $7

TEXT = _main+0(SB), 1, $0

// first arg; $1 =3D = stdout
MOVL $1, (SP)
// second arg, address of = string
MOVL $string+0(SB), 4(SP)
// third arg, $7 =3D = length of string
MOVL $7, 8(SP)
// fourth = argument, -1LL (vlong offset)
MOVL $-1, 12(SP)
MOVL $-1, = 16(SP)

// = use pwrite syscall
MOVL $51, AX
INT = $64
RET

The program assembles and = links fine - but executing it gives me:

8.out 1183: suicide: = invalid address 0x7 in sys call pc=3D0x104e

It's probably something = silly - I'll be extremely grateful if someone could point out what I'm = doing wrong.

Thanks!

--
Anant
= --Apple-Mail-1-904761903-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <5132a1f8e666ecdb202af09778aa16a2@terzarima.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly From: Charles Forsyth Date: Sat, 9 Feb 2008 09:58:36 +0000 In-Reply-To: <6FB2CC30-C95E-4C51-830D-FEE61A889161@kix.in> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4d72c0a8-ead3-11e9-9d60-3106f5b1d025 > It's probably something silly - I'll be extremely grateful if someone there might be more, but you haven't allocated a stack frame for the (system) call From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: From: Anant Narayanan To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> In-Reply-To: <5132a1f8e666ecdb202af09778aa16a2@terzarima.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v915) Subject: Re: [9fans] Hello Assembly Date: Sat, 9 Feb 2008 15:39:08 +0530 References: <5132a1f8e666ecdb202af09778aa16a2@terzarima.net> Topicbox-Message-UUID: 4d80e944-ead3-11e9-9d60-3106f5b1d025 Hi Charles, > there might be more, but you haven't allocated a stack frame for the > (system) call I did think that was the case earlier, so I tried: TEXT _main+0(SB), 1, $32 (And also with values ranging from $4 to $32 in increments of $4 just for the heck of it). But it doesn't seem to make any difference in the suicide, apart from the changed value of pc. The error is most likely because of the line (that's the only 7 around there): MOVL $7, 8(SP) But it doesn't complain about: MOVL $1, (SP) so I wonder... -- Anant From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <133924aadc2dc6260438461c902c7d25@quanstro.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly From: erik quanstrom Date: Sat, 9 Feb 2008 05:15:20 -0500 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4d86652c-ead3-11e9-9d60-3106f5b1d025 > I did think that was the case earlier, so I tried: > > TEXT _main+0(SB), 1, $32 > > (And also with values ranging from $4 to $32 in increments of $4 just > for the heck of it). But it doesn't seem to make any difference in the > suicide, apart from the changed value of pc. > > The error is most likely because of the line (that's the only 7 around > there): > MOVL $7, 8(SP) > > But it doesn't complain about: > MOVL $1, (SP) > > so I wonder... you seek: SUBL $value, SP - erik From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <900eb6253a34482ccdc5dd52435c184d@terzarima.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly From: Charles Forsyth Date: Sat, 9 Feb 2008 10:32:01 +0000 In-Reply-To: <5132a1f8e666ecdb202af09778aa16a2@terzarima.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4d8bb964-ead3-11e9-9d60-3106f5b1d025 > there might be more, but you haven't allocated a stack frame for the (system) call actually, there's probably enough space above your current location to (appear to) work, but a further error is hinted in the address given by the trap: 8.out 1183: suicide: invalid address 0x7 in sys call pc=0x104e since 7 is your length value, you've also got an off-by-4 error in your stack offsets. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <9bcb80e28d8b5b74840bac68585c91c7@quanstro.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly From: erik quanstrom Date: Sat, 9 Feb 2008 05:34:14 -0500 In-Reply-To: <900eb6253a34482ccdc5dd52435c184d@terzarima.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4d930ac0-ead3-11e9-9d60-3106f5b1d025 > actually, there's probably enough space above your current location to (appear to) work, but a further error > is hinted in the address given by the trap: > > 8.out 1183: suicide: invalid address 0x7 in sys call pc=0x104e > > since 7 is your length value, you've also got an off-by-4 error in your stack offsets. actually, i think there's something else wrong: acid: asm(_main) _main 0x00001020 SUBL $0x18,SP _main+0x3 0x00001023 MOVL $0x1,0x0(SP) _main+0xa 0x0000102a MOVL $string(SB),0x4(FP) _main+0x12 0x00001032 MOVL $0x7,0x8(FP) _main+0x1a 0x0000103a MOVL $0x0,0xc(FP) _main+0x22 0x00001042 MOVL $0x0,0x10(FP) _main+0x2a 0x0000104a MOVL $0x33,AX _main+0x2f 0x0000104f INTB $0x40 _main+0x31 0x00001051 ADDL $0x18,SP _main+0x34 0x00001054 RET why does the for the equivalent c "pwrite(1, string, 7, 0)" i get this acid: asm(main) main 0x00001020 SUBL $0x18,SP main+0x3 0x00001023 MOVL $0x1,AX main+0x8 0x00001028 MOVL AX,0x0(SP) main+0xb 0x0000102b MOVL string(SB),AX main+0x11 0x00001031 MOVL AX,0x4(SP) main+0x15 0x00001035 MOVL $0x7,AX main+0x1a 0x0000103a MOVL AX,0x8(SP) main+0x1e 0x0000103e MOVL $0x0,0xc(SP) main+0x26 0x00001046 MOVL $0x0,0x10(SP) main+0x2e 0x0000104e CALL pwrite(SB) main+0x33 0x00001053 ADDL $0x18,SP main+0x36 0x00001056 RET - erik From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <7f5aa18624c40a378b8a1fa19dabfd5e@quanstro.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly From: erik quanstrom Date: Sat, 9 Feb 2008 05:36:30 -0500 In-Reply-To: <9bcb80e28d8b5b74840bac68585c91c7@quanstro.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4d96e744-ead3-11e9-9d60-3106f5b1d025 > acid: asm(_main) > _main 0x00001020 SUBL $0x18,SP > _main+0x3 0x00001023 MOVL $0x1,0x0(SP) > _main+0xa 0x0000102a MOVL $string(SB),0x4(FP) > _main+0x12 0x00001032 MOVL $0x7,0x8(FP) > _main+0x1a 0x0000103a MOVL $0x0,0xc(FP) > _main+0x22 0x00001042 MOVL $0x0,0x10(FP) > _main+0x2a 0x0000104a MOVL $0x33,AX > _main+0x2f 0x0000104f INTB $0x40 > _main+0x31 0x00001051 ADDL $0x18,SP > _main+0x34 0x00001054 RET > > why does the ... SP in the .s get changed to FP unless the offset is 0? - erik From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sat, 9 Feb 2008 14:37:06 +0000 To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> Subject: Re: [9fans] Hello Assembly From: "Eris Discordia" Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 References: <6FB2CC30-C95E-4C51-830D-FEE61A889161@kix.in> Content-Transfer-Encoding: Quoted-Printable Message-ID: In-Reply-To: <6FB2CC30-C95E-4C51-830D-FEE61A889161@kix.in> User-Agent: Opera Mail/9.23 (Win32) Topicbox-Message-UUID: 4da74ef4-ead3-11e9-9d60-3106f5b1d025 On Sat, 09 Feb 2008 09:44:21 -0000, Anant Narayanan wrote= : > Hi, > > I'm trying to make a Hello World program in assembly without depending= > on libc. Here's what I have so far: > > DATA string+0(SB)/7, $"Hello\n\z" > GLOBL string+0(SB), $7 > > TEXT _main+0(SB), 1, $0 > > // first arg; $1 =3D stdout > MOVL $1, (SP) > // second arg, address of string > MOVL $string+0(SB), 4(SP) > // third arg, $7 =3D length of string > MOVL $7, 8(SP) > // fourth argument, -1LL (vlong offset) > MOVL $-1, 12(SP) > MOVL $-1, 16(SP) > > // use pwrite syscall > MOVL $51, AX > INT $64 > RET > No two cents from me. Just posted this to say that AT&T syntax is = "sickly." I suppose Anant Narayanan is assembling these using 8a, and = given the "symptoms" (the syntax, that is) 8a must be using AT&T syntax.= I = am wondering if there is an Intel syntax assembler for Plan 9 (something= = akin to Netwide Assembler or yet better Flat Assembler). -- = Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly From: Brantley Coile Date: Sat, 9 Feb 2008 11:17:56 -0500 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4db6bd1c-ead3-11e9-9d60-3106f5b1d025 I would like to hear what Rob or others have to say about the assembler syntax, but I actually like the syntax for the following reason. You only have to remember one syntax and not ten different ones. I would think, given that the structure of the compiler/loader is very non-traditional, it would be difficult to provide all the pseudo operations that the various native assemblers would require. Best thing is not to write a lot of assembler code. :) > On Sat, 09 Feb 2008 09:44:21 -0000, Anant Narayanan wrote: > >> Hi, >> >> I'm trying to make a Hello World program in assembly without depending >> on libc. Here's what I have so far: >> >> DATA string+0(SB)/7, $"Hello\n\z" >> GLOBL string+0(SB), $7 >> >> TEXT _main+0(SB), 1, $0 >> >> // first arg; $1 = stdout >> MOVL $1, (SP) >> // second arg, address of string >> MOVL $string+0(SB), 4(SP) >> // third arg, $7 = length of string >> MOVL $7, 8(SP) >> // fourth argument, -1LL (vlong offset) >> MOVL $-1, 12(SP) >> MOVL $-1, 16(SP) >> >> // use pwrite syscall >> MOVL $51, AX >> INT $64 >> RET >> > > No two cents from me. Just posted this to say that AT&T syntax is > "sickly." I suppose Anant Narayanan is assembling these using 8a, and > given the "symptoms" (the syntax, that is) 8a must be using AT&T syntax. I > am wondering if there is an Intel syntax assembler for Plan 9 (something > akin to Netwide Assembler or yet better Flat Assembler). > > -- > Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <13426df10802090827m3d6447cxe07052f07263f5bc@mail.gmail.com> Date: Sat, 9 Feb 2008 08:27:23 -0800 From: "ron minnich" To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> Subject: Re: [9fans] Hello Assembly In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: Topicbox-Message-UUID: 4dbdd5d4-ead3-11e9-9d60-3106f5b1d025 On Feb 9, 2008 8:17 AM, Brantley Coile wrote: > I would like to hear what Rob or others have to say about the > assembler syntax, but I actually like the syntax for the following > reason. if you love assembly code, the assembler on Plan 9 is not great. If you love assembly code, you are in need of a CAT scan in my view. The v6 manual entry for as called assembly code "the ultimate dead language". If only that had been true. gcc and friends have made the world safe for assembly, and there is more assembly in use than ever. Writing assembly code should be as painful as possible. Plan 9 succeeds in that regard. It's a good thing in my view. ron From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly From: erik quanstrom Date: Sat, 9 Feb 2008 11:38:37 -0500 In-Reply-To: <13426df10802090827m3d6447cxe07052f07263f5bc@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Topicbox-Message-UUID: 4dc37980-ead3-11e9-9d60-3106f5b1d025 > if you love assembly code, the assembler on Plan 9 is not great. >=20 > If you love assembly code, you are in need of a CAT scan in my view. >=20 > The v6 manual entry for as called assembly code "the ultimate dead > language". If only that had been true. >=20 > gcc and friends have made the world safe for assembly, and there is mor= e > assembly in use than ever. >=20 > Writing assembly code should be as painful as possible. Plan 9 > succeeds in that regard. It's a good thing in my view. >=20 > ron i don't think that it follows from the fact that assembly language is inappropriately used in a lot of linux software that it should be as hard to use as possible on plan 9. there are some tasks that must be in assembly language. and it's a good tool for learning how the machine works. sometimes, like on really small controllers, it's the best tool for the job. just my 2=C2=A2. - erik p.s. relax ron. i promise not to rewrite plan 9 in assembly language. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly From: Brantley Coile Date: Sat, 9 Feb 2008 11:51:55 -0500 In-Reply-To: <13426df10802090827m3d6447cxe07052f07263f5bc@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4dcc22ce-ead3-11e9-9d60-3106f5b1d025 > On Feb 9, 2008 8:17 AM, Brantley Coile wrote: >> I would like to hear what Rob or others have to say about the >> assembler syntax, but I actually like the syntax for the following >> reason. > > if you love assembly code, the assembler on Plan 9 is not great. > > If you love assembly code, you are in need of a CAT scan in my view. > > The v6 manual entry for as called assembly code "the ultimate dead > language". If only that had been true. > > gcc and friends have made the world safe for assembly, and there is more > assembly in use than ever. > > Writing assembly code should be as painful as possible. Plan 9 > succeeds in that regard. It's a good thing in my view. > > ron I'm afraid Plan 9 fails in this reguard. Here's some Oberon code to make the pread call. (This is NOT Wirth's compiler, but Paul Reed's. He agrees with you about make assembly programming as hard as possible.) PROCEDURE syspread(poshi, poslo: LONGINT; VAR buf: ARRAY OF CHAR; fd: LONGINT): LONGINT; BEGIN (* 18: return value 14: poshi 10: poslo 0c: buflen 08; buf ptr 04: fd 00: RA *) SYSTEM.CODE( 0C9H, (* leave *) 06AH, 50, (* pushb $close *) 058H, (* pop eax *) 0CDH, 040H, (* int $40h *) 089H,084H,024H,018H,000H,000H,000H, (* movl eax, 18h(esp) *) 0C2H, 14H, 0 (* ret $14h *) ) END syspread; From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <266b5e8c012b5d437346a87216ac5005@terzarima.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly From: Charles Forsyth Date: Sat, 9 Feb 2008 17:32:26 +0000 In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4dd2c296-ead3-11e9-9d60-3106f5b1d025 >> No two cents from me. Just posted this to say that AT&T syntax is >> "sickly." I suppose Anant Narayanan is assembling these using 8a, and >> given the "symptoms" (the syntax, that is) 8a must be using AT&T syntax. I the assembler is really just a front-end to the loader, and nothing to do with `at&t syntax'. there are some odd aspects to thompson syntax as it is (data loading for instance, and the <>) but generally i agree with brantley. some weeks i'm working with several processors, even several a day, and the `native' (in what sense? does the processor implement them?) assemblers typically differ in operand order, basic mnemonics (l/st vs mov), and other conventions, whereas the ?a family is uniformly data flow, and tends to use similar instructions for similar things. i find it much easier moving from platform to platform with it. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: <3FEA1766-A9DD-4B0B-833C-7AC6DE6382A0@kix.in> From: Anant Narayanan To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> In-Reply-To: <9bcb80e28d8b5b74840bac68585c91c7@quanstro.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v915) Subject: Re: [9fans] Hello Assembly Date: Sun, 10 Feb 2008 01:45:48 +0530 References: <9bcb80e28d8b5b74840bac68585c91c7@quanstro.net> Topicbox-Message-UUID: 4de0001e-ead3-11e9-9d60-3106f5b1d025 On 09-Feb-08, at 4:04 PM, erik quanstrom wrote: > actually, i think there's something else wrong: > for the equivalent c "pwrite(1, string, 7, 0)" i get this I don't get FP for `8c -S hello.c' (which just calls pwrite as you describe). This is what I get: TEXT main+0(SB), 0, $32 MOVL $.string<>+0(SB), CX MOVL $1, AX MOVL AX, (SP) MOVL CX, 4(SP) MOVL $7, AX MOVL AX, 8(SP) MOVL $-1, 12(SP) MOVL $-1, 16(SP) CALL ,pwrite+0(SB) RET , DATA .string<>+0(SB)/8, $"Hello\n\z\z" GLOBL .string<>+0(SB), $8 END , Replicating the exact program - with just three changes: moving the DATA/GLOBL statement to the top, changing main to _main and replacing CALL with MOVL $64, AX and INT $64 - still results in the suicide. Puzzling. -- Anant From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: From: Anant Narayanan To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> In-Reply-To: <900eb6253a34482ccdc5dd52435c184d@terzarima.net> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v915) Subject: Re: [9fans] Hello Assembly Date: Sun, 10 Feb 2008 01:47:20 +0530 References: <900eb6253a34482ccdc5dd52435c184d@terzarima.net> Topicbox-Message-UUID: 4de737c6-ead3-11e9-9d60-3106f5b1d025 > actually, there's probably enough space above your current location > to (appear to) work, but a further error > is hinted in the address given by the trap: > > 8.out 1183: suicide: invalid address 0x7 in sys call pc=0x104e > > since 7 is your length value, you've also got an off-by-4 error in > your stack offsets. In which direction, 4(SP) or -4(SP)? Both don't work, it still suicides but at different 'invalid addresses' and pc values :( -- Anant From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: <566BA6DE-1CF7-40EE-B0E7-399EB2585F1B@kix.in> From: Anant Narayanan To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v915) Subject: Re: [9fans] Hello Assembly Date: Sun, 10 Feb 2008 02:45:51 +0530 References: Topicbox-Message-UUID: 4ded377a-ead3-11e9-9d60-3106f5b1d025 Thanks everybody (especially Jim and Charles), I got this to work. Here's the final program: DATA string<>+0(SB)/8, $"Hello\n\z\z" GLOBL string<>+0(SB), $8 TEXT _main+0(SB), 1, $0 MOVL $1, 4(SP) MOVL $string<>+0(SB), 8(SP) MOVL $7, 12(SP) MOVL $-1, 16(SP) MOVL $-1, 20(SP) MOVL $51, AX INT $64 MOVL $string<>+0(SB), 4(SP) MOVL $8, AX INT $64 Jim pointed out that using RET was incorrect as the instruction wouldn't know where to get back to. Calling exits() instead, works. Plan 9 gets more and more exciting for me, everyday :) Thanks again! Cheers, Anant From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v753) In-Reply-To: <566BA6DE-1CF7-40EE-B0E7-399EB2585F1B@kix.in> References: <566BA6DE-1CF7-40EE-B0E7-399EB2585F1B@kix.in> Content-Type: multipart/alternative; boundary=Apple-Mail-1-946946988 Message-Id: From: Pietro Gagliardi Subject: Re: [9fans] Hello Assembly Date: Sat, 9 Feb 2008 16:27:26 -0500 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 4df39d22-ead3-11e9-9d60-3106f5b1d025 --Apple-Mail-1-946946988 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; format=flowed On Feb 9, 2008, at 4:15 PM, Anant Narayanan wrote: > DATA string<>+0(SB)/8, $"Hello\n\z\z" Why are there two \zs? Shouldn't one be enough? --Apple-Mail-1-946946988 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=US-ASCII
On Feb 9, 2008, at 4:15 PM, Anant Narayanan wrote:

DATA string<>+0(SB)/8, $"Hello\n\z\z"


Why are there two \zs? Shouldn't one be enough?

--Apple-Mail-1-946946988-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <47AEB025.8060700@proweb.co.uk> Date: Sun, 10 Feb 2008 08:04:53 +0000 From: maht User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] Hello Assembly References: <13426df10802090827m3d6447cxe07052f07263f5bc@mail.gmail.com> In-Reply-To: <13426df10802090827m3d6447cxe07052f07263f5bc@mail.gmail.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4e11600a-ead3-11e9-9d60-3106f5b1d025 > If you love assembly code, you are in need of a CAT scan in my view. chances are the CAT scanner was programmed in assembler ! From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sun, 10 Feb 2008 08:18:38 +0000 To: "Fans of the OS Plan 9 from Bell Labs" <9fans@cse.psu.edu> Subject: Re: [9fans] Hello Assembly From: "Eris Discordia" Content-Type: text/plain; format=flowed; delsp=yes; charset=iso-8859-15 MIME-Version: 1.0 References: <266b5e8c012b5d437346a87216ac5005@terzarima.net> Content-Transfer-Encoding: 7bit Message-ID: In-Reply-To: <266b5e8c012b5d437346a87216ac5005@terzarima.net> User-Agent: Opera Mail/9.23 (Win32) Topicbox-Message-UUID: 4e152dca-ead3-11e9-9d60-3106f5b1d025 On Sat, 09 Feb 2008 17:32:26 -0000, Charles Forsyth wrote: > the assembler is really just a front-end to the loader, and nothing to > do with `at&t syntax'. For the first ten minutes after reading that, I was wondering what the comment meant. Then I remembered in Plan 9 speak the loader means the linker. So, I gather from what you have pointed out that 8a assembly is actually some sort of intermediate language like MSIL (or GNU's version of AT&T assembly for the GCC backend). > and the <>) but generally i agree with brantley. some weeks i'm working > with several processors, > even several a day, and the `native' (in what sense? does the processor > implement them?) > assemblers typically differ in operand order, basic mnemonics (l/st vs > mov), and other conventions, > whereas the ?a family is uniformly data flow, and tends to use similar > instructions for > similar things. i find it much easier moving from platform to platform > with it. That is probably because assembly was never intended for moving from one platform to another all the time, but for squeezing the most out of a given platform whose nooks and crannies you ken well. The notion of a "native" assembler sounds strange to me. Netwide (nasm) is known for being available on many software/hardware platforms with similar syntax (the Intel syntax) all over. Of course, the instruction sets are far from identical but the syntax is still (almost) the same. Register access, for instance, is done by simply naming the register in an instruction: mov eax, 00h Compared to the AT&T syntax (for GNU assembler): movl $0x0, %eax (three extra keystrokes to get the same op-code) -- Using Opera's revolutionary e-mail client: http://www.opera.com/mail/ From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: From: Anant Narayanan To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v915) Subject: Re: [9fans] Hello Assembly Date: Sun, 10 Feb 2008 14:00:51 +0530 References: <566BA6DE-1CF7-40EE-B0E7-399EB2585F1B@kix.in> Topicbox-Message-UUID: 4e1920ec-ead3-11e9-9d60-3106f5b1d025 >> DATA string<>+0(SB)/8, $"Hello\n\z\z" > > Why are there two \zs? Shouldn't one be enough? One should be enough, but 8c -S does two \z's (probably to pad it out to exactly 8 bytes). It works either way, since the length we pass as an argument to pwrite is still $7. Regards, Anant From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Sun, 10 Feb 2008 09:56:26 +0100 From: Martin Neubauer To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] Hello Assembly Message-ID: <20080210085626.GA801@shodan.homeunix.net> References: <266b5e8c012b5d437346a87216ac5005@terzarima.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.4.2.3i Topicbox-Message-UUID: 4e20dfbc-ead3-11e9-9d60-3106f5b1d025 * Eris Discordia (eris.discordia@gmail.com) wrote: > That is probably because assembly was never intended for moving from one > platform to another all the time, but for squeezing the most out of a > given platform whose nooks and crannies you ken well. Nah, that's only what the intel assembler is for. Originally, assembly language was devised for not having to type in machine opcodes directly. With the advent of high level programming laguages its main merit became the ability to write those bits of operating system code that just cannot be written in a high level language. (Research) Unix was influential in that regard and showed that those parts are really small (and should be). Martin From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v753) In-Reply-To: <20080210085626.GA801@shodan.homeunix.net> References: <266b5e8c012b5d437346a87216ac5005@terzarima.net> <20080210085626.GA801@shodan.homeunix.net> Content-Type: multipart/alternative; boundary=Apple-Mail-2-1008817966 Message-Id: <1B092861-2EA7-4A22-921D-A2C2F91F59DC@mac.com> From: Pietro Gagliardi Subject: Re: [9fans] Hello Assembly Date: Sun, 10 Feb 2008 09:38:37 -0500 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 4e258d96-ead3-11e9-9d60-3106f5b1d025 --Apple-Mail-2-1008817966 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Feb 10, 2008, at 3:56 AM, Martin Neubauer wrote: > (Research) Unix was influential in that > regard and showed that those parts are really small (and should be). > > Martin I am working on rewriting an operating system that avoids this philosophy for the purpose of teaching assembly language. So far, I have 2% of the code (I started a rewrite), and I don't know if my code is 100% right. --Apple-Mail-2-1008817966 Content-Transfer-Encoding: quoted-printable Content-Type: text/html; charset=US-ASCII
On Feb 10, 2008, at = 3:56 AM, Martin Neubauer wrote:

(Research) Unix was = influential in that

regard and showed that those parts are really small (and = should be).


Martin

=

I am working on rewriting an operating = system that avoids this philosophy for the purpose of teaching assembly = language. So far, I have 2% of the code (I started a rewrite), and I = don't know if my code is 100% right.

= --Apple-Mail-2-1008817966-- From mboxrd@z Thu Jan 1 00:00:00 1970 Message-Id: From: Anant Narayanan To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> In-Reply-To: <1B092861-2EA7-4A22-921D-A2C2F91F59DC@mac.com> Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v915) Subject: Re: [9fans] Hello Assembly Date: Sun, 10 Feb 2008 22:25:15 +0530 References: <266b5e8c012b5d437346a87216ac5005@terzarima.net> <20080210085626.GA801@shodan.homeunix.net> <1B092861-2EA7-4A22-921D-A2C2F91F59DC@mac.com> Topicbox-Message-UUID: 4e29f7b4-ead3-11e9-9d60-3106f5b1d025 > I am working on rewriting an operating system that avoids this > philosophy for the purpose of teaching assembly language. So far, I > have 2% of the code (I started a rewrite), and I don't know if my > code is 100% right. There's an OS (complete with a Window Manager, IDE, Web Browser, and even some games) written entirely in assembly: http://www.menuetos.net/ Everyone has 24 hours in a day, but some use it more than others ;) -- Anant From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <0d1158f6fb2686277666a2e03182388e@quanstro.net> From: erik quanstrom Date: Sun, 10 Feb 2008 13:01:09 -0500 To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly In-Reply-To: MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4ecc342a-ead3-11e9-9d60-3106f5b1d025 > There's an OS (complete with a Window Manager, IDE, Web Browser, and > even some games) written entirely in assembly: http://www.menuetos.net/ > > Everyone has 24 hours in a day, but some use it more than others ;) > i can see from their documentation, that i have been using my time quite a bit more effectively: "Menuet has no roots within UNIX or the POSIX standards, nor is it based on any particular operating system. The design goal has been to remove the extra layers between different parts of an OS, which normally complicate programming and create bugs. here's their write system call: rbx - 1 Write rcx - Ignored rdx - Bytes to save rex - Pointer to data rfx - Filename pointer !? - erik From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v753) In-Reply-To: <0d1158f6fb2686277666a2e03182388e@quanstro.net> References: <0d1158f6fb2686277666a2e03182388e@quanstro.net> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <33FE9557-25C8-4B08-91E1-D44C0B1E2160@mac.com> Content-Transfer-Encoding: 7bit From: Pietro Gagliardi Subject: Re: [9fans] Hello Assembly Date: Sun, 10 Feb 2008 13:11:31 -0500 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 4ed95966-ead3-11e9-9d60-3106f5b1d025 In C, it could look like Write(char *filename, void *data, uvlong number_of_bytes); so I don't think it has an Open syscall, or probably you read everything into memory, modify the memory, then write it back. 64-bit systems can store quite a bit, but this philosophy will get old almost immediately: $ sed2c '1s/^/@/' # given sed2c is a program that converts sed commands to C char *buffer; buffer = malloc(FileLen("f")); Read("f", buffer, FileLen("f")); b[0] = '@'; Write("f", buffer, strlen(buffer)); Does that seem like a bit much? On Feb 10, 2008, at 1:01 PM, erik quanstrom wrote: >> There's an OS (complete with a Window Manager, IDE, Web Browser, and >> even some games) written entirely in assembly: http:// >> www.menuetos.net/ >> >> Everyone has 24 hours in a day, but some use it more than others ;) >> > > i can see from their documentation, that i have been using my time > quite > a bit more effectively: > > "Menuet has no roots within UNIX or the POSIX standards, > nor is it based on any particular operating system. The design > goal has been to remove the extra layers between different parts > of an OS, which normally complicate programming and create bugs. > > here's their write system call: > > rbx - 1 Write > > rcx - Ignored > rdx - Bytes to save > rex - Pointer to data > rfx - Filename pointer > > !? > > - erik From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 11 Feb 2008 13:36:38 +1100 From: Adrian Tritschler Subject: Re: [9fans] Hello Assembly In-reply-to: To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Message-id: MIME-version: 1.0 Content-type: text/plain; charset=us-ascii References: <266b5e8c012b5d437346a87216ac5005@terzarima.net> <20080210085626.GA801@shodan.homeunix.net> <1B092861-2EA7-4A22-921D-A2C2F91F59DC@mac.com> User-Agent: Gnus/5.110007 (No Gnus v0.7) Emacs/22.1 (gnu/linux) Topicbox-Message-UUID: 4f0663de-ead3-11e9-9d60-3106f5b1d025 Anant Narayanan writes: >> I am working on rewriting an operating system that avoids this >> philosophy for the purpose of teaching assembly language. So far, I >> have 2% of the code (I started a rewrite), and I don't know if my >> code is 100% right. > > There's an OS (complete with a Window Manager, IDE, Web Browser, and >even some games) written entirely in assembly: http://www.menuetos.net/ Or, if you want something at the other end of the spectrum, there's an OS "with modular microkernels using the C# programming language." http://arstechnica.com/news.ars/post/20080208-developers-create-open-source-os-kernels-using-net-tools.html > Everyone has 24 hours in a day, but some use it more than others ;) Indeed > Anant Adrian From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v753) In-Reply-To: References: <266b5e8c012b5d437346a87216ac5005@terzarima.net> <20080210085626.GA801@shodan.homeunix.net> <1B092861-2EA7-4A22-921D-A2C2F91F59DC@mac.com> Content-Type: multipart/alternative; boundary=Apple-Mail-10-1051918992 Message-Id: <871BE65B-FFE0-44FE-82AF-9D236D555D75@mac.com> From: Pietro Gagliardi Subject: Re: [9fans] Hello Assembly Date: Sun, 10 Feb 2008 21:36:58 -0500 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 4f17f27a-ead3-11e9-9d60-3106f5b1d025 --Apple-Mail-10-1051918992 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed On Feb 10, 2008, at 9:36 PM, Adrian Tritschler wrote: > OS "with modular microkernels using the C# programming language." Microsoft has too, and it outdates the other two. Unfortunately, it's only available in Microsoft and a select few universities. http://research.microsoft.com/os/singularity/ --Apple-Mail-10-1051918992 Content-Transfer-Encoding: 7bit Content-Type: text/html; charset=US-ASCII
On Feb 10, 2008, at 9:36 PM, Adrian Tritschler wrote:

OS "with modular microkernels using the C# programming language."


Microsoft has too, and it outdates the other two. Unfortunately, it's only available in Microsoft and a select few universities.


--Apple-Mail-10-1051918992-- From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v753) In-Reply-To: References: <266b5e8c012b5d437346a87216ac5005@terzarima.net> <20080210085626.GA801@shodan.homeunix.net> <1B092861-2EA7-4A22-921D-A2C2F91F59DC@mac.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: Content-Transfer-Encoding: 7bit From: Pietro Gagliardi Subject: Re: [9fans] Hello Assembly Date: Sun, 10 Feb 2008 21:39:52 -0500 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 4f1e47ce-ead3-11e9-9d60-3106f5b1d025 Oh, and I can't wait to see those two have GUI support. When I finish making my OS C- and portability-friendly, I'm going to start with graphics. On Feb 10, 2008, at 9:36 PM, Adrian Tritschler wrote: > Anant Narayanan writes: > >>> I am working on rewriting an operating system that avoids this >>> philosophy for the purpose of teaching assembly language. So far, I >>> have 2% of the code (I started a rewrite), and I don't know if my >>> code is 100% right. >> >> There's an OS (complete with a Window Manager, IDE, Web Browser, and >> even some games) written entirely in assembly: http:// >> www.menuetos.net/ > > Or, if you want something at the other end of the spectrum, there's an > OS "with modular microkernels using the C# programming language." > > http://arstechnica.com/news.ars/post/20080208-developers-create- > open-source-os-kernels-using-net-tools.html > >> Everyone has 24 hours in a day, but some use it more than others ;) > > Indeed > >> Anant > Adrian From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v753) In-Reply-To: References: <266b5e8c012b5d437346a87216ac5005@terzarima.net> <20080210085626.GA801@shodan.homeunix.net> <1B092861-2EA7-4A22-921D-A2C2F91F59DC@mac.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <8954C776-EF48-4E5D-B8A8-3A0F916510D9@mac.com> Content-Transfer-Encoding: 7bit From: Pietro Gagliardi Subject: Re: [9fans] Hello Assembly Date: Sun, 10 Feb 2008 21:40:57 -0500 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 4f24f862-ead3-11e9-9d60-3106f5b1d025 One more thing. Does anyone know if, in raw x86 assembly, RET implies STI? Thanks. From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <60278fa01e1f8b1d90553dc754c8f719@quanstro.net> From: erik quanstrom Date: Sun, 10 Feb 2008 21:55:16 -0500 To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly In-Reply-To: <8954C776-EF48-4E5D-B8A8-3A0F916510D9@mac.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4f510772-ead3-11e9-9d60-3106f5b1d025 > One more thing. Does anyone know if, in raw x86 assembly, RET implies > STI? Thanks. if it did, it would be impossible to call a function with interrupts off. - erik From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <47AFEA84.7070707@proweb.co.uk> Date: Mon, 11 Feb 2008 06:26:12 +0000 From: maht User-Agent: Thunderbird 2.0.0.9 (Windows/20071031) MIME-Version: 1.0 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Subject: Re: [9fans] Hello Assembly References: <266b5e8c012b5d437346a87216ac5005@terzarima.net> <20080210085626.GA801@shodan.homeunix.net> <1B092861-2EA7-4A22-921D-A2C2F91F59DC@mac.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 4f95fcec-ead3-11e9-9d60-3106f5b1d025 Windows 1, 2 &3 was done in assembler From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <2a0c333c33cb5c4a62170748e1d21f4d@csplan9.rit.edu> To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly Date: Mon, 11 Feb 2008 11:36:11 -0500 From: john@csplan9.rit.edu In-Reply-To: <566BA6DE-1CF7-40EE-B0E7-399EB2585F1B@kix.in> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 500c7be2-ead3-11e9-9d60-3106f5b1d025 > Thanks everybody (especially Jim and Charles), I got this to work. > Here's the final program: > > DATA string<>+0(SB)/8, $"Hello\n\z\z" > GLOBL string<>+0(SB), $8 > > TEXT _main+0(SB), 1, $0 > > MOVL $1, 4(SP) > MOVL $string<>+0(SB), 8(SP) > MOVL $7, 12(SP) > MOVL $-1, 16(SP) > MOVL $-1, 20(SP) > > MOVL $51, AX > INT $64 > > MOVL $string<>+0(SB), 4(SP) > MOVL $8, AX > INT $64 > > Jim pointed out that using RET was incorrect as the instruction > wouldn't know where to get back to. Calling exits() instead, works. > > Plan 9 gets more and more exciting for me, everyday :) > Thanks again! > > Cheers, > Anant I've always thought variables and such went at the bottom... or is that just m68k asm? John From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4694eb30ed7083d92b969bd4a1954f82@csplan9.rit.edu> To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly Date: Mon, 11 Feb 2008 11:39:24 -0500 From: john@csplan9.rit.edu In-Reply-To: <13426df10802090827m3d6447cxe07052f07263f5bc@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 5013f0f2-ead3-11e9-9d60-3106f5b1d025 > On Feb 9, 2008 8:17 AM, Brantley Coile wrote: >> I would like to hear what Rob or others have to say about the >> assembler syntax, but I actually like the syntax for the following >> reason. > > if you love assembly code, the assembler on Plan 9 is not great. > > If you love assembly code, you are in need of a CAT scan in my view. > > The v6 manual entry for as called assembly code "the ultimate dead > language". If only that had been true. > > gcc and friends have made the world safe for assembly, and there is more > assembly in use than ever. > > Writing assembly code should be as painful as possible. Plan 9 > succeeds in that regard. It's a good thing in my view. > > ron And if you can pass off the assembly writing task to an intern, all the better, right? :) I don't know... barring certain architecture gotchas, I enjoyed the assembly I did; it's sort of a relaxing break from C. John "Real Programmers Use FORTRAN" Floren From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <4249fd0fe06295fe2de7c79856aa206f@quanstro.net> To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly From: erik quanstrom Date: Mon, 11 Feb 2008 11:43:08 -0500 In-Reply-To: <2a0c333c33cb5c4a62170748e1d21f4d@csplan9.rit.edu> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 502174f2-ead3-11e9-9d60-3106f5b1d025 > I've always thought variables and such went at the bottom... or > is that just m68k asm? > > John you can put them anywhere. there's no typechecking in assembly and the linker doesn't care. - erik From mboxrd@z Thu Jan 1 00:00:00 1970 Message-ID: <3040f1a5e0a2c5a4057b370a6088d215@csplan9.rit.edu> To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly Date: Mon, 11 Feb 2008 11:45:51 -0500 From: john@csplan9.rit.edu In-Reply-To: <4249fd0fe06295fe2de7c79856aa206f@quanstro.net> MIME-Version: 1.0 Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: 7bit Topicbox-Message-UUID: 50267d76-ead3-11e9-9d60-3106f5b1d025 >> I've always thought variables and such went at the bottom... or >> is that just m68k asm? >> >> John > > you can put them anywhere. there's no typechecking in assembly > and the linker doesn't care. > > - erik Ok, maybe that was just a style thing they taught us. John From mboxrd@z Thu Jan 1 00:00:00 1970 Date: Mon, 11 Feb 2008 14:41:51 -0500 From: Jon Snader To: 9fans@cse.psu.edu Subject: Re: [9fans] Hello Assembly Message-ID: <20080211194151.GA94576@ix.netcom.com> References: <2a0c333c33cb5c4a62170748e1d21f4d@csplan9.rit.edu> <4249fd0fe06295fe2de7c79856aa206f@quanstro.net> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4249fd0fe06295fe2de7c79856aa206f@quanstro.net> User-Agent: Mutt/1.4.2.3i Topicbox-Message-UUID: 502c9d96-ead3-11e9-9d60-3106f5b1d025 On Mon, Feb 11, 2008 at 11:43:08AM -0500, erik quanstrom wrote: > > I've always thought variables and such went at the bottom... or > > is that just m68k asm? > > you can put them anywhere. there's no typechecking in assembly > and the linker doesn't care. > When I started programming (so long ago that assembly and Fortran were basically the only games in town) we always put the data at the end--it just seemed fitting somehow. Later, the best practice became to put them at the beginning on the grounds that the data wouldn't move as changes where made to the program; in those days, all manner of strange things happened like programs that knew where the data portion of other programs lived. If nothing else, it made the (very crude) dumps easier to work with. jcs From mboxrd@z Thu Jan 1 00:00:00 1970 Mime-Version: 1.0 (Apple Message framework v753) In-Reply-To: <20080211194151.GA94576@ix.netcom.com> References: <2a0c333c33cb5c4a62170748e1d21f4d@csplan9.rit.edu> <4249fd0fe06295fe2de7c79856aa206f@quanstro.net> <20080211194151.GA94576@ix.netcom.com> Content-Type: text/plain; charset=US-ASCII; delsp=yes; format=flowed Message-Id: <3DAE8847-1D3B-4BDD-B930-95A7E2FB2396@mac.com> Content-Transfer-Encoding: 7bit From: Pietro Gagliardi Subject: Re: [9fans] Hello Assembly Date: Mon, 11 Feb 2008 14:49:37 -0500 To: Fans of the OS Plan 9 from Bell Labs <9fans@cse.psu.edu> Topicbox-Message-UUID: 5032068c-ead3-11e9-9d60-3106f5b1d025 It's also that x86 segments memory into code, data, and stack, so you can have .code OR EAX, EAX // produces less binary than CMP EAX, 0; JE X JZ X JMP Y Y: .data str DB 'less\z' .code // ... .data .code .stack .code .data On Feb 11, 2008, at 2:41 PM, Jon Snader wrote: > On Mon, Feb 11, 2008 at 11:43:08AM -0500, erik quanstrom wrote: >>> I've always thought variables and such went at the bottom... or >>> is that just m68k asm? >> >> you can put them anywhere. there's no typechecking in assembly >> and the linker doesn't care. >> > > When I started programming (so long ago that assembly and Fortran > were basically the only games in town) we always put the data at > the end--it just seemed fitting somehow. Later, the best > practice became to put them at the beginning on the grounds that > the data wouldn't move as changes where made to the program; in > those days, all manner of strange things happened like programs > that knew where the data portion of other programs lived. If > nothing else, it made the (very crude) dumps easier to work with. > > jcs