Omnimaga: The Coders Of Tomorrow
Welcome, Guest. Please login or register.
 
Omnimaga: The Coders Of Tomorrow
20 May, 2013, 15:37:52 *
Welcome, Guest. Please login or register.

Login with username, password and session length
 
   home   news downloads projects tutorials misc forums rules new posts irc about Login Register  
+-OmnomIRC

You must Register, be logged in and have at least 40 posts to use this shout-box! If it still doesn't show up afterward, it might be that OmnomIRC is disabled for your group or under maintenance.

Note: You can also use an IRC client like mIRC, X-Chat or Mibbit to connect to an EFnet server and #omnimaga.

Pages: [1]   Go Down
  Print  
Author Topic: Set by Address restrictions? -  (Read 363 times) Bookmark and Share
0 Members and 1 Guest are viewing this topic.
systwo
LV2 Member (Next: 40)
**
Offline Offline

Last Login: 03 February, 2012, 10:16:24
Date Registered: 13 January, 2012, 07:06:05
Posts: 25

Topic starter
Total Post Ratings: +7

View Profile
« on: 15 January, 2012, 06:14:12 »
+2

Hello again everyone!

I'm going through Hot Dog's tutorial on asm right now and I have encountered a slight problem. Working with variables, ld doesn't want to set a register. In the snippet below, the first line will work but the second one will not. Is there something I skipped over accidentally?


1
2
ld a, (var1)
ld b, (var1)

The error spasm outputs:

1
2
3
4
5
Pass one...
learn2.asm:7: warning: Suggest remove extra parentheses around argument
Pass two...
learn2.asm:7: warning: Number is too large to fit in 8 bits, truncating
Done



Here is the code


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
;Multiplication program
#include "ti83plus.inc"
.org $9d93
.db t2ByteTok, tAsmCmp
B_CALL _ClrLCDFull
ld a, (Mula) ;Holds the answer
ld b, (Mulb) ;How many times to multiply
ld c, a      ;What to add every time it multiplies, or else it will do powers


BeginLoop:
add a, c
djnz BeginLoop ;Remember that the b is decresed before it checks
ld h, 0
ld l, a

B_CALL _DispHL

ret


Mula:
.db 5

Mulb:
.db 5




Thanks!


Edit:
Found the answer! For those who look at this in the future, you can only use register a to retrieve data. You need to store the memory address in hl for other registers.
« Last Edit: 15 January, 2012, 06:51:09 by systwo » Logged
Hot_Dog
If you can't find a cat, look for its tail.
Support Staff
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: 09 May, 2013, 19:22:43
Date Registered: 28 December, 2009, 18:47:54
Location: Midland, Washington
Posts: 2940


Total Post Ratings: +428

View Profile
« Reply #1 on: 15 January, 2012, 06:59:25 »
0

You can also get the value in register A, and then use "ld b, a"

Wonderful job on this program so far!  Keep up the good work!
Logged

There are people who can speak two languages, and they are called bilingual.  There are people who speak three languages and are therefore trilingual.  Then there are people who speak one language, and these people are called Americans.

Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 18 May, 2013, 00:55:01
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Total Post Ratings: +1019

View Profile
« Reply #2 on: 15 January, 2012, 08:34:43 »
0

There is also another cool trick the same size and speed almost the same speed as Hot_Dog's suggestion but destroys the value of 'c' instead of 'a' (in case you need to preserve a).


1
ld bc,(var1-1)

This works because 2 byte numbers are stored as little endian in memory.
« Last Edit: 15 January, 2012, 09:20:27 by Quigibo » Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
Runer112
Anti-Riot Squad
LV10 31337 u53r (Next: 2000)
*
Offline Offline

Gender: Male
Last Login: Today at 06:42:06
Date Registered: 02 July, 2009, 06:38:05
Posts: 1679


Total Post Ratings: +492

View Profile
« Reply #3 on: 15 January, 2012, 08:39:28 »
0

I think you mean:


1
2
ld bc,(var1-1) ;c=(var1-1), b=(var1)

And that's the same size as Hot_Dog's suggestion, but it's 3 cycles slower. Wink
Logged
Quigibo
The Executioner
LV11 Super Veteran (Next: 3000)
***********
Offline Offline

Gender: Male
Last Login: 18 May, 2013, 00:55:01
Date Registered: 22 January, 2010, 05:02:37
Location: Los Angeles
Posts: 2022


Total Post Ratings: +1019

View Profile
« Reply #4 on: 15 January, 2012, 09:20:32 »
0

Oops yeah, you're right, I was thinking of hl.  Fixed.
Logged

___Axe_Parser___
Today the calculator, tomorrow the world!
systwo
LV2 Member (Next: 40)
**
Offline Offline

Last Login: 03 February, 2012, 10:16:24
Date Registered: 13 January, 2012, 07:06:05
Posts: 25

Topic starter
Total Post Ratings: +7

View Profile
« Reply #5 on: 15 January, 2012, 21:02:09 »
0

Wow! Thanks for the advice, I have yet to reach the multi-byte storage lesson yet, but I'm sure it will make sense to me when I get there.
Logged
Hot_Dog
If you can't find a cat, look for its tail.
Support Staff
LV11 Super Veteran (Next: 3000)
*
Offline Offline

Gender: Male
Last Login: 09 May, 2013, 19:22:43
Date Registered: 28 December, 2009, 18:47:54
Location: Midland, Washington
Posts: 2940


Total Post Ratings: +428

View Profile
« Reply #6 on: 15 January, 2012, 21:56:21 »
0

There is also another cool trick the same size and speed almost the same speed as Hot_Dog's suggestion but destroys the value of 'c' instead of 'a' (in case you need to preserve a).


1
ld bc,(var1-1)

This works because 2 byte numbers are stored as little endian in memory.

That's one of those tricks that totally makes sense but someone like me forgets about Grin
Logged

There are people who can speak two languages, and they are called bilingual.  There are people who speak three languages and are therefore trilingual.  Then there are people who speak one language, and these people are called Americans.

Pages: [1]   Go Up
  Print  
 
Jump to:  

Powered by EzPortal
Powered by MySQL Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Powered by PHP
Page created in 0.253 seconds with 31 queries.
Skin by DJ Omnimaga edited from SMF default theme with the help of tr1p1ea.
All programs, games and songs avaliable on this website are property of their respective owners.
Best viewed in Opera, Firefox, Chrome and Safari with a resolution of 1024x768 or above.