Howto try small machine code programs in BASIC ?
Re: Howto try small machine code programs in BASIC ?
Ok, then we have ALLDREAM, DOSDREAM, Encoder 09 and Dasm... Which is the best for starting?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Re: Howto try small machine code programs in BASIC ?
I suggest you try them all, and use the one that you prefer.jedie wrote:Ok, then we have ALLDREAM, DOSDREAM, Encoder 09 and Dasm... Which is the best for starting?
Re: Howto try small machine code programs in BASIC ?
OK, i must evaluate all
Here a hand made test code, that doesn't output the expected value:
The test assembler code is:
I expected that the code makes this:
set A = $12 and B = $34
store A & B to $0600, so that 12 34 will be stored
load $0600 -> D will be set to $1234
Display D -> 4660 (dez == $1234)
I have expected that 4660 will be output by JSR 38266 but it will output noting
btw. exists there a way to display the hex code instead of decimal value ?
Can i display the hex code of A or B registers or only from D ?
Here a hand made test code, that doesn't output the expected value:
Code: Select all
10 ' MACHINE CODE LOADER
20 READ LA ' LA = LOAD ADDRESS (START OF PROGRAM)
30 READ EA ' EA = ADDRESS OF FIRST INSTRUCTION
40 PA = EA 'TO BE EXECUTED
50 READ HB$ ' HEX CONSTANTS
60 IF HB$="END" THEN 100
70 POKE PA,VAL("&H"+HB$) ' POKE VALUE INTO MEMORY
80 PA = PA + 1 ' INCREMENT ADDRESS
90 GOTO 50
100 PRINT "AUTORUN WITH EXEC";EA;":"
105 PRINT "-------------------------------"
110 EXEC EA ' AUTORUN
114 PRINT
115 PRINT "-------------------------------"
120 PRINT "END ADDRESS:"; PA-1
130 PRINT "RUN AGAIN WITH EXEC";EA
149 ' LOAD ADDRESS:
150 DATA 20001
159 ' EXECUTE ADDRESS:
160 DATA 20001
165 ' MACHINE CODE IN HEX
170 DATA 34,12 ' PSHS A,X ; Save registers A, X
180 ' TEST CODE START
190 DATA 0x86, 0x12 ' LDA $12
200 DATA 0xC6, 0x34 ' LDB $34
210 DATA 0xB7, 0x06, 0x00 ' STA 0x0600 (extended) ($0600-1dff = Available graphics pages w/o DOS)
220 DATA 0xF7, 0x06, 0x01 ' STB 0x0601 (extended)
230 DATA 0xFC, 0x06, 0x00 ' LDD 0x0600 (extended)
240 ' TEST CODE END
1000 DATA BD,95,7A ' JSR 38266 ; outputs the decimal value of D register
1010 DATA 35,92 ' PULS A,X,PC ; Restore and return
1020 DATA END
Code: Select all
LDA $12
LDB $34
STA 0x0600
STB 0x0601
LDD 0x0600
set A = $12 and B = $34
store A & B to $0600, so that 12 34 will be stored
load $0600 -> D will be set to $1234
Display D -> 4660 (dez == $1234)
I have expected that 4660 will be output by JSR 38266 but it will output noting
btw. exists there a way to display the hex code instead of decimal value ?
Can i display the hex code of A or B registers or only from D ?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Re: Howto try small machine code programs in BASIC ?
I explained this to you a few pages backjedie wrote:btw. exists there a way to display the hex code instead of decimal value ?
Can i display the hex code of A or B registers or only from D ?
EDIT: Sorry, I explained A/B decimal output, not hex. See the M/L monitor example in Inside the Dragon for such routines.
Re: Howto try small machine code programs in BASIC ?
Just tried your test code with Encoder 09 and it works perfectly (as I expected).
Code: Select all
EXEC
4660
OK
LIST
10 ORG $5000
20 LDA #$12
30 LDB #$34
40 STA $0600
50 STB $0601
60 LDD $0600
70 JSR 38266
80 RTS
5000 8612 LDA #$12
5002 C634 LDB #$34
5004 B70600 STA $0600
5007 F70601 STB $0601
500A FC0600 LDD $0600
500D BD957A JSR $957A
5010 39 RTS
Code: Select all
OK
EXEC
4660
OK
LIST
10 ORG $5000
20 LDD #$1234
30 STD $0600
40 JSR $957A
50 RTS
OK
5000 CC1234 LDD #$1234
5003 FD0600 STD $0600
5006 BD957A JSR $957A
5009 39 RTS
Re: Howto try small machine code programs in BASIC ?
Code: Select all
LDA #$12
LDB #$34
STA $600
STB $601
LDD $600
JSR 38266
Re: Howto try small machine code programs in BASIC ?
Look here.jedie wrote: btw. exists there a way to display the hex code instead of decimal value ?
Re: Howto try small machine code programs in BASIC ?
Thanks!zephyr wrote:Look here.jedie wrote: btw. exists there a way to display the hex code instead of decimal value ?
Other idea beside this: save the value to display into memory and peek it from memory in BASIC and convert/ print it...
In my example i use $0600 is it a good location?
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Re: Howto try small machine code programs in BASIC ?
I cleanup the test programm a little bit:
Code: Select all
10 ' MACHINE CODE LOADER
20 READ LA ' LOAD / EXECUTE ADDRESS
25 PRINT "POKE MACHINE CODE TO: $";HEX$(LA)
30 PA = LA ' START ADDRESS FOR POKE
50 READ HB$ ' HEX CONSTANTS
60 IF HB$="END" THEN 100
70 POKE PA,VAL("&H"+HB$) ' POKE VALUE INTO MEMORY
80 PA = PA + 1 ' INCREMENT POKE ADDRESS
90 GOTO 50
100 PRINT "END ADDRESS IS: $"; HEX$(PA-1)
110 PRINT
120 PRINT "AUTORUN WITH 'EXEC &H"; HEX$(LA) ;"'"
130 PRINT "-------------------------------"
140 EXEC LA ' AUTORUN
150 PRINT
160 PRINT "-------------------------------"
170 PRINT "RUN AGAIN WITH 'EXEC &H"; HEX$(LA) ;"'"
180 ' LOAD AND EXECUTE ADDRESS:
190 DATA &H4000
200 ' MACHINE CODE IN HEX
210 DATA CC,12,34 ' LDD $1234 ; $5858 == 22616
220 DATA BD,95,7A ' JSR 38266 ; OUTPUT D REGISTER
230 DATA 39 ' RTS
1000 DATA END
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Re: Howto try small machine code programs in BASIC ?
OK, now i have a test code for SUBA:
Now i will see, how to display the CC registers.
EDIT: Hm. There is no way to store or get the CC value, isn't it?
EDIT2: Maybe it can do this: Save CC on stack and PEEK it from there???
Code: Select all
10 SA=&H5000 ' VALUE STORAGE ADDRESS
20 LA=&H4000 ' LOAD / EXECUTE ADDRESS
25 PRINT "POKE MACHINE CODE TO: $";HEX$(LA)
30 PA = LA ' START ADDRESS FOR POKE
50 READ HB$ ' HEX CONSTANTS
60 IF HB$="END" THEN 100
70 POKE PA,VAL("&H"+HB$) ' POKE VALUE INTO MEMORY
80 PA = PA + 1 ' INCREMENT POKE ADDRESS
90 GOTO 50
100 PRINT "LOADED, END ADDRESS IS: $"; HEX$(PA-1)
110 PRINT
120 POKE SA,5 ' SET START VALUE
130 PRINT "START VALUE FROM $";HEX$(SA);": $";HEX$(PEEK(SA))
150 EXEC LA
160 PRINT "VALUE FROM $";HEX$(SA);": $";HEX$(PEEK(SA))
200 PRINT "ANY KEY FOR LOOP OR 'Q' FOR QUIT"
210 A$=INKEY$:IF A$="" THEN 210
220 IF A$<>"Q" THEN GOTO 150
1000 ' MACHINE CODE IN HEX
1030 DATA B6,50,00 ' LDA $5000
1040 DATA 80,01 ' SUBA 1
1050 DATA B7,50,00 ' STA $5000
1060 DATA 39 ' RTS
10000 DATA END
EDIT: Hm. There is no way to store or get the CC value, isn't it?
EDIT2: Maybe it can do this: Save CC on stack and PEEK it from there???
... too many ideas and too little time ... Related stuff written in Python:
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809
Dragon 32 emulator / PyDC - Python Dragon 32 converter: https://github.com/jedie/DragonPy
DWLOAD server / Dragon-Lib and other stuff: https://github.com/6809