Don't have an account? Register now to chat, post, use our tools, and much more.
Online Users
There are 85 users online: 4 members, 57 guests and 24 bots.
Members: blue_bear_94, parrotgeek1, rfdave.
Bots: MSN/Bing (1), VoilaBot (1), Googlebot (20), MSN/Bing (2).
RSS & Social Media
SAX
You must log in to view the SAX chat widget
Author Message
KermMartian

Joined: 14 Mar 2005
Posts: 55773
Location: Earth, Sol, Milky Way

 Posted: 10 Sep 2006 09:51:08 am    Post subject: Indirection Q: What's with the parentheses sometimes used with ld? A: OK, this is because of something called indirection. For simplicity's sake, let's assume you have a piece of memory that can hold exactly 2^16th bytes (sets of 8 bits). That means that you can 'address' the memory by assigning each of the 2^16 bytes with a number between 0 and 65535. Now, each of these spaces store a byte, so you want to be able to get the contents and store to each (reading and writing). Since registers can store numbers (a, b, c, d, e, h, and l hold one byte, and bc, de, hl, sp, ix, and iy hold 2 bytes each). Two bytes is exactly what we need to store 16-bit numbers, so let's put the number, hmmm, 42 in hl. That means hl will hold the number 42. In order to actually put 42 in hl, we use a regular load statement: Code: `ld hl,42` Easy enough. But say we want to save that for later. In ourt theoretical memory, let's decide that we want the 1,338th location to hold our number. Its address is 1337 (because remember that the first location is 0), so we want to store hl into the _address_ 1337. To do that, we can use: Code: ```ld hl,1337 ld (hl),42``` Here we have both methods together. First, we are simply loading the number 1337 into hl. Next, we are loading 42 into the address of memory named by hl. This will put the binary equivalent of 42 into address 1337 of memory. If we want it again, we simply do: Code: `ld hl,(1337)` This gets the contents of 1337 into hl, which is 42, instead of putting the number 1337 into hl. Makes sense?_________________
calc84maniac

Epic z80 roflpwner

Joined: 01 Aug 2006
Posts: 1503
Location: The ex-planet Pluto

 Posted: 10 Sep 2006 11:22:32 am    Post subject: Yes, it somehow does. _________________~calc84maniac has spoken. Projects: TI-Boy SE F-Zero Super Mario (aka Project M)
something1990

Supreme Commander of the Asgard Fleet

Joined: 12 Jan 2006
Posts: 1144
Location: Orilla

 Posted: 10 Sep 2006 11:55:42 am    Post subject: It more than "somehow does" make sense. Kerm explained it in an understandable way. I have one question though. You have to load the address to hl and then load the value to that address right? You can't simply do ld (1337) , 42?_________________Check the links: Please help save Stargate SG-1.
KermMartian

Joined: 14 Mar 2005
Posts: 55773
Location: Earth, Sol, Milky Way

 Posted: 10 Sep 2006 01:26:17 pm    Post subject: Only because of limitations of the z80. That's essentially what I'm doing in two instructions._________________
Ultimate Dev'r

Joined: 16 Mar 2005
Posts: 7297

 Posted: 10 Sep 2006 04:13:59 pm    Post subject: Generally you don't have this problem with microcontrollers _________________
KermMartian

Joined: 14 Mar 2005
Posts: 55773
Location: Earth, Sol, Milky Way

 Posted: 10 Sep 2006 06:54:42 pm    Post subject: By the way, here are the C equivalents: Code: `hl=42;` Code: ```hl=1337; *hl = 42;``` Code: ```a = 1337; hl = *a;```_________________
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

»
 Page 1 of 1 » All times are GMT - 5 Hours

 Jump to: Select a forum Announcements----------------Cemetech AnnouncementsCemetech LabsContests General Discussion----------------Technology & Calculator Open Topic-- Electronics/Hardware Development-- Calculator HardwareYour ProjectsGeneral Open Topic-- Politics & Rants-- Reviews-- Humour/Jokes Cemetech's Projects----------------Doors CSSourceCoderMember Features-- TI-Freak8x-- Merthsoft-- GrammerOther & Upcoming Projects-- The BASIC Elite-- mobileTunes-- CALCnet 2.2-- SuggestionsProgramming the TI-83 Plus/TI-84 PlusUsing the TI-83 Plus/TI-84 PlusWebsite Programming & Design----------------General Programmingz80 AssemblyTI-BASICCasio Prizm/FX Development & ProgrammingWebsite Markup & ScriptingGraphics1337 Programming Tips Building with Blocks----------------FreeBuild, LEGO, and Minecraft-- FreeBuild General-- Suggestions & Troubleshooting-- Content & Gallery-- Servers & Activities
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

© Copyright 2000-2013 Cemetech & Kerm Martian :: Page Execution Time: 0.028397 seconds.