• Announcements

    • khawk

      Download the Game Design and Indie Game Marketing Freebook   07/19/17

      GameDev.net and CRC Press have teamed up to bring a free ebook of content curated from top titles published by CRC Press. The freebook, Practices of Game Design & Indie Game Marketing, includes chapters from The Art of Game Design: A Book of Lenses, A Practical Guide to Indie Game Marketing, and An Architectural Approach to Level Design. The GameDev.net FreeBook is relevant to game designers, developers, and those interested in learning more about the challenges in game development. We know game development can be a tough discipline and business, so we picked several chapters from CRC Press titles that we thought would be of interest to you, the GameDev.net audience, in your journey to design, develop, and market your next game. The free ebook is available through CRC Press by clicking here. The Curated Books The Art of Game Design: A Book of Lenses, Second Edition, by Jesse Schell Presents 100+ sets of questions, or different lenses, for viewing a game’s design, encompassing diverse fields such as psychology, architecture, music, film, software engineering, theme park design, mathematics, anthropology, and more. Written by one of the world's top game designers, this book describes the deepest and most fundamental principles of game design, demonstrating how tactics used in board, card, and athletic games also work in video games. It provides practical instruction on creating world-class games that will be played again and again. View it here. A Practical Guide to Indie Game Marketing, by Joel Dreskin Marketing is an essential but too frequently overlooked or minimized component of the release plan for indie games. A Practical Guide to Indie Game Marketing provides you with the tools needed to build visibility and sell your indie games. With special focus on those developers with small budgets and limited staff and resources, this book is packed with tangible recommendations and techniques that you can put to use immediately. As a seasoned professional of the indie game arena, author Joel Dreskin gives you insight into practical, real-world experiences of marketing numerous successful games and also provides stories of the failures. View it here. An Architectural Approach to Level Design This is one of the first books to integrate architectural and spatial design theory with the field of level design. The book presents architectural techniques and theories for level designers to use in their own work. It connects architecture and level design in different ways that address the practical elements of how designers construct space and the experiential elements of how and why humans interact with this space. Throughout the text, readers learn skills for spatial layout, evoking emotion through gamespaces, and creating better levels through architectural theory. View it here. Learn more and download the ebook by clicking here. Did you know? GameDev.net and CRC Press also recently teamed up to bring GDNet+ Members up to a 20% discount on all CRC Press books. Learn more about this and other benefits here.

Archived

This topic is now archived and is closed to further replies.

newOperator

Changing 32-bit int to ASCII in ASM?

4 posts in this topic

I have a new appreciation for computers now, considerring what I took for granted before, but maybe there is an easy solution to the following: How would some one change an integer to an ascii string representation of the integer in base ten, of course. It seems easy enough to do with small numbers, but not so easy with larger numbers, for some reason... I don''t know. So for instance taking 1110 1110 and changing it to the appropriate bytes (oh man, maybe that''s it) but 238... I still am not sure. Thank-ya
0

Share this post


Link to post
Share on other sites
You could simply call the appropriate C function from your asm code.

Otherwise you just have to bite the bullet and code it yourself.
0

Share this post


Link to post
Share on other sites
Actually I want to code it myself -- I''m reading Elite Programmer''s Delight with tons of bit manipulations in it, and tons of simple ways to do the coolest things, mostly in assembler. But I can''t find anything on how to change an integer to an ascii representation.
0

Share this post


Link to post
Share on other sites
quote:
Original post by newOperator
Actually I want to code it myself -- I''m reading Elite Programmer''s Delight with tons of bit manipulations in it, and tons of simple ways to do the coolest things, mostly in assembler. But I can''t find anything on how to change an integer to an ascii representation.

Fair enough. I usualy do things in C then convert it to asm - to make sure the algorithm is working.

You could calculate the modulus of 10 to get the least significant digit, then divide by 10 and repeat the process. Of course, that gives you the digits in reverse order - so you''ll have to figure your way around that little problem..
0

Share this post


Link to post
Share on other sites
well its not x86 asm which is prolly what you want. but i actualy had to write an integer to hexadecimal (ascii) program for my digital systems class the other day. unfortunatly its RISC asm for a MIPS processor... here is a slightly modified version that takes a 32 bit word, a buffer, and a radix and converts the word into an ascii string of the right radix.


.data
prompt1: .asciiz "Enter a number: "
prompt2: .asciiz "Enter the base to convert to: "
result: .asciiz "The converted number is: "
endl: .asciiz "\n"
buffer: .space 80
number: .word 0
radix: .word 0

.text
.globl main
main:
la $a0,prompt1
li $v0,4
syscall

li $v0,5
syscall

sw $v0,number

la $a0,prompt2
li $v0,4
syscall

li $v0,5
syscall

sw $v0,radix

lw $a0,number
la $a1,buffer
lw $a2,radix
jal itoa

la $a0,result
li $v0,4
syscall

la $a0,buffer
li $v0,4
syscall

la $a0,endl
li $v0,4
syscall

li $v0, 10
syscall

itoa:
li $t0,'' ''
bgez $a0,itoa_start
li $t0,''-''
neg $a0,$a0
itoa_start:
sb $t0,0($a1)
addi $a1,$a1,1
move $t0,$a1
itoa_loop_start:
div $a0,$a2
mflo $a0
mfhi $t1
blt $t1,10,itoa_less_than_10
b itoa_greater_than_10
itoa_less_than_10:
addi $t1,$t1,''0''
sb $t1,0($t0)
addi $t0,$t0,1
bnez $a0,itoa_loop_start
sb $zero,0($t0)
b itoa_reverse
itoa_greater_than_10:
addi $t1,$t1,87
sb $t1,0($t0)
addi $t0,$t0,1
bnez $a0,itoa_loop_start
sb $zero,0($t0)
itoa_reverse:
addi $t0,$t0,-1
ble $t0,$a1,itoa_end
lbu $t2,0($a1)
lbu $t3,0($t0)
sb $t2,0($t0)
sb $t3,0($a1)
addi $a1,$a1,1
b itoa_reverse
itoa_end:
addi $a1,$a1,1
jr $ra
.end


i guess you could convert that to x86 asm. i dont know x86 asm like the back of my hand yet so itd take me a long time to do it.

my instructor had the c source code, if i can find it ill post it. its pretty neat.

Bungo!
0

Share this post


Link to post
Share on other sites