I have been working on my first big assembly program. But it appears I have made and error somewhere.


Code:

.NOLIST
#define   EQU   .equ
#define   equ   .equ
#define   END   .end
#define   end   .end
#include "ti83plus.inc"
.LIST
 .org 9D93h
 .db $BB,$6D
 ld DE,100 ; Set the variables
 ld (CHH),DE
 ld DE,100
 ld (RHH),DE
 ld DE,100
 ld (EHH),DE
 ld DE,100
 ld (GHH),DE
 ld DE,100
 ld (UH),DE
 
 bcall(_RunIndicOff)
 call title
COMPARE: ;Just a point to jump to
 call MENU
GET: ; This reads the key press and jumps to correct option
 bcall(_GetKey)
 cp 143
 jr z,ONO
 cp 144
 jr z,ONT
 cp 145
 jr z,ONTHR
 cp 146
 jp z,ONF
 cp 9
 jp z,EXIT
 cp 5
 jr z,GET
 jr nz,GET
 ret
ONO: ; Option 1
 ld DE,$00
 ld DE,(CHH)
 dec DE
 ld (CHH),DE
 ld a,25
 ld (penRow),a
 ld a,15
 ld (penCol),a
 ld hl,CHT
 bcall(_VPutS)
 bcall(_GetKey)
 bcall(_ClrLCDFull)
 jp ENEMYH
ONT: ; Option 2
 ld a,(EHH)
 dec a
 ld (EHH),a
ONTHR: ; Option 3
ONF: ; Option 4
MENU: ; The main menu
 bcall(_ClrLCDFull)
 ld a,40
 ld (penRow),a
 ld a,0
 ld (penCol),a
 ld hl,LINE
 bcall(_VPutS)
 ld a,2
 ld (penRow),a
 ld a,8
 ld (penCol),a
 ld hl,TAR
 bcall(_VPutS)
 ld a,45
 ld (penRow),a
 ld a,2
 ld (penCol),a
 ld hl,CHIN
 bcall(_VPutS)
 ld a,55
 ld (penRow),a
 ld a,2
 ld (penCol),a
 ld hl,EGYP
 bcall(_VPutS)
 ld a,45
 ld (penRow),a
 ld a,55
 ld (pencol),a
 ld hl,RUSS
 bcall(_VPutS)
 ld a,55
 ld (penRow),a
 ld a,55
 ld (penCol),a
 ld hl,GREC
 bcall(_VPutS)
 ret

Title: ; Title Page, nothing important here
 bcall(_ClrLCDFull)
 ld hl,$00
 ld (CurRow),hl
 ld hl,WEL
 bcall(_PutS)
 bcall(_NewLine)
 ld hl,THER
 bcall(_PutS)
 bcall(_NewLine)
 ld hl,WAR
 bcall(_PutS)
 bcall(_NewLine)
 ld a,50
 ld (penRow),a
 ld a,15
 ld (penCol),a
 ld hl,CRED
 bcall(_VPutS)
 bcall(_GetKey)
 ret

ENEMYH: ; Page that displays the enemys health
 ld a,5
 ld (penRow),a
 ld a,0
 ld (penCol),a
 ld hl,CHTT
 bcall(_VPutS)
 ld hl,1
 ld (curRow),hl
 ld hl,8
 ld (curCol),hl
 ld HL,(CHH)
 bcall(_DispHL)
 bcall(_GetKEy)
 jp compare

WEL:
 .db "  WELCOME TO",0

THER:
 .db " THERMONUCLEAR",0

WAR:
 .db "      WAR",0

CRED:
 .db "CREATED BY OPRED",0

LINE:
 .db "-----------------------",0

TAR:
 .db "WHO IS OUR TARGET, SIR?",0

CHIN:
 .db "1.China",0

RUSS:
 .db "3.Russia",0

EGYP:
 .db "2.Egypt",0

GREC:
 .db "4.Greece",0

CHT:
 .db "YOU HIT CHINA",0

CHTT:
 .db "Chinas Health:",0

RUT:
 .db "YOU HIT RUSSIA",0

RUTT:
 .db "RUSSIAS HEALTH:",0

EQT:
 .db "YOU HIT EGYPT",0

EHH:
.db $0A

RHH:
.db $14

GHH:
 .db $1E

UH:
 .db $32

CHH:
 .db 28

EXIT:
 bcall(_ClrLCDFull)
 ret
 
.end
end



When ran the value for china's health is 65****, but when i remove



Code:

 ld DE,100
 ld (RHH),DE
 ld DE,100
 ld (EHH),DE
 ld DE,100
 ld (GHH),DE
 ld DE,100
 ld (UH),DE


It works perfectly. What is the error here? Shouldn't it just set the value to 100?

I tried to make a variable by

Code:

 CHH .equ AppBackUpScreen
 EHH .equ AppBackUpScreen+9

and etc. But Tasm cant compile it.

So what have I done wrong here?
Welcome to Cemetech! A few recommendations:
1) TASM is outdated and has a number of issues. Have you considered Brass, SPASM-ng, or even emSPASM-ng in SourceCoder?
2) Since labels don't affect the size of the output ASM program, let them be longer and more descriptive! Why use ENEMYH when you can use Display_Enemy_Health:?
3) Convention and good coding practices put the data after all the code in the program, so EXIT shouldn't be hiding after your .dbs.

The problem with your program is that you're defining EH, UHH, etc as .db (one byte), but you're using them with a two-byte register, DE. If you want them to be two bytes, you need to reserve their space using .dw. An even better option would be to use AppBackupScreen, as you were starting to do. At the beginning of the program, even before the .org, you'd do something like:

Code:
EHH .equ AppBackupScreen  ; 2 bytes
RHH .equ EHH + 2  ; 2 bytes
GHH .equ RHH + 2  ; 2 bytes
UH .equ GHH + 2  ; 2 bytes
CHH .equ UH + 2  ; 2 bytes (but please make these names more descriptive!
KermMartian wrote:
Welcome to Cemetech! A few recommendations:
1) TASM is outdated and has a number of issues. Have you considered Brass, SPASM-ng, or even emSPASM-ng in SourceCoder?
2) Since labels don't affect the size of the output ASM program, let them be longer and more descriptive! Why use ENEMYH when you can use Display_Enemy_Health:?
3) Convention and good coding practices put the data after all the code in the program, so EXIT shouldn't be hiding after your .dbs.

The problem with your program is that you're defining EH, UHH, etc as .db (one byte), but you're using them with a two-byte register, DE. If you want them to be two bytes, you need to reserve their space using .dw. An even better option would be to use AppBackupScreen, as you were starting to do. At the beginning of the program, even before the .org, you'd do something like:

Code:
EHH .equ AppBackupScreen  ; 2 bytes
RHH .equ EHH + 2  ; 2 bytes
GHH .equ RHH + 2  ; 2 bytes
UH .equ GHH + 2  ; 2 bytes
CHH .equ UH + 2  ; 2 bytes (but please make these names more descriptive!


Thank you very much for the help
1. I originally tried to as I only had a 64 bit computer but I could not get it to work (brass, spasm, and the source coder), so I went out and bought a 32 bit HP 6735b and a 32 bit copy of windows 7 ultimate (okay maybe not so much as bought as used i2p to get it) so I could use TASM.

2. AHH, okay I thought that it would, that is very good to know.

3. Again, thank you ill remember that.

Okay, I never though of the fact that the type of variable declaration and the type of register would affect it. That made it work. Sorry for the newbie error.

As for the .equ. I originally used that when I first began programming using mimas on calc but Tasm can't compile it :/. Ill have to look for a fix online.

Thank you very much, I appreciate the help.
x190 wrote:
KermMartian wrote:
Welcome to Cemetech! A few recommendations:
1) TASM is outdated and has a number of issues. Have you considered Brass, SPASM-ng, or even emSPASM-ng in SourceCoder?
2) Since labels don't affect the size of the output ASM program, let them be longer and more descriptive! Why use ENEMYH when you can use Display_Enemy_Health:?
3) Convention and good coding practices put the data after all the code in the program, so EXIT shouldn't be hiding after your .dbs.

The problem with your program is that you're defining EH, UHH, etc as .db (one byte), but you're using them with a two-byte register, DE. If you want them to be two bytes, you need to reserve their space using .dw. An even better option would be to use AppBackupScreen, as you were starting to do. At the beginning of the program, even before the .org, you'd do something like:

Code:
EHH .equ AppBackupScreen  ; 2 bytes
RHH .equ EHH + 2  ; 2 bytes
GHH .equ RHH + 2  ; 2 bytes
UH .equ GHH + 2  ; 2 bytes
CHH .equ UH + 2  ; 2 bytes (but please make these names more descriptive!


Thank you very much for the help
1. I originally tried to as I only had a 64 bit computer but I could not get it to work (brass, spasm, and the source coder), so I went out and bought a 32 bit HP 6735b and a 32 bit copy of windows 7 ultimate (okay maybe not so much as bought as used i2p to get it) so I could use TASM.

2. AHH, okay I thought that it would, that is very good to know.

3. Again, thank you ill remember that.

Okay, I never though of the fact that the type of variable declaration and the type of register would affect it. That made it work. Sorry for the newbie error.

As for the .equ. I originally used that when I first began programming using mimas on calc but Tasm can't compile it :/. Ill have to look for a fix online.

Thank you very much, I appreciate the help.

Oh my goodness! You went out and bought a whole computer for this? Such dedication!
Unfortunately (or fortunately, depending on your outlook), you don't need a 32 bit copy of Windows to code in assembly. I use SpasmNG, which allows you to compile programs on a 64 bit computer (or 32 bit still). You can even compile for a 84+CE. You can download it here: https://github.com/alberthdev/spasm-ng/releases.
Quote:

Oh my goodness! You went out and bought a whole computer for this? Such dedication!
Unfortunately (or fortunately, depending on your outlook), you don't need a 32 bit copy of Windows to code in assembly. I use SpasmNG, which allows you to compile programs on a 64 bit computer (or 32 bit still). You can even compile for a 84+CE. You can download it here: https://github.com/alberthdev/spasm-ng/releases.


Well, I bought it for $15 and then $20 for a 120gb SSD so it was not much dedication.

Oh,well. I'll just install centOS on this computer and use it to host my BBS, as the current computer is even worse.
KermMartian wrote:
3) Convention and good coding practices put the data after all the code in the program, so EXIT shouldn't be hiding after your .dbs.
As well as the fact that no code can be run after $BFFF, so you have about 8.8kb of executable code (the program is run from $9D95) without hacks. Putting the data at the end of your program doesn't take up the space for executable code. For small programs, it's not an issue.

Also, penCol and penRow are consecutive bytes in memory (just like curRow and curCol, yeah, curRow comes before curCol but penCol comes before penRow, who knows why they decided to do it that way). So you can use a 16-bit register (preferable HL, since it's faster and smaller when loading to/from addresses). Also, beware that when you do 'ld (curCol),hl', you're loading L into (curCol) and H into (curCol+1). You can instead do something like:

Code:
    ld hl,$0703  ;L = $03, H = $07
    ld (curRow),hl

which is equivalent to:

Code:
    ld a,3
    ld (curRow),a
    ld a,7
    ld (curCol),a  ;curCol is the address curRow+1

You can do the same trick with penCol (just remember that penCol comes before penRow in memory, it's the opposite of the big font, where curRow comes first). You can check the addresses of the equates in ti83plus.inc to verify.

There's also a bit we could do to make the menu much smaller and easier to make new menus, if you're interested we can give you some suggestions. For example, what about having a loop that reads through each menu item and displays it one at a time, before each text you would put the coordinates where you want to draw the text:

Code:
mainMenu:
;x,y,"text",0
.db 0,40,"-----------------------",0
.db 8,2,"WHO IS OUR TARGET, SIR?",0
;etc.
A little hint, _VPutS leaves hl pointing to the byte after the 0, so you can load mainMenu into HL, load the first value into penCol (you can use ldi, otherwise you'll have to load the value into a first then into penCol), load the second value into penRow, then run _VPutS. After that, hl will be pointing to the next menu entry. Repeat the loop until you've reached the end of your menu. You can either tell the routine how many menu items there are or you can put a special byte at the end (eg. $FF) which will tell the routine you've reached the end of the menu and should quit.
  
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.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
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

 

Advertisement