Skip to main content
GameDev.net gamedev.net
🔒 Locked

Assembly Programming

Started by eriel Apr 27, 2003 at 6:40 PM 17 replies 2.8k views
Original Post
eriel
eriel
I''ve decided to try to learn 16 bit assembly to increase my knowledge on how programming works. I want to get a book, but I don''t know what book to get. Any suggestions on good books, assemblers, or other resources would be greatly appreciated. Thanks!
sjelkjd
sjelkjd
16 bit assembly? You have a 16 bit cpu? I''m curious, which one?

For x86 asm I''d recommend art of assembly.
Burning_Ice
Burning_Ice
well if it's just for learning and not writing actual assembler-programs i can recommend you to do the same we do at uni, and learn MIPS assembler. it's different from x86, but there is the nice SPIM simulator for it.
This means you can write and run the asm code on every DOS/WIN/*NIX machine, and the best thing: since the code runs on the simulator the usual stuff that happens when experimenting with asm (bluescreens/crashes) can't happen.
And the thing also provides a debugger.

MIPS tutorials should be easy to find and amazon shows a good number of books on MIPS.
i can't give you any MIPS-specific book-recommendations tho since i'm learning it from the couple chapters that cover it in our textbook (Computer Organization & Design: The Hardware/Software Interface, which is a cool book and worth the read even if you dont study CS/CE, just as a side-note )


My Homepage


[edited by - burning_ice on April 27, 2003 8:05:12 PM]
eriel
eriel
sjelkjd - My friend has an old Texas Instruments 99-4A that I was interested in trying to write games and programs for. I have AoA, but I am not able to print it off and use it away from the computer.

Burning_Ice - I am interested in all different variations of assembly, x86 for my own computer, but was inquiring for the Texas Instruments 99-4A computer. MIPS assembler sounds like something I could use.

Thanks for the replies!
CWizard
CWizard
Go and find a dusty Amiga 500/1200/2000 and learn Motorola 68000 assembly. I really think that would be very good learning experience. The Amiga OS'' API is designed primarily for assembly, so it''s really easy to get started, and the 68k has the most intuitive instruction set I have ever used.


JONSKI
JONSKI
I agree with Burning_Ice. You should try learning assembly for a RISC processor like MIPS. RISC stands for Reduced Instruction Set Computer. As the name implies, it''s has a smaller set of instructions that you could memorize after using just a few times. This doesn''t limit its abilities, but rather eliminates redundant instructions. MIPS is also nice, because it has 32 general-purpose registers as opposed to x86''s 8. MIPS''s opcode instructions are also ALL 4 bytes long. Intel''s instructions vary in size depending on the instruction (IIRC the longest opcode instruction is 17 bytes!). x86 and it''s IA-xx (Intel Architecture) derivatives are CISC (Complex Instruction Set Computer). As it''s name implies, it has a large set of instructions. At one point it was standard practice to program in assembly, so Intel decided to make that easier by including redundant instructions that did the job of several instructions combined. In order to be backward compatable, these instructions have been carried through EIGHT generations of processors and have been expanded with SIMD instructions!!! I''m about one paragraph away from jumping on the soapbox about how ridiculous that is, but I will spare your ears (or eyes) of this.

Anyways, good luck.
Interests: my money-pit car, computer hardware/programming, anything 3D'93 RX-7
fodd3r
fodd3r
"My friend has an old Texas Instruments 99-4A that I was interested in trying to write games and programs for. I have AoA, but I am not able to print it off and use it away from the computer."

First, assembly is not a specific language. Different processors have their own flavours which vary. So, first figure out what processor/machine you''re going to code for -- you seem to have done this. Then do a quick google search to see if there are any online books/resources. Also, check out TI''s site, they might have something.
CWizard
CWizard
quote:
Original post by JONSKI
You should try learning assembly for a RISC processor like MIPS. RISC stands for Reduced Instruction Set Computer. As the name implies, it''s has a smaller set of instructions that you could memorize after using just a few times.
I would think that it is easier to work with a more powerful instruction set. Perhaps I''m wrong or biased, not sure. RISC processors are not designed for humans but for compilers, as I see it.

Intel x86 is pure crap, with its huge, inconsistent, complex, patched and generally stupid instruction set.

680x0, on the other hand, is extremely nice to work in, due to its consistensy and the great addressing modes, and general purpose registers (although only 16). You can often do stuff in a single instruction that would require 3-4 x86 instructions and maybe 8-10 RISC instructions (rough guess). For me, it''s not much more time consuming coding 680x0 than to code C.
sjelkjd
sjelkjd
I have to second the earlier suggestion to get and use SPIM, the MIPS emulator.

MIPS is a good ISA to learn from, it''s fairly consistent and is fairly popular in modern cpus. For example, the PS2 uses MIPS. Also, my undergrad architecture classes covered MIPS.

CWizard: actually, you could argue the opposite regarding RISC and compilers, since the life of a compiler writer is easier when there are more powerful instructions available. I''ve always thought of RISC vs. CISC as compiler complexity vs. hardware complexity.

On that note, hardware advances sure beat the heck out of software advances over the years.
CWizard
CWizard
About RISC, I haven't really worked with any so I don't know exactly how work. From what I figure, it's something like the RISC processor's instructions maps almost directly to the processor's micro code. Right?

This might be a bit unfair, and probably not correct, but an illustration why I don't think RISC is for humans:

; Motorola 680x0 instruction
; a0-7 32-bit address regs, d0-7 32-bit data regs
; Adds the long value at: (*(*a0 + d0 * 8) + 96)
; To the value at: (*(*a1 + d1 * 8) + 12)
add.l 96([a0,d0.W*8]),12([a1,d1.W*8])

; Corresponding Pseudo RISC instructions
; (x) means the value at the address of x
; I assume you can use the tempororary registers of the processor, so I call them tmp1, tmp2, ...
move (a0),tmp1 ; Get value to add by in temporary register (3)
move d0,tmp2
mul 8,tmp2
add tmp2,tmp1
move (tmp1),tmp2
add 12,tmp2
move (tmp2),tmp3

move (a1),tmp1 ; Get value to add to in temporary register (4),
move d1,tmp2 ; and its address in temporary register (2)
mul 8,tmp2
add tmp2,tmp1
move (tmp1),tmp2
add 12,tmp2
move (tmp2),tmp4

add tmp4,tmp3 ; Perform the addition, and put back the result
move tmp3,(tmp2)
I admit that you probably can do it in fewer instructions, but it's just an illustration.




[edited by - CWizard on April 28, 2003 5:26:39 AM]
Ilici
Ilici
if u want to write 3d games u gotta learn some assembly if u want to do things faster. (write whole functions in assembly)

i dunno if u can use a C compiler on ur Texas Instruments computer u got there, so if u wanna do smth u gotta do it in assembly.

to get started make some simple things like gettin a string from the console, unsing ports, interrupts.

noVum
noVum
quote:
Original post by sjelkjd
16 bit assembly? You have a 16 bit cpu? I'm curious, which one?

For x86 asm I'd recommend art of assembly.


Every x86 processor can operate in 16 bit mode

[edited by - novum on April 28, 2003 9:23:39 AM]
raging_jakl
raging_jakl
quote:
Original post by CWizard
Go and find a dusty Amiga 500/1200/2000 and learn Motorola 68000 assembly. I really think that would be very good learning experience. The Amiga OS'' API is designed primarily for assembly, so it''s really easy to get started, and the 68k has the most intuitive instruction set I have ever used.





Or you could use this editor, assembler simulator that my professeur and I wrote for the 68000. Works quite well is and still being updated.

Check it out here
http://www.monroeccc.edu/ckelly/tools68000.htm
CGameProgrammer
CGameProgrammer
Any time you use a "short" or "WORD" you are using 16-bit commands. So of course x86s have 16-bit commands.

But there isn''t any reason to learn specifically 16-bit assembly because 32-bit isn''t any more complicated. Here''s a 16-bit add:

mov ax, 2
mov bx, 3
add ax, bx

Here''s a 32-bit add:

mov eax, 2
mov ebx, 3
add eax, ebx

All the instructions are like that. There''s a few advanced exceptions but basically it''s the same instructions. Here''s an 8-bit add if you''re curious:

mov al, 2
mov bl, 3
add al, bl

~CGameProgrammer( );
DevImg.net - Post screenshots, comment on others.
Town 3D Engine - A city-rendering 3D engine. Download the demo.
~CGameProgrammer( ); Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
CWizard
CWizard
quote:
Original post by raging_jakl
Or you could use this editor, assembler simulator that my professeur and I wrote for the 68000. Works quite well is and still being updated.
Or, better yet. Download WinUAE (Amiga emulator) and install Asm-One (the f*** best IDE ever made). I still use that combination from time to time, almost rather than my real A1200 because I can use 1600x1200 resolution .


Snash
Snash
x86 ASM is pretty easy, but if your going to write programs, I wouldnt use ASM.
Learning Assembly really teaches you how a computer works, I would start with the Assembly you need, Eg Texas instrument instructionsset.
Todays compilers compile nearly as fast code as a human can, so I wouldnt count on that you will gain alota speed if writing some specifik rendercode in ASM.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.